diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp index 30d0db5d8d..20e9444147 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp @@ -45,7 +45,7 @@ #include /** - * Scale convertion from 3d model units to pcb units + * Scale conversion from 3d model units to pcb units */ #define UNITS3D_TO_UNITSPCB (IU_PER_MM) @@ -76,6 +76,8 @@ C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY( BOARD_ADAPTER& aAdapter, CCAMERA& m_ogl_disp_list_grid = 0; m_last_grid_type = GRID3D_TYPE::NONE; m_currentIntersectedBoardItem = nullptr; + m_ogl_disp_list_board_with_holes = nullptr; + m_ogl_disp_list_through_holes_outer_with_npth = nullptr; m_3dmodel_map.clear(); } @@ -460,6 +462,7 @@ SFVEC4F C3D_RENDER_OGL_LEGACY::get_layer_color( PCB_LAYER_ID aLayerID ) return layerColor; } + void init_lights(void) { // Setup light @@ -508,11 +511,13 @@ void init_lights(void) glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE ); } + void C3D_RENDER_OGL_LEGACY::setCopperMaterial() { OGL_SetMaterial( m_materials.m_NonPlatedCopper, 1.0f ); } + void C3D_RENDER_OGL_LEGACY::setPlatedCopperAndDepthOffset( PCB_LAYER_ID aLayer_id ) { glEnable( GL_POLYGON_OFFSET_FILL ); @@ -520,11 +525,13 @@ void C3D_RENDER_OGL_LEGACY::setPlatedCopperAndDepthOffset( PCB_LAYER_ID aLayer_i set_layer_material( aLayer_id ); } + void C3D_RENDER_OGL_LEGACY::unsetDepthOffset() { glDisable( GL_POLYGON_OFFSET_FILL ); } + void C3D_RENDER_OGL_LEGACY::render_board_body( bool aSkipRenderHoles ) { m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor; @@ -550,10 +557,11 @@ void C3D_RENDER_OGL_LEGACY::render_board_body( bool aSkipRenderHoles ) } } -bool C3D_RENDER_OGL_LEGACY::Redraw( - bool aIsMoving, REPORTER* aStatusReporter, REPORTER* aWarningReporter ) + +bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter, + REPORTER* aWarningReporter ) { - // Initialize openGL + // Initialize OpenGL if( !m_is_opengl_initialized ) { if( !initializeOpenGL() ) @@ -590,8 +598,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( // ///////////////////////////////////////////////////////////////////////// glDepthFunc( GL_LESS ); glEnable( GL_CULL_FACE ); - glFrontFace( GL_CCW ); // This is the openGL default - glEnable( GL_NORMALIZE ); // This allow openGL to normalize the normals after transformations + glFrontFace( GL_CCW ); // This is the OpenGL default + glEnable( GL_NORMALIZE ); // This allow OpenGL to normalize the normals after transformations glViewport( 0, 0, m_windowSize.x, m_windowSize.y ); @@ -639,7 +647,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( { const SFVEC3F &cameraPos = m_camera.GetPos(); - // Place the light at a minimun Z so the diffuse factor will not drop + // Place the light at a minimum Z so the diffuse factor will not drop // and the board will still look with good light. float zpos; @@ -689,7 +697,6 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( m_ogl_disp_list_pads_holes->DrawAll(); } - // Display copper and tech layers // ///////////////////////////////////////////////////////////////////////// for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin(); @@ -738,10 +745,12 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( setPlatedCopperAndDepthOffset( layer_id ); if( ( layer_id == F_Cu ) && m_ogl_disp_lists_platedPads_F_Cu ) - m_ogl_disp_lists_platedPads_F_Cu->DrawAllCameraCulled( m_camera.GetPos().z, drawMiddleSegments ); + m_ogl_disp_lists_platedPads_F_Cu->DrawAllCameraCulled( m_camera.GetPos().z, + drawMiddleSegments ); else if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu ) - m_ogl_disp_lists_platedPads_B_Cu->DrawAllCameraCulled( m_camera.GetPos().z, drawMiddleSegments ); + m_ogl_disp_lists_platedPads_B_Cu->DrawAllCameraCulled( m_camera.GetPos().z, + drawMiddleSegments ); unsetDepthOffset(); } @@ -1249,7 +1258,10 @@ void C3D_RENDER_OGL_LEGACY::render_solder_mask_layer(PCB_LAYER_ID aLayerID, } } -void C3D_RENDER_OGL_LEGACY::render_3D_models_selected( bool aRenderTopOrBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly ) + +void C3D_RENDER_OGL_LEGACY::render_3D_models_selected( bool aRenderTopOrBot, + bool aRenderTransparentOnly, + bool aRenderSelectedOnly ) { C_OGL_3DMODEL::BeginDrawMulti( !aRenderSelectedOnly ); @@ -1291,6 +1303,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_models_selected( bool aRenderTopOrBot, boo C_OGL_3DMODEL::EndDrawMulti(); } + void C3D_RENDER_OGL_LEGACY::render_3D_models( bool aRenderTopOrBot, bool aRenderTransparentOnly ) { @@ -1401,7 +1414,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module, } -// create a 3D grid to an openGL display list: an horizontal grid (XY plane and Z = 0, +// create a 3D grid to an OpenGL display list: an horizontal grid (XY plane and Z = 0, // and a vertical grid (XZ plane and Y = 0) void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType ) { diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 6f94a73954..d0f05e8e7d 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -1,13 +1,13 @@ /** * @file PDF_plotter.cpp - * @brief Kicad: specialized plotter for PDF files format + * @brief KiCad: specialized plotter for PDF files format */ /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2012 Lorenzo Marcantonio, l.marcantonio@logossrl.com - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -29,12 +29,8 @@ #include #include -//#include -//#include #include #include -//#include -//#include // for KiROUND #include #include @@ -44,10 +40,10 @@ std::string PDF_PLOTTER::encodeStringForPlotter( const wxString& aText ) { -// returns a string compatible with PDF string convention from a unicode string. -// if the initial text is only ASCII7, return the text between ( and ) for a good readability -// if the initial text is no ASCII7, return the text between < and > -// and encoded using 16 bits hexa (4 digits) by wide char (unicode 16) + // returns a string compatible with PDF string convention from a unicode string. + // if the initial text is only ASCII7, return the text between ( and ) for a good readability + // if the initial text is no ASCII7, return the text between < and > + // and encoded using 16 bits hexa (4 digits) by wide char (unicode 16) std::string result; // Is aText only ASCII7 ? @@ -107,12 +103,6 @@ std::string PDF_PLOTTER::encodeStringForPlotter( const wxString& aText ) } -/* - * Open or create the plot file aFullFilename - * return true if success, false if the file cannot be created/opened - * - * Opens the PDF file in binary mode - */ bool PDF_PLOTTER::OpenFile( const wxString& aFullFilename ) { filename = aFullFilename; @@ -137,22 +127,14 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, plotScale = aScale; m_IUsPerDecimil = aIusPerDecimil; - // The CTM is set to 1 user unit per decimil + // The CTM is set to 1 user unit per decimal iuPerDeviceUnit = 1.0 / aIusPerDecimil; - /* The paper size in this engined is handled page by page + /* The paper size in this engine is handled page by page Look in the StartPage function */ } -/** - * Pen width setting for PDF. Since the specs *explicitly* says that a 0 - * width is a bad thing to use (since it results in 1 pixel traces), we - * convert such requests to the minimal width (like 1) - * Note pen width = 0 is used in plot polygons to plot filled polygons with - * no outline thickness - * use in this case pen width = 1 does not actally change the polygon - */ void PDF_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) { wxASSERT( workFile ); @@ -174,15 +156,6 @@ void PDF_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) } -/** - * PDF supports colors fully. It actually has distinct fill and pen colors, - * but we set both at the same time. - * - * XXX Keeping them divided could result in a minor optimization in - * eeschema filled shapes, but would propagate to all the other plot - * engines. Also arcs are filled as pies but only the arc is stroked so - * it would be difficult to handle anyway. - */ void PDF_PLOTTER::emitSetRGBColor( double r, double g, double b ) { wxASSERT( workFile ); @@ -190,9 +163,7 @@ void PDF_PLOTTER::emitSetRGBColor( double r, double g, double b ) r, g, b, r, g, b ); } -/** - * PDF supports dashed lines - */ + void PDF_PLOTTER::SetDash( PLOT_DASH_TYPE dashed ) { wxASSERT( workFile ); @@ -217,9 +188,6 @@ void PDF_PLOTTER::SetDash( PLOT_DASH_TYPE dashed ) } -/** - * Rectangles in PDF. Supported by the native operator - */ void PDF_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, int width ) { wxASSERT( workFile ); @@ -232,9 +200,6 @@ void PDF_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, in } -/** - * Circle drawing for PDF. They're approximated by curves, but fill is supported - */ void PDF_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_TYPE aFill, int width ) { wxASSERT( workFile ); @@ -288,14 +253,11 @@ void PDF_PLOTTER::Circle( const wxPoint& pos, int diametre, FILL_TYPE aFill, int } -/** - * The PDF engine can't directly plot arcs, it uses the base emulation. - * So no filled arcs (not a great loss... ) - */ void PDF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius, FILL_TYPE fill, int width ) { wxASSERT( workFile ); + if( radius <= 0 ) { Circle( centre, width, FILL_TYPE::FILLED_SHAPE, 0 ); @@ -344,13 +306,11 @@ void PDF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i } -/** - * Polygon plotting for PDF. Everything is supported - */ void PDF_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_TYPE aFill, int aWidth, void * aData ) { wxASSERT( workFile ); + if( aCornerList.size() <= 1 ) return; @@ -373,6 +333,7 @@ void PDF_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, void PDF_PLOTTER::PenTo( const wxPoint& pos, char plume ) { wxASSERT( workFile ); + if( plume == 'Z' ) { if( penState != 'Z' ) @@ -382,6 +343,7 @@ void PDF_PLOTTER::PenTo( const wxPoint& pos, char plume ) penLastpos.x = -1; penLastpos.y = -1; } + return; } @@ -392,13 +354,12 @@ void PDF_PLOTTER::PenTo( const wxPoint& pos, char plume ) pos_dev.x, pos_dev.y, ( plume=='D' ) ? 'l' : 'm' ); } + penState = plume; penLastpos = pos; } -/** - * PDF images are handles as inline, not XObject streams... - */ + void PDF_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos, double aScaleFactor ) { @@ -468,7 +429,8 @@ void PDF_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos, if( aImage.HasMask() ) { - if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen() && b == aImage.GetMaskBlue() ) + if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen() + && b == aImage.GetMaskBlue() ) { r = 0xFF; g = 0xFF; @@ -496,11 +458,6 @@ void PDF_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos, } -/** - * Allocate a new handle in the table of the PDF object. The - * handle must be completed using startPdfObject. It's an in-RAM operation - * only, no output is done. - */ int PDF_PLOTTER::allocPdfObject() { xrefTable.push_back( 0 ); @@ -508,10 +465,6 @@ int PDF_PLOTTER::allocPdfObject() } -/** - * Open a new PDF object and returns the handle if the parameter is -1. - * Otherwise fill in the xref entry for the passed object - */ int PDF_PLOTTER::startPdfObject(int handle) { wxASSERT( outputFile ); @@ -526,9 +479,6 @@ int PDF_PLOTTER::startPdfObject(int handle) } -/** - * Close the current PDF object - */ void PDF_PLOTTER::closePdfObject() { wxASSERT( outputFile ); @@ -537,13 +487,7 @@ void PDF_PLOTTER::closePdfObject() } -/** - * Starts a PDF stream (for the page). Returns the object handle opened - * Pass -1 (default) for a fresh object. Especially from PDF 1.5 streams - * can contain a lot of things, but for the moment we only handle page - * content. - */ -int PDF_PLOTTER::startPdfStream(int handle) +int PDF_PLOTTER::startPdfStream( int handle ) { wxASSERT( outputFile ); wxASSERT( !workFile ); @@ -568,15 +512,12 @@ int PDF_PLOTTER::startPdfStream(int handle) // Open a temporary file to accumulate the stream workFilename = wxFileName::CreateTempFileName( "" ); - workFile = wxFopen( workFilename, wxT( "w+b" )); + workFile = wxFopen( workFilename, wxT( "w+b" ) ); wxASSERT( workFile ); return handle; } -/** - * Finish the current PDF stream (writes the deferred length, too) - */ void PDF_PLOTTER::closePdfStream() { wxASSERT( workFile ); @@ -625,9 +566,6 @@ void PDF_PLOTTER::closePdfStream() wxZlibOutputStream zos( memos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB ); zos.Write( inbuf, stream_len ); - - delete[] inbuf; - } // flush the zip stream using zos destructor wxStreamBuffer* sb = memos.GetOutputStreamBuffer(); @@ -636,6 +574,7 @@ void PDF_PLOTTER::closePdfStream() fwrite( sb->GetBufferStart(), 1, out_count, outputFile ); } + delete[] inbuf; fputs( "endstream\n", outputFile ); closePdfObject(); @@ -645,9 +584,7 @@ void PDF_PLOTTER::closePdfStream() closePdfObject(); } -/** - * Starts a new page in the PDF document - */ + void PDF_PLOTTER::StartPage() { wxASSERT( outputFile ); @@ -671,9 +608,7 @@ void PDF_PLOTTER::StartPage() userToDeviceSize( m_renderSettings->GetDefaultPenWidth() ) ); } -/** - * Close the current page in the PDF document (and emit its compressed stream) - */ + void PDF_PLOTTER::ClosePage() { wxASSERT( workFile ); @@ -714,11 +649,7 @@ void PDF_PLOTTER::ClosePage() pageStreamHandle = 0; } -/** - * The PDF engine supports multiple pages; the first one is opened - * 'for free' the following are to be closed and reopened. Between - * each page parameters can be set - */ + bool PDF_PLOTTER::StartPlot() { wxASSERT( outputFile ); @@ -791,11 +722,13 @@ bool PDF_PLOTTER::EndPlot() // Named font dictionary (was allocated, now we emit it) startPdfObject( fontResDictHandle ); fputs( "<<\n", outputFile ); + for( int i = 0; i < 4; i++ ) { fprintf( outputFile, " %s %d 0 R\n", fontdefs[i].rsname, fontdefs[i].font_handle ); } + fputs( ">>\n", outputFile ); closePdfObject(); @@ -826,7 +759,7 @@ bool PDF_PLOTTER::EndPlot() if( title.IsEmpty() ) { - // Windows uses '\' and other platforms ue '/' as sepatator + // Windows uses '\' and other platforms ue '/' as separator title = filename.AfterLast('\\'); title = title.AfterLast('/'); } @@ -865,6 +798,7 @@ bool PDF_PLOTTER::EndPlot() "xref\n" "0 %ld\n" "0000000000 65535 f \n", (long) xrefTable.size() ); + for( unsigned i = 1; i < xrefTable.size(); i++ ) { fprintf( outputFile, "%010ld 00000 n \n", xrefTable[i] ); @@ -885,6 +819,7 @@ bool PDF_PLOTTER::EndPlot() return true; } + void PDF_PLOTTER::Text( const wxPoint& aPos, const COLOR4D aColor, const wxString& aText, @@ -909,7 +844,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, const char *fontname = aItalic ? ( aBold ? "/KicadFontBI" : "/KicadFontI" ) : ( aBold ? "/KicadFontB" : "/KicadFont" ); - // Compute the copious transformation parameters of the Curent Transform Matrix + // Compute the copious transformation parameters of the Current Transform Matrix double ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f; double wideningFactor, heightFactor; diff --git a/common/plotters/plotters_pslike.h b/common/plotters/plotters_pslike.h index d7f769c9dc..12a24b6677 100644 --- a/common/plotters/plotters_pslike.h +++ b/common/plotters/plotters_pslike.h @@ -83,7 +83,8 @@ public: virtual void FlashRegularPolygon( const wxPoint& aShapePos, int aDiameter, int aCornerCount, double aOrient, OUTLINE_MODE aTraceMode, void* aData ) override; - /** The SetColor implementation is split with the subclasses: + /** + * The SetColor implementation is split with the subclasses: * The PSLIKE computes the rgb values, the subclass emits the * operator to actually do it */ @@ -191,6 +192,7 @@ protected: virtual void emitSetRGBColor( double r, double g, double b ) override; }; + class PDF_PLOTTER : public PSLIKE_PLOTTER { public: @@ -215,32 +217,77 @@ public: /** * Open or create the plot file aFullFilename - * @param aFullFilename = the full file name of the file to create - * @return true if success, false if the file cannot be created/opened * * The base class open the file in text mode, so we should have this * function overlaid for PDF files, which are binary files + * + * @param aFullFilename = the full file name of the file to create + * @return true if success, false if the file cannot be created/opened */ virtual bool OpenFile( const wxString& aFullFilename ) override; + /** + * The PDF engine supports multiple pages; the first one is opened + * 'for free' the following are to be closed and reopened. Between + * each page parameters can be set + */ virtual bool StartPlot() override; virtual bool EndPlot() override; + + /** + * Starts a new page in the PDF document + */ virtual void StartPage(); + + /** + * Close the current page in the PDF document (and emit its compressed stream) + */ virtual void ClosePage(); + + /** + * Pen width setting for PDF. + * + * Since the specs *explicitly* says that a 0 width is a bad thing to use (since it + * results in 1 pixel traces), we convert such requests to the minimal width (like 1) + * Note pen width = 0 is used in plot polygons to plot filled polygons with no outline + * thickness. Use in this case pen width = 1 does not actually change the polygon. + */ virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override; + + /** + * PDF supports dashed lines + */ virtual void SetDash( PLOT_DASH_TYPE dashed ) override; - /** PDF can have multiple pages, so SetPageSettings can be called - * with the outputFile open (but not inside a page stream!) */ + /** + * PDF can have multiple pages, so SetPageSettings can be called + * with the outputFile open (but not inside a page stream!) + */ virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, double aScale, bool aMirror ) override; + + /** + * Rectangles in PDF. Supported by the native operator + */ virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_TYPE fill, int width = USE_DEFAULT_LINE_WIDTH ) override; + + /** + * Circle drawing for PDF. They're approximated by curves, but fill is supported + */ virtual void Circle( const wxPoint& pos, int diametre, FILL_TYPE fill, int width = USE_DEFAULT_LINE_WIDTH ) override; + + /** + * The PDF engine can't directly plot arcs, it uses the base emulation. + * So no filled arcs (not a great loss... ) + */ virtual void Arc( const wxPoint& centre, double StAngle, double EndAngle, int rayon, FILL_TYPE fill, int width = USE_DEFAULT_LINE_WIDTH ) override; + /** + * Polygon plotting for PDF. Everything is supported + */ virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_TYPE aFill, int aWidth = USE_DEFAULT_LINE_WIDTH, void * aData = NULL ) override; @@ -259,7 +306,9 @@ public: bool aBold, bool aMultilineAllowed = false, void* aData = NULL ) override; - + /** + * PDF images are handles as inline, not XObject streams... + */ virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos, double aScaleFactor ) override; @@ -269,22 +318,59 @@ protected: /// string PDF format (convert special chars and non ascii7 chars) std::string encodeStringForPlotter( const wxString& aUnicode ) override; + /** + * PDF supports colors fully. It actually has distinct fill and pen colors, + * but we set both at the same time. + * + * XXX Keeping them divided could result in a minor optimization in + * Eeschema filled shapes, but would propagate to all the other plot + * engines. Also arcs are filled as pies but only the arc is stroked so + * it would be difficult to handle anyway. + */ virtual void emitSetRGBColor( double r, double g, double b ) override; + + /** + * Allocate a new handle in the table of the PDF object. The + * handle must be completed using startPdfObject. It's an in-RAM operation + * only, no output is done. + */ int allocPdfObject(); + + /** + * Open a new PDF object and returns the handle if the parameter is -1. + * Otherwise fill in the xref entry for the passed object + */ int startPdfObject(int handle = -1); + + /** + * Close the current PDF object + */ void closePdfObject(); + + /** + * Starts a PDF stream (for the page). Returns the object handle opened + * Pass -1 (default) for a fresh object. Especially from PDF 1.5 streams + * can contain a lot of things, but for the moment we only handle page + * content. + */ int startPdfStream(int handle = -1); + + /** + * Finish the current PDF stream (writes the deferred length, too) + */ void closePdfStream(); + int pageTreeHandle; /// Handle to the root of the page tree object int fontResDictHandle; /// Font resource dictionary std::vector pageHandles;/// Handles to the page objects int pageStreamHandle; /// Handle of the page content object int streamLengthHandle; /// Handle to the deferred stream length wxString workFilename; - FILE* workFile; /// Temporary file to costruct the stream before zipping + FILE* workFile; /// Temporary file to construct the stream before zipping std::vector xrefTable; /// The PDF xref offset table }; + class SVG_PLOTTER : public PSLIKE_PLOTTER { public: @@ -330,27 +416,27 @@ public: virtual void PenTo( const wxPoint& pos, char plume ) override; /** - * Function SetSvgCoordinatesFormat - * selection of SVG step size (number of digits needed for 1 mm or 1 inch ) + * Select SVG step size (number of digits needed for 1 mm or 1 inch ) + * + * Should be called only after SetViewport() is called + * * @param aResolution = number of digits in mantissa of coordinate * use a value from 3-6 * do not use value > 6 to avoid overflow in PCBNEW * do not use value > 4 to avoid overflow for other parts * @param aUseInches = true to use inches, false to use mm (default) - * - * Should be called only after SetViewport() is called */ virtual void SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches = false ) override; /** - * calling this function allows one to define the beginning of a group + * Calling this function allows one to define the beginning of a group * of drawing items (used in SVG format to separate components) - * @param aData should be a string for the SVG ID tage + * @param aData should be a string for the SVG ID tag */ virtual void StartBlock( void* aData ) override; /** - * calling this function allows one to define the end of a group of drawing + * Calling this function allows one to define the end of a group of drawing * items the group is started by StartBlock() * @param aData should be null */ @@ -370,36 +456,34 @@ public: void* aData = NULL ) override; protected: - FILL_TYPE m_fillMode; // true if the current contour + FILL_TYPE m_fillMode; // true if the current contour // rect, arc, circle, polygon must be filled - long m_pen_rgb_color; // current rgb color value: each color has + long m_pen_rgb_color; // current rgb color value: each color has // a value 0 ... 255, and the 3 colors are // grouped in a 3x8 bits value // (written in hex to svg files) long m_brush_rgb_color; // same as m_pen_rgb_color, used to fill // some contours. bool m_graphics_changed; // true if a pen/brush parameter is modified - // color, pen size, fil mode ... + // color, pen size, fill mode ... // the new SVG stype must be output on file PLOT_DASH_TYPE m_dashed; // plot line style bool m_useInch; // is 0 if the step size is 10**-n*mm // is 1 if the step size is 10**-n*inch // Where n is given from m_precision unsigned m_precision; // How fine the step size is - // Use 3-6 (3 means um precision, 6 nm precision) in pcbnew - // 3-4 in other moduls (avoid values >4 to avoid overflow) + // Use 3-6 (3 means um precision, 6 nm precision) in PcbNew + // 3-4 in other modules (avoid values >4 to avoid overflow) // see also comment for m_useInch. /** - * function emitSetRGBColor() - * initialize m_pen_rgb_color from reduced values r, g ,b + * Initialize m_pen_rgb_color from reduced values r, g ,b * ( reduced values are 0.0 to 1.0 ) */ virtual void emitSetRGBColor( double r, double g, double b ) override; /** - * function setSVGPlotStyle() - * output the string which define pen and brush color, shape, transparency + * Output the string which define pen and brush color, shape, transparency * * @param aIsGroup If false, do not form a new group for the style. * @param aExtraStyle If given, the string will be added into the style string before closing @@ -407,8 +491,7 @@ protected: void setSVGPlotStyle( bool aIsGroup = true, const std::string& aExtraStyle = {} ); /** - * function setFillMode() - * prepare parameters for setSVGPlotStyle() + * Prepare parameters for setSVGPlotStyle() */ void setFillMode( FILL_TYPE fill ); }; diff --git a/eeschema/dialogs/panel_setup_formatting.cpp b/eeschema/dialogs/panel_setup_formatting.cpp index c04c1c5109..352faba60b 100644 --- a/eeschema/dialogs/panel_setup_formatting.cpp +++ b/eeschema/dialogs/panel_setup_formatting.cpp @@ -37,7 +37,8 @@ PANEL_SETUP_FORMATTING::PANEL_SETUP_FORMATTING( wxWindow* aWindow, SCH_EDIT_FRAM m_frame( aFrame ), m_textSize( aFrame, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ), m_lineWidth( aFrame, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ), - m_pinSymbolSize( aFrame, m_pinSymbolSizeLabel, m_pinSymbolSizeCtrl, m_pinSymbolSizeUnits, true ) + m_pinSymbolSize( aFrame, m_pinSymbolSizeLabel, m_pinSymbolSizeCtrl, m_pinSymbolSizeUnits, + true ) { } @@ -110,7 +111,7 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() settings.m_DefaultTextSize = (int) m_textSize.GetValue(); settings.m_DefaultLineWidth = (int) m_lineWidth.GetValue(); settings.m_PinSymbolSize = (int) m_pinSymbolSize.GetValue(); - + // Get the current working size in case of problem with wxChoice widget results int currJunctionDotSize = settings.m_JunctionSize; // See if user has made a junction dot size selection @@ -121,6 +122,8 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() EESCHEMA_SETTINGS* projSettings = dynamic_cast( Kiface().KifaceSettings() ); + wxCHECK( projSettings, false ); + if( currDotSizeIndex ) { // Junction dots are scaled value of default line width @@ -139,6 +142,7 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() settings.m_JunctionSizeChoice = currDotSizeIndex; // Store to set pulldown next time } + settings.m_JunctionSize = currJunctionDotSize; settings.m_IntersheetsRefShow = m_showIntersheetsReferences->GetValue(); @@ -179,5 +183,3 @@ void PANEL_SETUP_FORMATTING::ImportSettingsFrom( SCHEMATIC_SETTINGS& aSettings ) wxString offsetRatio = wxString::Format( "%f", aSettings.m_TextOffsetRatio * 100.0 ); m_textOffsetRatioCtrl->SetValue( offsetRatio ); } - - diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index ca122e3649..96b3d54f5e 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -416,6 +416,8 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier // symbol library table. const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName ); + wxCHECK( row, false ); + SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri, row->GetType(), row->GetOptions(), diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index d1858e23a3..c6fe5edf3b 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -381,6 +381,7 @@ void SYMBOL_EDIT_FRAME::SaveOneSymbol() if( m_my_part->GetDrawItems().empty() ) return; + wxString msg; PROJECT& prj = Prj(); SEARCH_STACK* search = prj.SchSearchS(); @@ -406,8 +407,8 @@ void SYMBOL_EDIT_FRAME::SaveOneSymbol() prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() ); - if( fn.FileExists() ) - wxRemove( fn.GetFullPath() ); + if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) ) + return; SetStatusText( wxString::Format( _( "Saving symbol in \"%s\"" ), fn.GetPath() ) ); @@ -425,8 +426,7 @@ void SYMBOL_EDIT_FRAME::SaveOneSymbol() } catch( const IO_ERROR& ioe ) { - wxString msg = wxString::Format( _( "An error occurred saving symbol file \"%s\"" ), - fn.GetFullPath() ); + msg.Printf( _( "An error occurred saving symbol file \"%s\"" ), fn.GetFullPath() ); DisplayErrorMessage( this, msg, ioe.What() ); } } diff --git a/pcbnew/dialogs/dialog_select_net_from_list.cpp b/pcbnew/dialogs/dialog_select_net_from_list.cpp index c3528004f9..5d668cc20a 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list.cpp +++ b/pcbnew/dialogs/dialog_select_net_from_list.cpp @@ -960,11 +960,13 @@ DIALOG_SELECT_NET_FROM_LIST::DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParen #undef connect_event - // if the dialog is opened while something is highlighted on the board ... - OnBoardHighlightNetChanged( *m_brd ); - if( m_brd != nullptr ) + { + // if the dialog is opened while something is highlighted on the board ... + OnBoardHighlightNetChanged( *m_brd ); + m_brd->AddListener( this ); + } } @@ -1452,6 +1454,8 @@ std::unique_ptr DIALOG_SELECT_NET_FROM_L void DIALOG_SELECT_NET_FROM_LIST::buildNetsList() { + wxCHECK( m_brd, /* void */ ); + m_in_build_nets_list = true; // when rebuilding the netlist, try to keep the row selection diff --git a/qa/libs/kimath/geometry/test_shape_compound_collision.cpp b/qa/libs/kimath/geometry/test_shape_compound_collision.cpp index 99aa0c8575..16be5419d6 100644 --- a/qa/libs/kimath/geometry/test_shape_compound_collision.cpp +++ b/qa/libs/kimath/geometry/test_shape_compound_collision.cpp @@ -55,7 +55,7 @@ struct ShapeCompoundCollisionFixture shapesB.push_back( new SHAPE_CIRCLE( VECTOR2I( 0, 80 ), 100 ) ); shapesB.push_back( new SHAPE_CIRCLE( VECTOR2I( 80, 80 ), 100 ) ); - + shapesC.push_back( new SHAPE_CIRCLE( VECTOR2I( 0, 280 ), 100 ) ); shapesC.push_back( new SHAPE_CIRCLE( VECTOR2I( 80, 280 ), 100 ) ); @@ -66,14 +66,19 @@ struct ShapeCompoundCollisionFixture ~ShapeCompoundCollisionFixture() { + delete compoundA; + delete compoundB; + delete compoundC; } }; + /** * Declares the CollisionFixture as the boost test suite fixture. */ BOOST_FIXTURE_TEST_SUITE( SCompoundCollision, ShapeCompoundCollisionFixture ) + /** * This test checks basic behaviour of PointOnEdge, testing if points on corners, outline edges * and hole edges are detected as colliding. @@ -121,4 +126,5 @@ BOOST_AUTO_TEST_CASE( ShapeCompoundCollide ) BOOST_CHECK( actual == 80 ); } + BOOST_AUTO_TEST_SUITE_END()