Loading pcbnew/tools/drawing_tool.cpp +46 −23 Original line number Original line Diff line number Diff line Loading @@ -289,18 +289,22 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent ) break; break; } } else if( evt->IsKeyPressed() && step != SET_ORIGIN ) else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) && step != SET_ORIGIN ) { { width = dimension->GetWidth(); dimension->SetWidth( dimension->GetWidth() + WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } // Modify the new item width else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) && step != SET_ORIGIN ) if( evt->KeyCode() == '-' && width > WIDTH_STEP ) { dimension->SetWidth( width - WIDTH_STEP ); int width = dimension->GetWidth(); else if( evt->KeyCode() == '=' ) dimension->SetWidth( width + WIDTH_STEP ); if( width > WIDTH_STEP ) { dimension->SetWidth( width - WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } } else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) ) { { Loading Loading @@ -465,18 +469,22 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent ) if( evt->IsCancel() || evt->IsActivate() ) if( evt->IsCancel() || evt->IsActivate() ) break; break; else if( evt->IsKeyPressed() ) else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) { target->SetWidth( target->GetWidth() + WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) { { int width = target->GetWidth(); int width = target->GetWidth(); // Modify the new item width if( width > WIDTH_STEP ) if( evt->KeyCode() == '-' && width > WIDTH_STEP ) { target->SetWidth( width - WIDTH_STEP ); target->SetWidth( width - WIDTH_STEP ); else if( evt->KeyCode() == '=' ) target->SetWidth( width + WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } } else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) ) { { Loading Loading @@ -893,7 +901,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, // Init the new item attributes // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetWidth( m_board->GetDesignSettings().m_DrawSegmentWidth ); aGraphic->SetWidth( lineWidth ); aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) ); aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer ); Loading Loading @@ -955,7 +963,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, { { // Init the new item attributes // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetWidth( m_board->GetDesignSettings().m_DrawSegmentWidth ); lineWidth = getSegmentWidth( layer ); aGraphic->SetWidth( lineWidth ); aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer ); Loading Loading @@ -1003,17 +1012,17 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) { { aGraphic->SetWidth( aGraphic->GetWidth() + WIDTH_STEP ); lineWidth += WIDTH_STEP; aGraphic->SetWidth( lineWidth ); updatePreview = true; updatePreview = true; } } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) { { int width = aGraphic->GetWidth(); if( lineWidth > WIDTH_STEP ) if( width > WIDTH_STEP ) { { aGraphic->SetWidth( width - WIDTH_STEP ); lineWidth -= WIDTH_STEP; aGraphic->SetWidth( lineWidth ); updatePreview = true; updatePreview = true; } } } } Loading Loading @@ -1093,7 +1102,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) // Init the new item attributes // Init the new item attributes aGraphic->SetShape( S_ARC ); aGraphic->SetShape( S_ARC ); aGraphic->SetAngle( 0.0 ); aGraphic->SetAngle( 0.0 ); aGraphic->SetWidth( m_board->GetDesignSettings().m_DrawSegmentWidth ); aGraphic->SetWidth( getSegmentWidth( layer ) ); aGraphic->SetCenter( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetCenter( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer ); Loading Loading @@ -1685,3 +1694,17 @@ void DRAWING_TOOL::setTransitions() Go( &DRAWING_TOOL::PlaceDXF, COMMON_ACTIONS::placeDXF.MakeEvent() ); Go( &DRAWING_TOOL::PlaceDXF, COMMON_ACTIONS::placeDXF.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, COMMON_ACTIONS::setAnchor.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, COMMON_ACTIONS::setAnchor.MakeEvent() ); } } int DRAWING_TOOL::getSegmentWidth( unsigned int aLayer ) const { assert( m_board ); if( aLayer == Edge_Cuts ) return m_board->GetDesignSettings().m_EdgeSegmentWidth; else if( m_editModules ) return m_board->GetDesignSettings().m_ModuleSegmentWidth; else return m_board->GetDesignSettings().m_DrawSegmentWidth; } pcbnew/tools/drawing_tool.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -191,6 +191,9 @@ private: ///> Sets up handlers for various events. ///> Sets up handlers for various events. void setTransitions(); void setTransitions(); ///> Returns the appropriate width for a segment depending on the settings. int getSegmentWidth( unsigned int aLayer ) const; KIGFX::VIEW* m_view; KIGFX::VIEW* m_view; KIGFX::VIEW_CONTROLS* m_controls; KIGFX::VIEW_CONTROLS* m_controls; BOARD* m_board; BOARD* m_board; Loading @@ -199,6 +202,9 @@ private: /// Edit module mode flag /// Edit module mode flag bool m_editModules; bool m_editModules; /// Stores the current line width for multisegment drawing. unsigned int lineWidth; // How does line width change after one -/+ key press. // How does line width change after one -/+ key press. static const int WIDTH_STEP = 100000; static const int WIDTH_STEP = 100000; }; }; Loading Loading
pcbnew/tools/drawing_tool.cpp +46 −23 Original line number Original line Diff line number Diff line Loading @@ -289,18 +289,22 @@ int DRAWING_TOOL::DrawDimension( TOOL_EVENT& aEvent ) break; break; } } else if( evt->IsKeyPressed() && step != SET_ORIGIN ) else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) && step != SET_ORIGIN ) { { width = dimension->GetWidth(); dimension->SetWidth( dimension->GetWidth() + WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } // Modify the new item width else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) && step != SET_ORIGIN ) if( evt->KeyCode() == '-' && width > WIDTH_STEP ) { dimension->SetWidth( width - WIDTH_STEP ); int width = dimension->GetWidth(); else if( evt->KeyCode() == '=' ) dimension->SetWidth( width + WIDTH_STEP ); if( width > WIDTH_STEP ) { dimension->SetWidth( width - WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } } else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) ) { { Loading Loading @@ -465,18 +469,22 @@ int DRAWING_TOOL::PlaceTarget( TOOL_EVENT& aEvent ) if( evt->IsCancel() || evt->IsActivate() ) if( evt->IsCancel() || evt->IsActivate() ) break; break; else if( evt->IsKeyPressed() ) else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) { target->SetWidth( target->GetWidth() + WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) { { int width = target->GetWidth(); int width = target->GetWidth(); // Modify the new item width if( width > WIDTH_STEP ) if( evt->KeyCode() == '-' && width > WIDTH_STEP ) { target->SetWidth( width - WIDTH_STEP ); target->SetWidth( width - WIDTH_STEP ); else if( evt->KeyCode() == '=' ) target->SetWidth( width + WIDTH_STEP ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); } } } else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) ) { { Loading Loading @@ -893,7 +901,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, // Init the new item attributes // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetWidth( m_board->GetDesignSettings().m_DrawSegmentWidth ); aGraphic->SetWidth( lineWidth ); aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) ); aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer ); Loading Loading @@ -955,7 +963,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, { { // Init the new item attributes // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetWidth( m_board->GetDesignSettings().m_DrawSegmentWidth ); lineWidth = getSegmentWidth( layer ); aGraphic->SetWidth( lineWidth ); aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer ); Loading Loading @@ -1003,17 +1012,17 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) { { aGraphic->SetWidth( aGraphic->GetWidth() + WIDTH_STEP ); lineWidth += WIDTH_STEP; aGraphic->SetWidth( lineWidth ); updatePreview = true; updatePreview = true; } } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) { { int width = aGraphic->GetWidth(); if( lineWidth > WIDTH_STEP ) if( width > WIDTH_STEP ) { { aGraphic->SetWidth( width - WIDTH_STEP ); lineWidth -= WIDTH_STEP; aGraphic->SetWidth( lineWidth ); updatePreview = true; updatePreview = true; } } } } Loading Loading @@ -1093,7 +1102,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) // Init the new item attributes // Init the new item attributes aGraphic->SetShape( S_ARC ); aGraphic->SetShape( S_ARC ); aGraphic->SetAngle( 0.0 ); aGraphic->SetAngle( 0.0 ); aGraphic->SetWidth( m_board->GetDesignSettings().m_DrawSegmentWidth ); aGraphic->SetWidth( getSegmentWidth( layer ) ); aGraphic->SetCenter( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetCenter( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer ); Loading Loading @@ -1685,3 +1694,17 @@ void DRAWING_TOOL::setTransitions() Go( &DRAWING_TOOL::PlaceDXF, COMMON_ACTIONS::placeDXF.MakeEvent() ); Go( &DRAWING_TOOL::PlaceDXF, COMMON_ACTIONS::placeDXF.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, COMMON_ACTIONS::setAnchor.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, COMMON_ACTIONS::setAnchor.MakeEvent() ); } } int DRAWING_TOOL::getSegmentWidth( unsigned int aLayer ) const { assert( m_board ); if( aLayer == Edge_Cuts ) return m_board->GetDesignSettings().m_EdgeSegmentWidth; else if( m_editModules ) return m_board->GetDesignSettings().m_ModuleSegmentWidth; else return m_board->GetDesignSettings().m_DrawSegmentWidth; }
pcbnew/tools/drawing_tool.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -191,6 +191,9 @@ private: ///> Sets up handlers for various events. ///> Sets up handlers for various events. void setTransitions(); void setTransitions(); ///> Returns the appropriate width for a segment depending on the settings. int getSegmentWidth( unsigned int aLayer ) const; KIGFX::VIEW* m_view; KIGFX::VIEW* m_view; KIGFX::VIEW_CONTROLS* m_controls; KIGFX::VIEW_CONTROLS* m_controls; BOARD* m_board; BOARD* m_board; Loading @@ -199,6 +202,9 @@ private: /// Edit module mode flag /// Edit module mode flag bool m_editModules; bool m_editModules; /// Stores the current line width for multisegment drawing. unsigned int lineWidth; // How does line width change after one -/+ key press. // How does line width change after one -/+ key press. static const int WIDTH_STEP = 100000; static const int WIDTH_STEP = 100000; }; }; Loading