Loading pcbnew/tools/drawing_tool.cpp +51 −30 Original line number Original line Diff line number Diff line Loading @@ -83,13 +83,16 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent ) MODULE* module = m_board->m_Modules; MODULE* module = m_board->m_Modules; EDGE_MODULE* line = new EDGE_MODULE( module ); EDGE_MODULE* line = new EDGE_MODULE( module ); while( drawSegment( S_SEGMENT, line ) ) while( drawSegment( S_SEGMENT, reinterpret_cast<DRAWSEGMENT*&>( line ) ) ) { if( line ) { { m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); line->SetLocalCoord(); line->SetLocalCoord(); line->SetParent( module ); line->SetParent( module ); module->GraphicalItems().PushFront( line ); module->GraphicalItems().PushFront( line ); } line = new EDGE_MODULE( module ); line = new EDGE_MODULE( module ); } } Loading @@ -101,10 +104,13 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent ) DRAWSEGMENT* line = new DRAWSEGMENT; DRAWSEGMENT* line = new DRAWSEGMENT; while( drawSegment( S_SEGMENT, line ) ) while( drawSegment( S_SEGMENT, line ) ) { if( line ) { { m_board->Add( line ); m_board->Add( line ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( line, UR_NEW ); m_frame->SaveCopyInUndoList( line, UR_NEW ); } line = new DRAWSEGMENT; line = new DRAWSEGMENT; } } Loading @@ -126,13 +132,16 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent ) MODULE* module = m_board->m_Modules; MODULE* module = m_board->m_Modules; EDGE_MODULE* circle = new EDGE_MODULE( module ); EDGE_MODULE* circle = new EDGE_MODULE( module ); while( drawSegment( S_CIRCLE, circle ) ) while( drawSegment( S_CIRCLE, reinterpret_cast<DRAWSEGMENT*&>( circle ) ) ) { if( circle ) { { m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); circle->SetLocalCoord(); circle->SetLocalCoord(); circle->SetParent( module ); circle->SetParent( module ); module->GraphicalItems().PushFront( circle ); module->GraphicalItems().PushFront( circle ); } circle = new EDGE_MODULE( module ); circle = new EDGE_MODULE( module ); } } Loading @@ -144,10 +153,13 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent ) DRAWSEGMENT* circle = new DRAWSEGMENT; DRAWSEGMENT* circle = new DRAWSEGMENT; while( drawSegment( S_CIRCLE, circle ) ) while( drawSegment( S_CIRCLE, circle ) ) { if( circle ) { { m_board->Add( circle ); m_board->Add( circle ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( circle, UR_NEW ); m_frame->SaveCopyInUndoList( circle, UR_NEW ); } circle = new DRAWSEGMENT; circle = new DRAWSEGMENT; } } Loading @@ -169,13 +181,16 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent ) MODULE* module = m_board->m_Modules; MODULE* module = m_board->m_Modules; EDGE_MODULE* arc = new EDGE_MODULE( module ); EDGE_MODULE* arc = new EDGE_MODULE( module ); while( drawArc( arc ) ) while( drawArc( reinterpret_cast<DRAWSEGMENT*&>( arc ) ) ) { if( arc ) { { m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); arc->SetLocalCoord(); arc->SetLocalCoord(); arc->SetParent( module ); arc->SetParent( module ); module->GraphicalItems().PushFront( arc ); module->GraphicalItems().PushFront( arc ); } arc = new EDGE_MODULE( module ); arc = new EDGE_MODULE( module ); } } Loading @@ -187,10 +202,13 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent ) DRAWSEGMENT* arc = new DRAWSEGMENT; DRAWSEGMENT* arc = new DRAWSEGMENT; while( drawArc( arc ) ) while( drawArc( arc ) ) { if( arc ) { { m_board->Add( arc ); m_board->Add( arc ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( arc, UR_NEW ); m_frame->SaveCopyInUndoList( arc, UR_NEW ); } arc = new DRAWSEGMENT; arc = new DRAWSEGMENT; } } Loading Loading @@ -939,7 +957,7 @@ int DRAWING_TOOL::SetAnchor( TOOL_EVENT& aEvent ) } } bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic ) { { // Only two shapes are currently supported // Only two shapes are currently supported assert( aShape == S_SEGMENT || aShape == S_CIRCLE ); assert( aShape == S_SEGMENT || aShape == S_CIRCLE ); Loading Loading @@ -989,6 +1007,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) preview.Clear(); preview.Clear(); updatePreview = true; updatePreview = true; delete aGraphic; delete aGraphic; aGraphic = NULL; break; break; } } Loading Loading @@ -1049,7 +1068,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) else // User has clicked twice in the same spot else // User has clicked twice in the same spot { // a clear sign that the current drawing is finished { // a clear sign that the current drawing is finished delete aGraphic; // but only if at least one graphic was created delete aGraphic; // but only if at least one graphic was created started = false; // otherwise - force user to draw more or cancel aGraphic = NULL; // otherwise - force user to draw more or cancel started = false; } } preview.Clear(); preview.Clear(); Loading Loading @@ -1081,7 +1101,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) } } bool DRAWING_TOOL::drawArc( DRAWSEGMENT* aGraphic ) bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) { { bool clockwise = true; // drawing direction of the arc bool clockwise = true; // drawing direction of the arc double startAngle = 0.0f; // angle of the first arc line double startAngle = 0.0f; // angle of the first arc line Loading Loading @@ -1121,6 +1141,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT* aGraphic ) preview.Clear(); preview.Clear(); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); delete aGraphic; delete aGraphic; aGraphic = NULL; break; break; } } Loading pcbnew/tools/drawing_tool.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -156,14 +156,14 @@ private: ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> the same point. ///> the same point. bool drawSegment( int aShape, DRAWSEGMENT* aGraphic ); bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic ); ///> Starts drawing an arc. ///> Starts drawing an arc. ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> the same point. ///> the same point. bool drawArc( DRAWSEGMENT* aGraphic ); bool drawArc( DRAWSEGMENT*& aGraphic ); ///> Draws a polygon, that is added as a zone or a keepout area. ///> Draws a polygon, that is added as a zone or a keepout area. ///> @param aKeepout decides if the drawn polygon is a zone or a keepout area. ///> @param aKeepout decides if the drawn polygon is a zone or a keepout area. Loading Loading
pcbnew/tools/drawing_tool.cpp +51 −30 Original line number Original line Diff line number Diff line Loading @@ -83,13 +83,16 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent ) MODULE* module = m_board->m_Modules; MODULE* module = m_board->m_Modules; EDGE_MODULE* line = new EDGE_MODULE( module ); EDGE_MODULE* line = new EDGE_MODULE( module ); while( drawSegment( S_SEGMENT, line ) ) while( drawSegment( S_SEGMENT, reinterpret_cast<DRAWSEGMENT*&>( line ) ) ) { if( line ) { { m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); line->SetLocalCoord(); line->SetLocalCoord(); line->SetParent( module ); line->SetParent( module ); module->GraphicalItems().PushFront( line ); module->GraphicalItems().PushFront( line ); } line = new EDGE_MODULE( module ); line = new EDGE_MODULE( module ); } } Loading @@ -101,10 +104,13 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent ) DRAWSEGMENT* line = new DRAWSEGMENT; DRAWSEGMENT* line = new DRAWSEGMENT; while( drawSegment( S_SEGMENT, line ) ) while( drawSegment( S_SEGMENT, line ) ) { if( line ) { { m_board->Add( line ); m_board->Add( line ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( line, UR_NEW ); m_frame->SaveCopyInUndoList( line, UR_NEW ); } line = new DRAWSEGMENT; line = new DRAWSEGMENT; } } Loading @@ -126,13 +132,16 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent ) MODULE* module = m_board->m_Modules; MODULE* module = m_board->m_Modules; EDGE_MODULE* circle = new EDGE_MODULE( module ); EDGE_MODULE* circle = new EDGE_MODULE( module ); while( drawSegment( S_CIRCLE, circle ) ) while( drawSegment( S_CIRCLE, reinterpret_cast<DRAWSEGMENT*&>( circle ) ) ) { if( circle ) { { m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); circle->SetLocalCoord(); circle->SetLocalCoord(); circle->SetParent( module ); circle->SetParent( module ); module->GraphicalItems().PushFront( circle ); module->GraphicalItems().PushFront( circle ); } circle = new EDGE_MODULE( module ); circle = new EDGE_MODULE( module ); } } Loading @@ -144,10 +153,13 @@ int DRAWING_TOOL::DrawCircle( TOOL_EVENT& aEvent ) DRAWSEGMENT* circle = new DRAWSEGMENT; DRAWSEGMENT* circle = new DRAWSEGMENT; while( drawSegment( S_CIRCLE, circle ) ) while( drawSegment( S_CIRCLE, circle ) ) { if( circle ) { { m_board->Add( circle ); m_board->Add( circle ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( circle, UR_NEW ); m_frame->SaveCopyInUndoList( circle, UR_NEW ); } circle = new DRAWSEGMENT; circle = new DRAWSEGMENT; } } Loading @@ -169,13 +181,16 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent ) MODULE* module = m_board->m_Modules; MODULE* module = m_board->m_Modules; EDGE_MODULE* arc = new EDGE_MODULE( module ); EDGE_MODULE* arc = new EDGE_MODULE( module ); while( drawArc( arc ) ) while( drawArc( reinterpret_cast<DRAWSEGMENT*&>( arc ) ) ) { if( arc ) { { m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); m_frame->SaveCopyInUndoList( module, UR_MODEDIT ); arc->SetLocalCoord(); arc->SetLocalCoord(); arc->SetParent( module ); arc->SetParent( module ); module->GraphicalItems().PushFront( arc ); module->GraphicalItems().PushFront( arc ); } arc = new EDGE_MODULE( module ); arc = new EDGE_MODULE( module ); } } Loading @@ -187,10 +202,13 @@ int DRAWING_TOOL::DrawArc( TOOL_EVENT& aEvent ) DRAWSEGMENT* arc = new DRAWSEGMENT; DRAWSEGMENT* arc = new DRAWSEGMENT; while( drawArc( arc ) ) while( drawArc( arc ) ) { if( arc ) { { m_board->Add( arc ); m_board->Add( arc ); m_frame->OnModify(); m_frame->OnModify(); m_frame->SaveCopyInUndoList( arc, UR_NEW ); m_frame->SaveCopyInUndoList( arc, UR_NEW ); } arc = new DRAWSEGMENT; arc = new DRAWSEGMENT; } } Loading Loading @@ -939,7 +957,7 @@ int DRAWING_TOOL::SetAnchor( TOOL_EVENT& aEvent ) } } bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic ) { { // Only two shapes are currently supported // Only two shapes are currently supported assert( aShape == S_SEGMENT || aShape == S_CIRCLE ); assert( aShape == S_SEGMENT || aShape == S_CIRCLE ); Loading Loading @@ -989,6 +1007,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) preview.Clear(); preview.Clear(); updatePreview = true; updatePreview = true; delete aGraphic; delete aGraphic; aGraphic = NULL; break; break; } } Loading Loading @@ -1049,7 +1068,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) else // User has clicked twice in the same spot else // User has clicked twice in the same spot { // a clear sign that the current drawing is finished { // a clear sign that the current drawing is finished delete aGraphic; // but only if at least one graphic was created delete aGraphic; // but only if at least one graphic was created started = false; // otherwise - force user to draw more or cancel aGraphic = NULL; // otherwise - force user to draw more or cancel started = false; } } preview.Clear(); preview.Clear(); Loading Loading @@ -1081,7 +1101,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT* aGraphic ) } } bool DRAWING_TOOL::drawArc( DRAWSEGMENT* aGraphic ) bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) { { bool clockwise = true; // drawing direction of the arc bool clockwise = true; // drawing direction of the arc double startAngle = 0.0f; // angle of the first arc line double startAngle = 0.0f; // angle of the first arc line Loading Loading @@ -1121,6 +1141,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT* aGraphic ) preview.Clear(); preview.Clear(); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); delete aGraphic; delete aGraphic; aGraphic = NULL; break; break; } } Loading
pcbnew/tools/drawing_tool.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -156,14 +156,14 @@ private: ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> the same point. ///> the same point. bool drawSegment( int aShape, DRAWSEGMENT* aGraphic ); bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic ); ///> Starts drawing an arc. ///> Starts drawing an arc. ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> the same point. ///> the same point. bool drawArc( DRAWSEGMENT* aGraphic ); bool drawArc( DRAWSEGMENT*& aGraphic ); ///> Draws a polygon, that is added as a zone or a keepout area. ///> Draws a polygon, that is added as a zone or a keepout area. ///> @param aKeepout decides if the drawn polygon is a zone or a keepout area. ///> @param aKeepout decides if the drawn polygon is a zone or a keepout area. Loading