Commit 09182d81 authored by tomasz.'s avatar tomasz.

View: various fixes, added VIEW::IsDirty()

parent cc6ca277
...@@ -498,14 +498,16 @@ struct VIEW::drawItem ...@@ -498,14 +498,16 @@ struct VIEW::drawItem
{ {
group = gal->BeginGroup(); group = gal->BeginGroup();
aItem->setGroup( currentLayer->id, group ); aItem->setGroup( currentLayer->id, group );
view->m_painter->Draw( aItem, currentLayer->id ); if(!view->m_painter->Draw( aItem, currentLayer->id ))
aItem->ViewDraw(currentLayer->id, gal, BOX2I());
gal->EndGroup(); gal->EndGroup();
} }
} }
else else
{ {
// Immediate mode // Immediate mode
view->m_painter->Draw( aItem, currentLayer->id ); if(!view->m_painter->Draw( aItem, currentLayer->id ))
aItem->ViewDraw(currentLayer->id, gal, BOX2I());
} }
} }
...@@ -526,11 +528,20 @@ void VIEW::redrawRect( const BOX2I& aRect ) ...@@ -526,11 +528,20 @@ void VIEW::redrawRect( const BOX2I& aRect )
m_gal->SetTarget( l->target ); m_gal->SetTarget( l->target );
m_gal->SetLayerDepth( l->renderingOrder ); m_gal->SetLayerDepth( l->renderingOrder );
l->items->Query( aRect, drawFunc ); l->items->Query( aRect, drawFunc );
l->isDirty = false;
} }
l->isDirty = false;
} }
} }
bool VIEW::IsDirty()
{
BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers )
{
if(l->isDirty)
return true;
}
return false;
}
struct VIEW::unlinkItem struct VIEW::unlinkItem
{ {
...@@ -622,18 +633,22 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags ) ...@@ -622,18 +633,22 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
for( int i = 0; i < layer_count; i++ ) for( int i = 0; i < layer_count; i++ )
{ {
VIEW_LAYER* l = &m_layers[layer_indices[i]]; if(m_layers.find(layer_indices[i]) != m_layers.end())
{
VIEW_LAYER* l = &m_layers[layer_indices[i]];
l->dirtyExtents = l->dirtyExtents =
l->isDirty ? aItem->ViewBBox() : l->dirtyExtents.Merge( aItem->ViewBBox() ); l->isDirty ? aItem->ViewBBox() : l->dirtyExtents.Merge( aItem->ViewBBox() );
if( aUpdateFlags & VIEW_ITEM::GEOMETRY ) l->isDirty = true;
{
l->items->Remove( aItem );
l->items->Insert( aItem ); /* reinsert */
aItem->deleteGroups(); if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
} {
l->items->Remove( aItem );
l->items->Insert( aItem ); /* reinsert */
aItem->deleteGroups();
}
}
} }
if( aItem->storesGroups() ) if( aItem->storesGroups() )
......
...@@ -57,6 +57,9 @@ void VIEW_ITEM::ViewGetRequiredLayers( int aLayers[], int& aCount ) const ...@@ -57,6 +57,9 @@ void VIEW_ITEM::ViewGetRequiredLayers( int aLayers[], int& aCount ) const
void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw )
{ {
if(!m_view)
return;
m_view->invalidateItem( this, aUpdateFlags ); m_view->invalidateItem( this, aUpdateFlags );
if( aForceImmediateRedraw ) if( aForceImmediateRedraw )
...@@ -140,3 +143,9 @@ bool VIEW_ITEM::storesGroups() const ...@@ -140,3 +143,9 @@ bool VIEW_ITEM::storesGroups() const
{ {
return ( m_groupsSize > 0 ); return ( m_groupsSize > 0 );
} }
void VIEW_ITEM::ViewSetHighlighted( bool aIsHighlighted )
{
m_highlighted = aIsHighlighted;
ViewUpdate(APPEARANCE | GEOMETRY);
}
...@@ -270,7 +270,7 @@ public: ...@@ -270,7 +270,7 @@ public:
} }
/** /**
* Function SetLayerOrder() * Function SetLayerOrder()
* Sets rendering order of a particular layer. * Sets rendering order of a particular layer.
* @param aLayer: the layer * @param aLayer: the layer
* @param aRenderingOrder: arbitrary number denoting the rendering order. * @param aRenderingOrder: arbitrary number denoting the rendering order.
...@@ -360,6 +360,8 @@ public: ...@@ -360,6 +360,8 @@ public:
*/ */
bool IsDynamic() const { return m_dynamic; } bool IsDynamic() const { return m_dynamic; }
bool IsDirty();
static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown
private: private:
......
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
JUMP = 2 JUMP = 2
}; };
VIEW_CONTROLS( VIEW* aView ) : m_view( aView ) {}; VIEW_CONTROLS( VIEW* aView ) : m_view( aView ) {};
virtual ~VIEW_CONTROLS() {}; virtual ~VIEW_CONTROLS() {};
...@@ -74,7 +75,7 @@ public: ...@@ -74,7 +75,7 @@ public:
virtual void SetGrabMouse( bool aEnabled ) {}; virtual void SetGrabMouse( bool aEnabled ) {};
/** /**
* Function SetGrabMouse * Function SetAutoPan
* Turns on/off auto panning (this feature is used when there is a tool active (eg. drawing a * Turns on/off auto panning (this feature is used when there is a tool active (eg. drawing a
* track) and user moves mouse to the VIEW edge - then the view can be translated or not). * track) and user moves mouse to the VIEW edge - then the view can be translated or not).
* @param aEnabled tells if the autopanning should be active. * @param aEnabled tells if the autopanning should be active.
...@@ -108,6 +109,11 @@ public: ...@@ -108,6 +109,11 @@ public:
*/ */
virtual void AnimatedZoom( const BOX2I& aExtents ) {}; virtual void AnimatedZoom( const BOX2I& aExtents ) {};
virtual void WarpCursor (const VECTOR2D& aPosition ) {};
virtual void ShowCursor (bool aEnabled ) {};
protected: protected:
/// Pointer to controlled VIEW. /// Pointer to controlled VIEW.
VIEW* m_view; VIEW* m_view;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <view/view_controls.h> #include <view/view_controls.h>
class EDA_DRAW_PANEL_GAL; class EDA_DRAW_PANEL_GAL;
class TOOL_DISPATCHER;
namespace KiGfx namespace KiGfx
{ {
...@@ -56,6 +57,8 @@ public: ...@@ -56,6 +57,8 @@ public:
void onButton( wxMouseEvent& event ); void onButton( wxMouseEvent& event );
void onEnter( wxMouseEvent& event ); void onEnter( wxMouseEvent& event );
void SetEventDispatcher( TOOL_DISPATCHER *aEventDispatcher );
private: private:
/// Options for WX_VIEW_CONTROLS /// Options for WX_VIEW_CONTROLS
...@@ -80,6 +83,7 @@ private: ...@@ -80,6 +83,7 @@ private:
/// Used for determining time intervals between events. /// Used for determining time intervals between events.
wxLongLong m_timeStamp; wxLongLong m_timeStamp;
TOOL_DISPATCHER* m_eventDispatcher;
}; };
} // namespace KiGfx } // namespace KiGfx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment