Commit c5a3c108 authored by Maciej Suminski's avatar Maciej Suminski

Removed a few RecacheAllItems() calls, some of them changed to specific type...

Removed a few RecacheAllItems() calls, some of them changed to specific type recaching (using TYPE_COLLECTOR & VIEW_ITEM::ViewUpdate() ).
Removed OPENGL_GAL::SetStrokeColor().
parent f7d00a39
...@@ -226,10 +226,7 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType ) ...@@ -226,10 +226,7 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
m_painter->SetGAL( m_gal ); m_painter->SetGAL( m_gal );
if( m_view ) if( m_view )
{
m_view->SetGAL( m_gal ); m_view->SetGAL( m_gal );
m_view->RecacheAllItems( true );
}
m_currentGal = aGalType; m_currentGal = aGalType;
m_pendingRefresh = false; m_pendingRefresh = false;
......
...@@ -77,6 +77,8 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -77,6 +77,8 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
// Allocate memory for pixel storage // Allocate memory for pixel storage
allocateBitmaps(); allocateBitmaps();
initSurface();
} }
...@@ -954,7 +956,8 @@ void CAIRO_GAL::deleteBitmaps() ...@@ -954,7 +956,8 @@ void CAIRO_GAL::deleteBitmaps()
void CAIRO_GAL::initSurface() void CAIRO_GAL::initSurface()
{ {
wxASSERT( !isInitialized ); if( isInitialized )
return;
// Create the Cairo surface // Create the Cairo surface
surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT, surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT,
......
...@@ -101,6 +101,8 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener, ...@@ -101,6 +101,8 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
} }
gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE ); gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
currentManager = &nonCachedManager;
} }
...@@ -248,6 +250,8 @@ void OPENGL_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoin ...@@ -248,6 +250,8 @@ void OPENGL_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoin
const VECTOR2D startEndVector = aEndPoint - aStartPoint; const VECTOR2D startEndVector = aEndPoint - aStartPoint;
double lineAngle = startEndVector.Angle(); double lineAngle = startEndVector.Angle();
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
drawLineQuad( aStartPoint, aEndPoint ); drawLineQuad( aStartPoint, aEndPoint );
// Line caps // Line caps
...@@ -468,6 +472,8 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList ) ...@@ -468,6 +472,8 @@ void OPENGL_GAL::DrawPolyline( std::deque<VECTOR2D>& aPointList )
if( aPointList.empty() ) if( aPointList.empty() )
return; return;
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
std::deque<VECTOR2D>::const_iterator it = aPointList.begin(); std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
// Start from the second point // Start from the second point
...@@ -590,15 +596,6 @@ void OPENGL_GAL::ClearScreen() ...@@ -590,15 +596,6 @@ void OPENGL_GAL::ClearScreen()
} }
void OPENGL_GAL::SetStrokeColor( const COLOR4D& aColor )
{
strokeColor = aColor;
// This is the default drawing color
currentManager->Color( aColor.r, aColor.g, aColor.b, aColor.a );
}
void OPENGL_GAL::Transform( const MATRIX3x3D& aTransformation ) void OPENGL_GAL::Transform( const MATRIX3x3D& aTransformation )
{ {
GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
...@@ -795,8 +792,23 @@ void OPENGL_GAL::drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd ...@@ -795,8 +792,23 @@ void OPENGL_GAL::drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd
} }
inline void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint )
{ {
/* Helper drawing: ____--- v3 ^
* ____---- ... \ \
* ____---- ... \ end \
* v1 ____---- ... ____---- \ width
* ---- ...___---- \ \
* \ ___...-- \ v
* \ ____----... ____---- v2
* ---- ... ____----
* start \ ... ____----
* \... ____----
* ----
* v0
* dots mark triangles' hypotenuses
*/
VECTOR2D startEndVector = aEndPoint - aStartPoint; VECTOR2D startEndVector = aEndPoint - aStartPoint;
double lineLength = startEndVector.EuclideanNorm(); double lineLength = startEndVector.EuclideanNorm();
double scale = 0.5 * lineWidth / lineLength; double scale = 0.5 * lineWidth / lineLength;
...@@ -854,8 +866,8 @@ void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRad ...@@ -854,8 +866,8 @@ void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRad
/* Draw a triangle that contains the semicircle, then shade it to leave only /* Draw a triangle that contains the semicircle, then shade it to leave only
* the semicircle. Parameters given to setShader are indices of the triangle's vertices * the semicircle. Parameters given to setShader are indices of the triangle's vertices
* (if you want to understand more, check the vertex shader source [shader.vert]). * (if you want to understand more, check the vertex shader source [shader.vert]).
* Shader uses this coordinates to determine if fragments are inside the semicircle or not. * Shader uses these coordinates to determine if fragments are inside the semicircle or not.
* v2 * v2
* /\ * /\
* /__\ * /__\
...@@ -885,9 +897,9 @@ void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRa ...@@ -885,9 +897,9 @@ void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRa
/* Draw a triangle that contains the semicircle, then shade it to leave only /* Draw a triangle that contains the semicircle, then shade it to leave only
* the semicircle. Parameters given to setShader are indices of the triangle's vertices * the semicircle. Parameters given to setShader are indices of the triangle's vertices
* (if you want to understand more, check the vertex shader source [shader.vert]), the * (if you want to understand more, check the vertex shader source [shader.vert]), the
* radius and the line width. Shader uses this coordinates to determine if fragments are * radius and the line width. Shader uses these coordinates to determine if fragments are
* inside the semicircle or not. * inside the semicircle or not.
* v2 * v2
* /\ * /\
* /__\ * /__\
......
...@@ -145,13 +145,6 @@ public: ...@@ -145,13 +145,6 @@ public:
/// @copydoc GAL::ClearScreen() /// @copydoc GAL::ClearScreen()
virtual void ClearScreen(); virtual void ClearScreen();
// -----------------
// Attribute setting
// -----------------
/// @copydoc GAL::SetStrokeColor()
virtual void SetStrokeColor( const COLOR4D& aColor );
// -------------- // --------------
// Transformation // Transformation
// -------------- // --------------
...@@ -311,7 +304,7 @@ private: ...@@ -311,7 +304,7 @@ private:
* @param aStartPoint is the start point of the line. * @param aStartPoint is the start point of the line.
* @param aEndPoint is the end point of the line. * @param aEndPoint is the end point of the line.
*/ */
inline void drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); void drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint );
/** /**
* @brief Draw a semicircle. Depending on settings (isStrokeEnabled & isFilledEnabled) it runs * @brief Draw a semicircle. Depending on settings (isStrokeEnabled & isFilledEnabled) it runs
......
...@@ -443,7 +443,14 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent ) ...@@ -443,7 +443,14 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
KIGFX::PCB_RENDER_SETTINGS* settings = KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() ); static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
settings->LoadDisplayOptions( DisplayOpt ); settings->LoadDisplayOptions( DisplayOpt );
GetGalCanvas()->GetView()->RecacheAllItems( true );
// Update pads
BOARD* board = GetBoard();
for( MODULE* module = board->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
pad->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
m_canvas->Refresh(); m_canvas->Refresh();
} }
......
...@@ -177,10 +177,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) ...@@ -177,10 +177,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
settings->LoadDisplayOptions( DisplayOpt ); settings->LoadDisplayOptions( DisplayOpt );
view->RecacheAllItems( true ); view->RecacheAllItems( true );
if( m_Parent->IsGalCanvasActive() ) m_Parent->GetCanvas()->Refresh();
m_Parent->GetGalCanvas()->Refresh();
else
m_Parent->GetCanvas()->Refresh();
EndModal( 1 ); EndModal( 1 );
} }
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <kicad_string.h> #include <kicad_string.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <class_board.h> #include <class_board.h>
#include <collectors.h>
#include <dialog_general_options.h> #include <dialog_general_options.h>
#include <class_drawpanel_gal.h> #include <class_drawpanel_gal.h>
...@@ -157,7 +158,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -157,7 +158,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
static_cast<KIGFX::PCB_PAINTER*> ( GetGalCanvas()->GetView()->GetPainter() ); static_cast<KIGFX::PCB_PAINTER*> ( GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings = KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() ); static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
bool recache = false; KICAD_T updateType = EOT;
switch( id ) switch( id )
{ {
...@@ -192,31 +193,31 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -192,31 +193,31 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_ZONES: case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0; DisplayOpt.DisplayZonesMode = 0;
recache = true; updateType = PCB_ZONE_T;
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE: case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1; DisplayOpt.DisplayZonesMode = 1;
recache = true; updateType = PCB_ZONE_T;
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY: case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2; DisplayOpt.DisplayZonesMode = 2;
recache = true; updateType = PCB_ZONE_T;
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state; m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state;
recache = true; updateType = PCB_VIA_T;
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state; m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
recache = true; updateType = PCB_TRACE_T;
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
...@@ -256,11 +257,18 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -256,11 +257,18 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
break; break;
} }
if( recache ) if( updateType != EOT )
{ {
// Apply new display options to the GAL canvas // Apply new display options to the GAL canvas
settings->LoadDisplayOptions( DisplayOpt ); settings->LoadDisplayOptions( DisplayOpt );
GetGalCanvas()->GetView()->RecacheAllItems( true );
// Find items that require update
KICAD_T scanList[] = { updateType, EOT };
TYPE_COLLECTOR collector;
collector.Collect( GetBoard(), scanList );
for( int i = 0; i < collector.GetCount(); ++i )
collector[i]->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
} }
if( IsGalCanvasActive() ) if( IsGalCanvasActive() )
......
...@@ -544,21 +544,15 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -544,21 +544,15 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
// Load zones // Load zones
for( int i = 0; i < aBoard->GetAreaCount(); ++i ) for( int i = 0; i < aBoard->GetAreaCount(); ++i )
{
view->Add( (KIGFX::VIEW_ITEM*) ( aBoard->GetArea( i ) ) ); view->Add( (KIGFX::VIEW_ITEM*) ( aBoard->GetArea( i ) ) );
}
// Load drawings // Load drawings
for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() ) for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() )
{
view->Add( drawing ); view->Add( drawing );
}
// Load tracks // Load tracks
for( TRACK* track = aBoard->m_Track; track; track = track->Next() ) for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
{
view->Add( track ); view->Add( track );
}
// Load modules and its additional elements // Load modules and its additional elements
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
...@@ -569,9 +563,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -569,9 +563,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
// Segzones (equivalent of ZONE_CONTAINER for legacy boards) // Segzones (equivalent of ZONE_CONTAINER for legacy boards)
for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() ) for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() )
{
view->Add( zone ); view->Add( zone );
}
// Add an entry for the worksheet layout // Add an entry for the worksheet layout
KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM( KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM(
...@@ -587,7 +579,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -587,7 +579,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view->Add( new KIGFX::RATSNEST_VIEWITEM( ratsnest ) ); view->Add( new KIGFX::RATSNEST_VIEWITEM( ratsnest ) );
view->SetPanBoundary( worksheet->ViewBBox() ); view->SetPanBoundary( worksheet->ViewBBox() );
view->RecacheAllItems( true ); view->RecacheAllItems( false );
if( IsGalCanvasActive() ) if( IsGalCanvasActive() )
GetGalCanvas()->Refresh(); GetGalCanvas()->Refresh();
......
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