diff --git a/3d-viewer/3d_aux.cpp b/3d-viewer/3d_aux.cpp index fb308391c2..26abe84a9f 100644 --- a/3d-viewer/3d_aux.cpp +++ b/3d-viewer/3d_aux.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * @@ -29,10 +29,6 @@ #include -#if !wxUSE_GLCANVAS -#error Please set wxUSE_GLCANVAS to 1 in setup.h. -#endif - #include #include #include @@ -49,7 +45,7 @@ #include -void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices ) +void S3D_MASTER::Set_Object_Coords( std::vector< S3D_VERTEX >& aVertices ) { unsigned ii; @@ -79,7 +75,7 @@ void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices ) } -void Set_Object_Data( std::vector< S3D_Vertex >& aVertices ) +void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices ) { unsigned ii; GLfloat ax, ay, az, bx, by, bz, nx, ny, nz, r; @@ -271,9 +267,9 @@ VERTEX_VALUE_CTRL::~VERTEX_VALUE_CTRL() } -S3D_Vertex VERTEX_VALUE_CTRL::GetValue() +S3D_VERTEX VERTEX_VALUE_CTRL::GetValue() { - S3D_Vertex value; + S3D_VERTEX value; double dtmp; m_XValueCtrl->GetValue().ToDouble( &dtmp ); @@ -286,7 +282,7 @@ S3D_Vertex VERTEX_VALUE_CTRL::GetValue() } -void VERTEX_VALUE_CTRL::SetValue( S3D_Vertex vertex ) +void VERTEX_VALUE_CTRL::SetValue( S3D_VERTEX vertex ) { wxString text; diff --git a/3d-viewer/3d_class.cpp b/3d-viewer/3d_class.cpp index 9fe268625c..f19e29f03b 100644 --- a/3d-viewer/3d_class.cpp +++ b/3d-viewer/3d_class.cpp @@ -1,6 +1,30 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: 3d_class.cpp -///////////////////////////////////////////////////////////////////////////// +/** + * @file 3d_class.cpp + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2012 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #include @@ -55,7 +79,7 @@ S3D_MASTER::S3D_MASTER( EDA_ITEM* aParent ) : S3D_MASTER:: ~S3D_MASTER() { - Struct3D_Shape* next; + STRUCT_3D_SHAPE* next; S3D_MATERIAL* nextmat; for( ; m_3D_Drawings != NULL; m_3D_Drawings = next ) @@ -72,7 +96,7 @@ S3D_MASTER:: ~S3D_MASTER() } -Struct3D_Shape::Struct3D_Shape( EDA_ITEM* aParent ) : +STRUCT_3D_SHAPE::STRUCT_3D_SHAPE( EDA_ITEM* aParent ) : EDA_ITEM( aParent, NOT_USED ) { m_3D_Coord = NULL; @@ -81,7 +105,7 @@ Struct3D_Shape::Struct3D_Shape( EDA_ITEM* aParent ) : } -Struct3D_Shape:: ~Struct3D_Shape() +STRUCT_3D_SHAPE:: ~STRUCT_3D_SHAPE() { delete m_3D_Coord; delete m_3D_CoordIndex; diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 3bad18fef1..4f0301e449 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +//include #include #include @@ -41,33 +41,89 @@ #include #include #include -#include +//#include #include #include <3d_viewer.h> #include #include +// angle increment to draw a circle, approximated by segments +#define ANGLE_INC(x) (3600/(x)) + extern void CheckGLError(); -static void Draw3D_FilledCircle( double posx, double posy, double radius, - double hole_radius, double zpos ); -static void Draw3D_FilledSegment( double startx, double starty, - double endx, double endy, - double width, double zpos ); -static void Draw3D_ZaxisCylinder( const S3D_Vertex& aPos, double aRadius, double aHeight ); +/* draw a segment using 3D primitives, in a XY plane + * aStartPos = 3D position of the starting point (3D units) + * aEndx, aEndy = 3D position of the ending point (3D units) + * aWidth = width of the segment (3D units) + */ +static void Draw3D_FilledSegment( const S3D_VERTEX& aStartPos, + double aEndx, double aEndy, double aWidth ); -static void Draw3D_FilledSegmentWithHole( double startx, double starty, +static void Draw3D_SegmentWithHole( double startx, double starty, double endx, double endy, double width, double holex, double holey, double holeradius, double zpos ); -static void Draw3D_ArcSegment( double startx, double starty, double centrex, - double centrey, double arc_angle, double width, double zpos ); -static void Draw3D_CircleSegment( double startx, double starty, double endx, - double endy, double width, double zpos ); -static int Get3DLayerEnable( int act_layer ); -static GLfloat Get3DLayerSide( int act_layer ); + +/* draw an arc using 3D primitives, in a plane parallel to the XY plane + * aCenterPos = 3D position of the center + * aStartPointX, aStartPointY = start point coordinate of arc (3D units) + * aWidth = width of the circle (3D units) + * aArcAngle = arc angle in 1/10 degrees + * aWidth = thickness of arc + */ +static void Draw3D_ArcSegment( const S3D_VERTEX& aCenterPos, + double aStartPointX, double aStartPointY, + double aArcAngle, double aWidth ); + +/* draw a circle with hole using 3D primitives, in a XY plane + * aCenterPos = 3D position of the center + * aRadius = radius of the circle (3D units) + * aHoleRadius = radius of the hole (3D units) + * Used to draw vias and round pads with round hole + */ +static void Draw3D_FilledCircleWithHole( const S3D_VERTEX& aPos, double aRadius, double aHoleRadius ); + +/* draw a circle using 3D primitives, in a plane parallel to the XY plane + * aCenterPos = 3D position of the center + * aRadius = radius of the circle (3D units) + * aWidth = width of the circle (3D units) + * Does the same think as Draw3D_FilledCircleWithHole, just does not use the same parmeters + * Used to draw circular segments + */ +static void Draw3D_ThickCircle( const S3D_VERTEX& aCenterPos, double aRadius, double aWidth ); + + /* returns true if aLayer should be displayed, false otherwise + */ +static bool Is3DLayerEnabled( int aLayer ); + + /* returns the Z orientation parmeter 1.0 or -1.0 for aLayer + * Z orientation is 1.0 for all layers but "back" layers: + * LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK + * used to calculate the Z orientation parmeter for glNormal3f + */ +static GLfloat Get3DLayer_Z_Orientation( int aLayer ); + +/* draw a cylinder using 3D primitives. + * the cylinder axis is parallel to the Z axis + * aCenterPos = 3D position of the axis cylinder + * aRadius = radius of the cylinder (3D units) + * aHeight = height of the cylinder (3D units) + */ +static void Draw3D_ZaxisCylinder( const S3D_VERTEX& aPos, double aRadius, double aHeight ); + +/* draw an oblong cylinder (oblong hole) using 3D primitives. + * the cylinder axis are parallel to the Z axis + * aCenterPos = 3D position of the first axis cylinder + * aEndx, aEndy = 3D position of the second axis cylinder + * aRadius = radius of the cylinder (3D units) + * aHeight = height of the cylinder (3D units) + */ +static void Draw3D_ZaxisOblongCylinder( const S3D_VERTEX& aCenterPos, + double aEndx, double aEndy, + double aRadius, double aHeight ); #ifndef CALLBACK @@ -138,9 +194,6 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() { PCB_BASE_FRAME* pcbframe = Parent()->Parent(); BOARD* pcb = pcbframe->GetBoard(); - TRACK* track; - SEGZONE* segzone; - int ii; wxBusyCursor dummy; @@ -171,19 +224,21 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() // Init Z position of each layer // calculate z position for each copper layer - for( ii = 0; ii < g_Parm_3D_Visu.m_CopperLayersCount; ii++ ) + int layer; + int copper_layers_cnt = g_Parm_3D_Visu.m_CopperLayersCount; + for( layer = 0; layer < copper_layers_cnt; layer++ ) { - g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_EpoxyThickness - * ii / (g_Parm_3D_Visu.m_CopperLayersCount - 1); + g_Parm_3D_Visu.m_LayerZcoord[layer] = + g_Parm_3D_Visu.m_EpoxyThickness * layer / (copper_layers_cnt - 1); } double zpos_copper_back = g_Parm_3D_Visu.m_LayerZcoord[0]; double zpos_copper_front = g_Parm_3D_Visu.m_EpoxyThickness; // Fill remaining unused copper layers and front layer zpos // with g_Parm_3D_Visu.m_EpoxyThickness - for( ; ii <= LAST_COPPER_LAYER; ii++ ) + for( ; layer <= LAST_COPPER_LAYER; layer++ ) { - g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_EpoxyThickness; + g_Parm_3D_Visu.m_LayerZcoord[layer] = g_Parm_3D_Visu.m_EpoxyThickness; } // calculate z position for each non copper layer @@ -275,112 +330,27 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis // draw tracks and vias : - for( track = pcb->m_Track; track != NULL; track = track->Next() ) + for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() ) { if( track->Type() == PCB_VIA_T ) Draw3D_Via( (SEGVIA*) track ); else - Draw3D_Track( track ); + { + int layer = track->GetLayer(); + + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) + Draw3D_Track( track ); + } } if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]) { - // Draw segments used to fill copper areas. outdated! - for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() ) + for( int ii = 0; ii < pcb->GetAreaCount(); ii++ ) { - if( segzone->Type() == PCB_ZONE_T ) - Draw3D_Track( segzone ); - } + int layer = pcb->GetArea( ii )->GetLayer(); - // Draw new segments - for( ii = 0; ii < pcb->GetAreaCount(); ii++ ) - { - ZONE_CONTAINER* curr_zone = pcb->GetArea( ii ); - - if( curr_zone->m_FillMode == 0 ) - { - // solid polygons only are used to fill areas - if( curr_zone->GetFilledPolysList().size() > 3 ) - { - Draw3D_SolidPolygonsInZones( curr_zone ); - } - } - else - { - // segments are used to fill areas - for( unsigned iseg = 0; iseg < curr_zone->m_FillSegmList.size(); iseg++ ) - { - SEGZONE dummysegment( pcb ); - dummysegment.SetLayer( curr_zone->GetLayer() ); - dummysegment.m_Width = curr_zone->m_ZoneMinThickness; - - dummysegment.m_Start.x = curr_zone->m_FillSegmList[iseg].m_Start.x; - dummysegment.m_Start.y = curr_zone->m_FillSegmList[iseg].m_Start.y; - dummysegment.m_End.x = curr_zone->m_FillSegmList[iseg].m_End.x; - dummysegment.m_End.y = curr_zone->m_FillSegmList[iseg].m_End.y; - Draw3D_Track( &dummysegment ); - } - } - } - - // Draw copper areas outlines - for( ii = 0; ii < pcb->GetAreaCount(); ii++ ) - { - ZONE_CONTAINER* zone = pcb->GetArea( ii ); - - std::vector polysList = zone->GetFilledPolysList(); - - if( polysList.size() == 0 ) - continue; - - if( zone->m_ZoneMinThickness <= 1 ) - continue; - - int imax = polysList.size() - 1; - CPolyPt* firstcorner = &polysList[0]; - CPolyPt* begincorner = firstcorner; - SEGZONE dummysegment( pcb ); - dummysegment.SetLayer( zone->GetLayer() ); - dummysegment.m_Width = zone->m_ZoneMinThickness; - - for( int ic = 1; ic <= imax; ic++ ) - { - CPolyPt* endcorner = &polysList[ic]; - - if( begincorner->m_utility == 0 ) - { - // Draw only basic outlines, not extra segments - dummysegment.m_Start.x = begincorner->x; - dummysegment.m_Start.y = begincorner->y; - dummysegment.m_End.x = endcorner->x; - dummysegment.m_End.y = endcorner->y; - Draw3D_Track( &dummysegment ); - } - - if( (endcorner->end_contour) || (ic == imax) ) - { - // the last corner of a filled area is found: draw it - if( endcorner->m_utility == 0 ) - { - // Draw only basic outlines, not extra segments - dummysegment.m_Start.x = endcorner->x; - dummysegment.m_Start.y = endcorner->y; - dummysegment.m_End.x = firstcorner->x; - dummysegment.m_End.y = firstcorner->y; - - Draw3D_Track( &dummysegment ); - } - - ic++; - - if( ic < imax - 1 ) - begincorner = firstcorner = &polysList[ic]; - } - else - { - begincorner = endcorner; - } - } + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ) + Draw3D_Zone( pcb->GetArea( ii ) ); } } @@ -392,11 +362,19 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() switch( PtStruct->Type() ) { case PCB_LINE_T: - Draw3D_DrawSegment( (DRAWSEGMENT*) PtStruct ); + { + DRAWSEGMENT* segment = (DRAWSEGMENT*) PtStruct; + if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( segment->GetLayer() ) ) + Draw3D_DrawSegment( segment ); + } break; case PCB_TEXT_T: - Draw3D_DrawText( (TEXTE_PCB*) PtStruct ); + { + TEXTE_PCB* text = (TEXTE_PCB*) PtStruct; + if( Is3DLayerEnabled( text->GetLayer() ) ) + Draw3D_DrawText( text ); + } break; default: @@ -422,6 +400,98 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List() return m_gllist; } +/* Draw a zone (solid copper areas in aZone) + */ +void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone ) +{ + int layer = aZone->GetLayer(); + int color = g_ColorsSettings.GetLayerColor( layer ); + + if( layer == LAST_COPPER_LAYER ) + layer = g_Parm_3D_Visu.m_CopperLayersCount - 1; + + double zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + double width = aZone->m_ZoneMinThickness * g_Parm_3D_Visu.m_BoardScale; + + SetGLColor( color ); + glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); + + if( aZone->m_FillMode == 0 ) + { + // solid polygons only are used to fill areas + if( aZone->GetFilledPolysList().size() > 3 ) + { + Draw3D_SolidPolygonsInZones( aZone ); + } + } + else + { + // segments are used to fill areas + for( unsigned iseg = 0; iseg < aZone->m_FillSegmList.size(); iseg++ ) + { + double ox = aZone->m_FillSegmList[iseg].m_Start.x * g_Parm_3D_Visu.m_BoardScale; + double oy = aZone->m_FillSegmList[iseg].m_Start.y * g_Parm_3D_Visu.m_BoardScale; + double fx = aZone->m_FillSegmList[iseg].m_End.x * g_Parm_3D_Visu.m_BoardScale; + double fy = aZone->m_FillSegmList[iseg].m_End.y * g_Parm_3D_Visu.m_BoardScale; + S3D_VERTEX pos( ox, -oy, zpos ); + Draw3D_FilledSegment( pos, fx, -fy, width ); + } + } + + // Draw copper area outlines + std::vector polysList = aZone->GetFilledPolysList(); + + if( polysList.size() == 0 ) + return; + + if( aZone->m_ZoneMinThickness <= 1 ) + return; + + int imax = polysList.size() - 1; + CPolyPt* firstcorner = &polysList[0]; + CPolyPt* begincorner = firstcorner; + + for( int ic = 1; ic <= imax; ic++ ) + { + CPolyPt* endcorner = &polysList[ic]; + + if( begincorner->m_utility == 0 ) + { + // Draw only basic outlines, not extra segments + double ox = begincorner->x * g_Parm_3D_Visu.m_BoardScale; + double oy = begincorner->y * g_Parm_3D_Visu.m_BoardScale; + double fx = endcorner->x * g_Parm_3D_Visu.m_BoardScale; + double fy = endcorner->y * g_Parm_3D_Visu.m_BoardScale; + S3D_VERTEX pos( ox, -oy, zpos ); + Draw3D_FilledSegment( pos, fx, -fy, width ); + } + + if( (endcorner->end_contour) || (ic == imax) ) + { + // the last corner of a filled area is found: draw it + if( endcorner->m_utility == 0 ) + { + // Draw only basic outlines, not extra segments + double ox = endcorner->x * g_Parm_3D_Visu.m_BoardScale; + double oy = endcorner->y * g_Parm_3D_Visu.m_BoardScale; + double fx = firstcorner->x * g_Parm_3D_Visu.m_BoardScale; + double fy = firstcorner->y * g_Parm_3D_Visu.m_BoardScale; + S3D_VERTEX pos( ox, -oy, zpos ); + Draw3D_FilledSegment( pos, fx, -fy, width ); + } + + ic++; + + if( ic < imax - 1 ) + begincorner = firstcorner = &polysList[ic]; + } + else + { + begincorner = endcorner; + } + } +} + // draw mm grid.. void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) @@ -554,13 +624,9 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM ) } -void EDA_3D_CANVAS::Draw3D_Track( TRACK* track ) +void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack ) { - int layer = track->GetLayer(); - - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) - return; - + int layer = aTrack->GetLayer(); int color = g_ColorsSettings.GetLayerColor( layer ); if( layer == LAST_COPPER_LAYER ) @@ -571,12 +637,14 @@ void EDA_3D_CANVAS::Draw3D_Track( TRACK* track ) SetGLColor( color ); glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); - double w = track->m_Width * g_Parm_3D_Visu.m_BoardScale; - double ox = track->m_Start.x * g_Parm_3D_Visu.m_BoardScale; - double oy = track->m_Start.y * g_Parm_3D_Visu.m_BoardScale; - double fx = track->m_End.x * g_Parm_3D_Visu.m_BoardScale; - double fy = track->m_End.y * g_Parm_3D_Visu.m_BoardScale; - Draw3D_FilledSegment( ox, -oy, fx, -fy, w, zpos ); + double w = aTrack->m_Width * g_Parm_3D_Visu.m_BoardScale; + double ox = aTrack->m_Start.x * g_Parm_3D_Visu.m_BoardScale; + double oy = aTrack->m_Start.y * g_Parm_3D_Visu.m_BoardScale; + double fx = aTrack->m_End.x * g_Parm_3D_Visu.m_BoardScale; + double fy = aTrack->m_End.y * g_Parm_3D_Visu.m_BoardScale; + + S3D_VERTEX pos( ox, -oy, zpos ); + Draw3D_FilledSegment( pos, fx, -fy, w ); } @@ -585,9 +653,6 @@ void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) double zpos; int layer = aZone->GetLayer(); - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) - return; - int color = g_ColorsSettings.GetLayerColor( layer ); if( layer == LAST_COPPER_LAYER ) @@ -596,7 +661,6 @@ void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ) zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; g_Parm_3D_Visu.m_ActZpos = zpos; - SetGLColor( color ); glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); @@ -677,7 +741,6 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via ) SetGLColor( color ); - // SetGLColor( LIGHTGRAY ); glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); if( layer == LAYER_N_BACK ) @@ -685,7 +748,8 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via ) else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; - Draw3D_FilledCircle( x, -y, r, hole, zpos ); + S3D_VERTEX pos( x, -y, zpos); + Draw3D_FilledCircleWithHole( pos, r, hole ); if( layer >= top_layer ) break; @@ -695,75 +759,84 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via ) color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->m_Shape ); SetGLColor( color ); height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer]; - S3D_Vertex position( x, -y, g_Parm_3D_Visu.m_LayerZcoord[bottom_layer] ); + S3D_VERTEX position( x, -y, g_Parm_3D_Visu.m_LayerZcoord[bottom_layer] ); Draw3D_ZaxisCylinder( position, hole, height ); } void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment ) { - double x, y, xf, yf; - double zpos, w; - int layer = segment->GetLayer(); - - if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false ) - return; - int color = g_ColorsSettings.GetLayerColor( layer ); SetGLColor( color ); - w = segment->GetWidth() * g_Parm_3D_Visu.m_BoardScale; - - x = segment->GetStart().x * g_Parm_3D_Visu.m_BoardScale; - y = segment->GetStart().y * g_Parm_3D_Visu.m_BoardScale; - - xf = segment->GetEnd().x * g_Parm_3D_Visu.m_BoardScale; - yf = segment->GetEnd().y * g_Parm_3D_Visu.m_BoardScale; + double w = segment->GetWidth() * g_Parm_3D_Visu.m_BoardScale; + double x = segment->GetStart().x * g_Parm_3D_Visu.m_BoardScale; + double y = segment->GetStart().y * g_Parm_3D_Visu.m_BoardScale; + double xf = segment->GetEnd().x * g_Parm_3D_Visu.m_BoardScale; + double yf = segment->GetEnd().y * g_Parm_3D_Visu.m_BoardScale; if( layer == EDGE_N ) { for( layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ ) { glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 ); - zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + double zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; switch( segment->GetShape() ) { case S_ARC: - Draw3D_ArcSegment( x, -y, xf, -yf, segment->GetAngle(), w, zpos ); + { + S3D_VERTEX pos( xf, -yf, zpos ); + Draw3D_ArcSegment( pos, x, -y, segment->GetAngle(), w ); + } break; case S_CIRCLE: - Draw3D_CircleSegment( x, -y, xf, -yf, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_ThickCircle( pos, hypot( x - xf, y - yf ), w ); + } break; default: - Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_FilledSegment( pos, xf, -yf, w ); + } break; } } } else { - glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) ); - zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; + glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); + double zpos = g_Parm_3D_Visu.m_LayerZcoord[layer]; - if( Get3DLayerEnable( layer ) ) + if( Is3DLayerEnabled( layer ) ) { switch( segment->GetShape() ) { case S_ARC: - Draw3D_ArcSegment( x, -y, xf, -yf, segment->GetAngle(), w, zpos ); + { + S3D_VERTEX pos( xf, -yf, zpos ); + Draw3D_ArcSegment( pos, x, -y, segment->GetAngle(), w ); + } break; case S_CIRCLE: - Draw3D_CircleSegment( x, -y, xf, -yf, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_ThickCircle( pos, hypot( x - xf, y - yf ), w ); + } break; default: - Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_FilledSegment( pos , xf, -yf, w ); + } break; } } @@ -771,7 +844,12 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment ) } +// These variables are used in Draw3dTextSegm. +// But Draw3dTextSegm is a call back function, so we cannot send them as arguments, +// so they are static. static double s_Text3DWidth, s_Text3DZPos; + +// This is a call back function, used by DrawGraphicText to draw the 3D text shape: static void Draw3dTextSegm( int x0, int y0, int xf, int yf ) { double startx = x0 * g_Parm_3D_Visu.m_BoardScale; @@ -779,23 +857,20 @@ static void Draw3dTextSegm( int x0, int y0, int xf, int yf ) double endx = xf * g_Parm_3D_Visu.m_BoardScale; double endy = yf * g_Parm_3D_Visu.m_BoardScale; - Draw3D_FilledSegment( startx, -starty, endx, -endy, s_Text3DWidth, s_Text3DZPos ); + S3D_VERTEX pos( startx, -starty, s_Text3DZPos ); + Draw3D_FilledSegment( pos, endx, -endy, s_Text3DWidth ); } void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text ) { int layer = text->GetLayer(); - - if( !Get3DLayerEnable( layer ) ) - return; - int color = g_ColorsSettings.GetLayerColor( layer ); SetGLColor( color ); s_Text3DZPos = g_Parm_3D_Visu.m_LayerZcoord[layer]; s_Text3DWidth = text->GetThickness() * g_Parm_3D_Visu.m_BoardScale; - glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) ); + glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); wxSize size = text->m_Size; if( text->m_Mirror ) @@ -946,15 +1021,24 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) switch( m_Shape ) { case S_SEGMENT: - Draw3D_FilledSegment( x, -y, fx, -fy, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_FilledSegment( pos, fx, -fy, w ); + } break; case S_CIRCLE: - Draw3D_CircleSegment( x, -y, fx, -fy, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_ThickCircle( pos, hypot( x - fx, y - fy ), w); + } break; case S_ARC: - Draw3D_ArcSegment( x, -y, fx, -fy, (double) m_Angle, w, zpos ); + { + S3D_VERTEX pos( fx, -fy, zpos ); + Draw3D_ArcSegment( pos, x, -y, (double) m_Angle, w ); + } break; case S_POLYGON: @@ -994,15 +1078,24 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) switch( m_Shape ) { case S_SEGMENT: - Draw3D_FilledSegment( x, -y, fx, -fy, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_FilledSegment( pos, fx, -fy, w ); + } break; case S_CIRCLE: - Draw3D_CircleSegment( x, -y, fx, -fy, w, zpos ); + { + S3D_VERTEX pos( x, -y, zpos ); + Draw3D_ThickCircle( pos, hypot( x - fx, y - fy ), w ); + } break; case S_ARC: - Draw3D_ArcSegment( x, -y, fx, -fy, (double) m_Angle, w, zpos ); + { + S3D_VERTEX pos( fx, -fy, zpos ); + Draw3D_ArcSegment( pos, x, -y, (double) m_Angle, w ); + } break; case S_POLYGON: @@ -1045,21 +1138,18 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) delta_cx, delta_cy, xc, yc; int angle; - double scale; double zpos; - wxPoint shape_pos; - double x, y, r, w, hole, holeX, holeY; - double drillx, drilly; + double x, y, r, w; bool Oncu, Oncmp, Both; int color; - scale = g_Parm_3D_Visu.m_BoardScale; - holeX = (double) m_Drill.x * scale / 2; - holeY = (double) m_Drill.y * scale / 2; - hole = fmin( holeX, holeY ); + double scale = g_Parm_3D_Visu.m_BoardScale; + double holeX = (double) m_Drill.x * scale / 2; + double holeY = (double) m_Drill.y * scale / 2; + double hole = fmin( holeX, holeY ); // Calculate the center of the pad. - shape_pos = ReturnShapePos(); + wxPoint shape_pos = ReturnShapePos(); ux0 = shape_pos.x; uy0 = shape_pos.y; xc = ux0; @@ -1069,17 +1159,48 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) dy = dy0 = m_Size.y >> 1; angle = m_Orient; - drillx = m_Pos.x * scale; - drilly = m_Pos.y * scale; + double drillx = m_Pos.x * scale; + double drilly = m_Pos.y * scale; + double height = g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_FRONT] - + g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_BACK]; - // Draw the pad hole (TODO: draw OBLONG hole) + // Draw the pad hole if( holeX && holeY ) { SetGLColor( DARKGRAY ); - S3D_Vertex position( drillx, -drilly, g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_BACK] ); - double height = g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_FRONT] - - g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_BACK]; - Draw3D_ZaxisCylinder( position, hole, height ); + S3D_VERTEX position( drillx, -drilly, g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_BACK] ); + + if( holeX == holeY ) // usual round hole + Draw3D_ZaxisCylinder( position, hole, height ); + else // Oval hole + { + double ldx, ldy; + + if( holeX > holeY ) // Horizontal oval + { + ldx = holeX - holeY; + ldy = 0; + w = m_Size.y * scale; + } + else // Vertical oval + { + ldx = 0; + ldy = holeY - holeX; + w = m_Size.x * scale; + } + + RotatePoint( &ldx, &ldy, angle ); + + { + double ox = ux0 * scale + ldx; + double oy = uy0 * scale + ldy; + double fx = ux0 * scale - ldx; + double fy = uy0 * scale - ldy; + + S3D_VERTEX position( ox, -oy, g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_BACK] ); + Draw3D_ZaxisOblongCylinder( position, fx, -fy, hole, height ); + } + } } glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis @@ -1123,7 +1244,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; - Draw3D_FilledCircle( x, -y, r, hole, zpos ); + S3D_VERTEX position( x, -y, zpos ); + Draw3D_FilledCircleWithHole( position, r, hole ); } break; @@ -1179,7 +1301,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) else zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale; - Draw3D_FilledSegmentWithHole( ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos ); + Draw3D_SegmentWithHole( ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos ); } } @@ -1282,34 +1404,33 @@ void SetGLColor( int color ) } -static void Draw3D_FilledCircle( double posx, double posy, - double radius, double hole, double zpos ) +void Draw3D_FilledCircleWithHole( const S3D_VERTEX& aPos, double radius, double hole_radius ) { const int slice = 16; - const int rot_angle = 3600/16; + const int rot_angle = ANGLE_INC(slice); glBegin( GL_QUAD_STRIP ); for( int ii = 0; ii <= slice; ii++ ) { - double x = hole; + double x = hole_radius; double y = 0.0; RotatePoint( &x, &y, ii * rot_angle ); - glVertex3f( x + posx, y + posy, zpos ); + glVertex3f( x + aPos.x, y + aPos.y, aPos.z ); x = radius; y = 0.0; RotatePoint( &x, &y, ii * rot_angle ); - glVertex3f( x + posx, y + posy, zpos ); + glVertex3f( x + aPos.x, y + aPos.y, aPos.z ); } glEnd(); } -static void Draw3D_ZaxisCylinder( const S3D_Vertex& aPos, double aRadius, double aHeight ) +static void Draw3D_ZaxisCylinder( const S3D_VERTEX& aPos, double aRadius, double aHeight ) { const int slice = 12; - std::vector< S3D_Vertex > coords; + std::vector< S3D_VERTEX > coords; coords.resize( 4 ); double tmp = DataScale3D; @@ -1324,7 +1445,7 @@ static void Draw3D_ZaxisCylinder( const S3D_Vertex& aPos, double aRadius, double { double x = aRadius; double y = 0.0; - RotatePoint( &x, &y, ii * (3600 / slice) ); + RotatePoint( &x, &y, ii * ANGLE_INC(slice) ); coords[2].x = coords[3].x = aPos.x + x; coords[2].y = coords[3].y = aPos.y + y; Set_Object_Data( coords ); @@ -1340,20 +1461,20 @@ static void Draw3D_ZaxisCylinder( const S3D_Vertex& aPos, double aRadius, double // Draw a polygon similar to a segment has rounded tips -static void Draw3D_FilledSegment( double startx, double starty, double endx, - double endy, double width, double zpos ) +static void Draw3D_FilledSegment( const S3D_VERTEX& aStartPos, + double aEndx, double aEndy, double aWidth ) { double dx, dy, x, y, firstx = 0, firsty = 0; int ii, angle; // Calculate the coordinates of the segment assumed horizontal. // Then turn the strips of the desired angle. - dx = endx - startx; - dy = endy - starty; + dx = aEndx - aStartPos.x; + dy = aEndy - aStartPos.y; angle = (int) ( ( atan2( dy, dx ) * 1800 / M_PI ) + 0.5 ); RotatePoint( &dx, &dy, angle ); - width /= 2; + aWidth /= 2; glBegin( GL_POLYGON ); @@ -1362,37 +1483,37 @@ static void Draw3D_FilledSegment( double startx, double starty, double endx, for( ii = 0; ii <= slice/2; ii++ ) { x = 0.0; - y = -width; - RotatePoint( &x, &y, -ii * 3600/slice ); + y = -aWidth; + RotatePoint( &x, &y, -ii * ANGLE_INC(slice) ); x += dx; RotatePoint( &x, &y, -angle ); - glVertex3f( startx + x, starty + y, zpos ); + glVertex3f( aStartPos.x + x, aStartPos.y + y, aStartPos.z ); if( ii == 0 ) { - firstx = startx + x; - firsty = starty + y; + firstx = aStartPos.x + x; + firsty = aStartPos.y + y; } } // Rounding the left (2nd half polygon is the origin of the segment) for( ii = 0; ii <= slice/2; ii++ ) { - int jj = ii * 3600/slice; + int jj = ii * ANGLE_INC(slice); x = 0.0; - y = width; + y = aWidth; RotatePoint( &x, &y, -angle - jj ); - glVertex3f( startx + x, starty + y, zpos ); + glVertex3f( aStartPos.x + x, aStartPos.y + y, aStartPos.z ); } - glVertex3f( firstx, firsty, zpos ); + glVertex3f( firstx, firsty, aStartPos.z ); glEnd(); } /* Draw a polygon similar to a segment ends with round hole */ -static void Draw3D_FilledSegmentWithHole( double startx, double starty, +static void Draw3D_SegmentWithHole( double startx, double starty, double endx, double endy, double width, double holex, double holey, double holeradius, @@ -1467,18 +1588,20 @@ static void Draw3D_FilledSegmentWithHole( double startx, double starty, } -static void Draw3D_ArcSegment( double startx, double starty, double centrex, - double centrey, double arc_angle, double width, double zpos ) +static void Draw3D_ArcSegment( const S3D_VERTEX& aCenterPos, + double aStartPointX, double aStartPointY, + double aArcAngle, double aWidth ) { - const int slice = 36; // Number of segments to approximate a circle by segments + const int slice = 16; // Number of segments to approximate a circle by segments double arcStart_Angle; - arcStart_Angle = (atan2( startx - centrex, starty - centrey ) * 1800 / M_PI ); - double radius = hypot( startx - centrex, starty - centrey ) + ( width / 2); - double hole = radius - width; + arcStart_Angle = (atan2( aStartPointX - aCenterPos.x, aStartPointY - aCenterPos.y ) * 1800 / M_PI ); + double radius = hypot( aStartPointX - aCenterPos.x, aStartPointY - aCenterPos.y ) + + ( aWidth / 2); + double hole = radius - aWidth; // Calculate the number of segments to approximate this arc - int imax = (int) ( (double) arc_angle * slice / 3600.0 ); + int imax = (int) ( (double) aArcAngle / ANGLE_INC(slice) ); if( imax < 0 ) imax = -imax; @@ -1488,7 +1611,7 @@ static void Draw3D_ArcSegment( double startx, double starty, double centrex, // Adjust delta_angle to have exactly imax segments in arc_angle // i.e. arc_angle = imax delta_agnle. - double delta_angle = (double) arc_angle / imax; + double delta_angle = (double) aArcAngle / imax; glBegin( GL_QUAD_STRIP ); @@ -1499,39 +1622,100 @@ static void Draw3D_ArcSegment( double startx, double starty, double centrex, double dx = hole; double dy = 0.0; RotatePoint( &dx, &dy, (int) angle ); - glVertex3f( dx + startx, dy + starty, zpos ); + glVertex3f( dx + aStartPointX, dy + aStartPointY, aCenterPos.z ); dx = radius; dy = 0.0; RotatePoint( &dx, &dy, (int) angle ); - glVertex3f( dx + startx, dy + starty, zpos ); + glVertex3f( dx + aStartPointX, dy + aStartPointY, aCenterPos.z ); } glEnd(); } -static void Draw3D_CircleSegment( double startx, double starty, double endx, - double endy, double width, double zpos ) +static void Draw3D_ThickCircle( const S3D_VERTEX& aCenterPos, double aRadius, double aWidth ) { - const int slice = 36; - double x, y, hole, radius; + double outer_radius = aRadius + ( aWidth / 2); + double inner_radius = outer_radius - aWidth; - radius = hypot( startx - endx, starty - endy ) + ( width / 2); - hole = radius - width; + Draw3D_FilledCircleWithHole( aCenterPos, outer_radius, inner_radius ); +} - glBegin( GL_QUAD_STRIP ); +/* + * Function Draw3D_ZaxisOblongCylinder: + * draw a segment with an oblong hole. + * Used to draw oblong holes + */ +void Draw3D_ZaxisOblongCylinder( const S3D_VERTEX& aCenterPos, + double aEndx, double aEndy, + double aRadius, double aHeight ) +{ + const int slice = 16; + std::vector coords; - for( int ii = 0; ii <= slice; ii++ ) + coords.resize( 4 ); + + double tmp = DataScale3D; + + DataScale3D = 1.0; // Coordinate is already in range for Set_Object_Data(); + + double dx = aEndx - aCenterPos.x; + double dy = aEndy - aCenterPos.y; + double angle = atan2( dy, dx ) * 1800 / M_PI; + dx = 0; + dy = aRadius; + + // draws the first rectangle between half cylinders + RotatePoint( &dx, &dy, angle ); + coords[0].x = coords[1].x = aCenterPos.x + dx; + coords[0].y = coords[1].y = aCenterPos.y - dy; + coords[2].x = coords[3].x = aEndx + dx; + coords[2].y = coords[3].y = aEndy - dy; + coords[0].z = coords[3].z = aCenterPos.z; + coords[1].z = coords[2].z = aCenterPos.z + aHeight; + Set_Object_Data( coords ); + + // Draw the first half cylinder + for( int ii = 1; ii <= slice/2; ii++ ) { - x = hole; y = 0.0; - RotatePoint( &x, &y, ii * 3600 / slice ); - glVertex3f( x + startx, y + starty, zpos ); - x = radius; y = 0.0; - RotatePoint( &x, &y, ii * 3600 / slice ); - glVertex3f( x + startx, y + starty, zpos ); + double ddx = dx; + double ddy = -dy; + RotatePoint( &ddx, &ddy, -ii * ANGLE_INC(slice) ); + coords[0].x = coords[2].x; + coords[0].y = coords[2].y; + coords[1].x = coords[3].x; + coords[1].y = coords[3].y; + coords[2].x = coords[3].x = aEndx + ddx; + coords[2].y = coords[3].y = aEndy + ddy; + Set_Object_Data( coords ); } - glEnd(); + // draws the second rectangle between half cylinders + coords[0].x = coords[1].x = aEndx - dx; + coords[0].y = coords[1].y = aEndy + dy; + coords[2].x = coords[3].x = aCenterPos.x - dx; + coords[2].y = coords[3].y = aCenterPos.y + dy; + coords[0].z = coords[3].z = aCenterPos.z; + coords[1].z = coords[2].z = aCenterPos.z + aHeight; + Set_Object_Data( coords ); + + // Draw the second half cylinder + for( int ii = 1; ii <= slice/2; ii++ ) + { + double ddx = -dx; + double ddy = dy; + RotatePoint( &ddx, &ddy, -ii * ANGLE_INC(slice) ); + coords[0].x = coords[2].x; + coords[0].y = coords[2].y; + coords[1].x = coords[3].x; + coords[1].y = coords[3].y; + coords[2].x = coords[3].x = aCenterPos.x + ddx; + coords[2].y = coords[3].y = aCenterPos.y + ddy; + Set_Object_Data( coords ); + } + + glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis + DataScale3D = tmp; } @@ -1571,50 +1755,51 @@ void EDA_3D_CANVAS::Draw3D_Polygon( std::vector& aCornersList, double a } -static int Get3DLayerEnable( int act_layer ) +bool Is3DLayerEnabled( int aLayer ) { - int i = -1; + int flg = -1; // see if layer needs to be shown // check the flags - switch (act_layer) + switch (aLayer) { case DRAW_N: - i=g_Parm_3D_Visu.FL_DRAWINGS; + flg=g_Parm_3D_Visu.FL_DRAWINGS; break; case COMMENT_N: - i=g_Parm_3D_Visu.FL_COMMENTS; + flg=g_Parm_3D_Visu.FL_COMMENTS; break; case ECO1_N: - i=g_Parm_3D_Visu.FL_ECO1; + flg=g_Parm_3D_Visu.FL_ECO1; break; case ECO2_N: - i=g_Parm_3D_Visu.FL_ECO2; + flg=g_Parm_3D_Visu.FL_ECO2; break; } // the layer was not a layer with a flag, so show it - if (i < 0) + if( flg < 0 ) return true; // if the layer has a flag, return the flag - return g_Parm_3D_Visu.m_DrawFlags[i]; + return g_Parm_3D_Visu.m_DrawFlags[flg]; } -static GLfloat Get3DLayerSide( int act_layer ) +GLfloat Get3DLayer_Z_Orientation( int aLayer ) { - GLfloat nZ; + double nZ; nZ = 1.0; - if( ( act_layer <= LAST_COPPER_LAYER - 1 ) - || ( act_layer == ADHESIVE_N_BACK ) - || ( act_layer == SOLDERPASTE_N_BACK ) - || ( act_layer == SILKSCREEN_N_BACK ) - || ( act_layer == SOLDERMASK_N_BACK ) ) + if( ( aLayer == LAYER_N_BACK ) + || ( aLayer == ADHESIVE_N_BACK ) + || ( aLayer == SOLDERPASTE_N_BACK ) + || ( aLayer == SILKSCREEN_N_BACK ) + || ( aLayer == SOLDERMASK_N_BACK ) ) nZ = -1.0; + return nZ; } diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index d2316bed2f..21be897582 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -431,7 +431,7 @@ void EDA_3D_FRAME::OnActivate( wxActivateEvent& event ) */ void EDA_3D_FRAME::Set3DBgColor() { - S3D_Color color; + S3D_COLOR color; wxColour newcolor, oldcolor; oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ), diff --git a/3d-viewer/3d_read_mesh.cpp b/3d-viewer/3d_read_mesh.cpp index 6740234b4a..3a07a4d083 100644 --- a/3d-viewer/3d_read_mesh.cpp +++ b/3d-viewer/3d_read_mesh.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * @@ -35,6 +35,8 @@ #include <3d_viewer.h> +// separator chars +static const char* sep_chars = " \t\n\r"; int S3D_MASTER::ReadData() { @@ -85,13 +87,13 @@ int S3D_MASTER::ReadData() while( GetLine( file, line, &LineNum, 512 ) ) { - text = strtok( line, " \t\n\r" ); + text = strtok( line, sep_chars ); if( stricmp( text, "DEF" ) == 0 ) { while( GetLine( file, line, &LineNum, 512 ) ) { - text = strtok( line, " \t\n\r" ); + text = strtok( line, sep_chars ); if( text == NULL ) continue; @@ -119,8 +121,8 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum ) wxString mat_name; S3D_MATERIAL* material = NULL; - command = strtok( NULL, " \t\n\r" ); - text = strtok( NULL, " \t\n\r" ); + command = strtok( NULL, sep_chars ); + text = strtok( NULL, sep_chars ); mat_name = FROM_UTF8( text ); if( stricmp( command, "USE" ) == 0 ) @@ -134,7 +136,7 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum ) } } - printf( "ReadMaterial error: material not found\n" ); + D( printf( "ReadMaterial error: material not found\n" ) ); return 0; } @@ -146,7 +148,7 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { - text = strtok( line, " \t\n\r" ); + text = strtok( line, sep_chars ); if( text == NULL ) continue; @@ -159,44 +161,44 @@ int S3D_MASTER::ReadMaterial( FILE* file, int* LineNum ) if( stricmp( text, "diffuseColor" ) == 0 ) { - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_DiffuseColor.x = atof( text ); - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_DiffuseColor.y = atof( text ); - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_DiffuseColor.z = atof( text ); } else if( stricmp( text, "emissiveColor" ) == 0 ) { - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_EmissiveColor.x = atof( text ); - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_EmissiveColor.y = atof( text ); - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_EmissiveColor.z = atof( text ); } else if( strnicmp( text, "specularColor", 13 ) == 0 ) { - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_SpecularColor.x = atof( text ); - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_SpecularColor.y = atof( text ); - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_SpecularColor.z = atof( text ); } else if( strnicmp( text, "ambientIntensity", 16 ) == 0 ) { - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_AmbientIntensity = atof( text ); } else if( strnicmp( text, "transparency", 12 ) == 0 ) { - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_Transparency = atof( text ); } else if( strnicmp( text, "shininess", 9 ) == 0 ) { - text = strtok( NULL, " \t\n\r" ); + text = strtok( NULL, sep_chars ); material->m_Shininess = atof( text ); } } @@ -212,7 +214,7 @@ int S3D_MASTER::ReadChildren( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { - text = strtok( line, " \t\n\r" ); + text = strtok( line, sep_chars ); if( *text == ']' ) return 0; @@ -226,7 +228,7 @@ int S3D_MASTER::ReadChildren( FILE* file, int* LineNum ) } else { - printf( "ReadChildren error line %d <%s> \n", *LineNum, text ); + D( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) ); break; } } @@ -242,7 +244,7 @@ int S3D_MASTER::ReadShape( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { - text = strtok( line, " \t\n\r" ); + text = strtok( line, sep_chars ); if( *text == '}' ) { @@ -260,7 +262,7 @@ int S3D_MASTER::ReadShape( FILE* file, int* LineNum ) } else { - printf( "ReadShape error line %d <%s> \n", *LineNum, text ); + D( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) ); break; } } @@ -276,7 +278,7 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { - text = strtok( line, " \t\n\r" ); + text = strtok( line, sep_chars ); if( *text == '}' ) { @@ -289,7 +291,7 @@ int S3D_MASTER::ReadAppearance( FILE* file, int* LineNum ) } else { - printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ); + D( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) ); break; } } @@ -402,7 +404,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) while( GetLine( file, line, LineNum, 512 ) ) { strcpy( buffer, line ); - text = strtok( buffer, " \t\n\r" ); + text = strtok( buffer, sep_chars ); if( *text == '}' ) { @@ -507,7 +509,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) } std::vector< int > coordIndex; - std::vector< S3D_Vertex > vertices; + std::vector< S3D_VERTEX > vertices; while( GetLine( file, line, LineNum, 512 ) ) { @@ -535,7 +537,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) break; } - S3D_Vertex vertex; + S3D_VERTEX vertex; vertex.x = points[kk]; vertex.y = points[kk + 1]; vertex.z = points[kk + 2]; @@ -572,7 +574,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) } -int Struct3D_Shape::ReadData( FILE* file, int* LineNum ) +int STRUCT_3D_SHAPE::ReadData( FILE* file, int* LineNum ) { char line[512]; diff --git a/3d-viewer/3d_struct.h b/3d-viewer/3d_struct.h index b5ec529201..26e6738339 100644 --- a/3d-viewer/3d_struct.h +++ b/3d-viewer/3d_struct.h @@ -41,32 +41,21 @@ class S3D_MASTER; -class Struct3D_Shape; +class STRUCT_3D_SHAPE; -class S3D_Color /* 3D color (R, G, G) 3 floats range 0 to 1.0*/ -{ -public: - double m_Red, m_Green, m_Blue; - -public: S3D_Color() - { - m_Red = m_Green = m_Blue = 0; - } -}; - -/* S3D_Vertex manage a 3D coordinate (3 float numbers: x,y,z coordinates)*/ -class S3D_Vertex +/* S3D_VERTEX manages a 3D coordinate (3 float numbers: x,y,z coordinates)*/ +class S3D_VERTEX { public: double x, y, z; public: - S3D_Vertex() + S3D_VERTEX() { x = y = z = 0.0; } - S3D_Vertex( double px, double py, double pz) + S3D_VERTEX( double px, double py, double pz) { x = px; y = py; @@ -78,9 +67,9 @@ class S3D_MATERIAL : public EDA_ITEM /* openGL "material" data*/ { public: wxString m_Name; - S3D_Vertex m_DiffuseColor; - S3D_Vertex m_EmissiveColor; - S3D_Vertex m_SpecularColor; + S3D_VERTEX m_DiffuseColor; + S3D_VERTEX m_EmissiveColor; + S3D_VERTEX m_SpecularColor; float m_AmbientIntensity; float m_Transparency; float m_Shininess; @@ -104,10 +93,10 @@ class S3D_MASTER : public EDA_ITEM { public: wxString m_Shape3DName; /* 3D shape name in 3D library */ - S3D_Vertex m_MatScale; - S3D_Vertex m_MatRotation; - S3D_Vertex m_MatPosition; - Struct3D_Shape* m_3D_Drawings; + S3D_VERTEX m_MatScale; + S3D_VERTEX m_MatRotation; + S3D_VERTEX m_MatPosition; + STRUCT_3D_SHAPE* m_3D_Drawings; S3D_MATERIAL* m_Materials; public: @@ -146,7 +135,7 @@ public: int ReadShape( FILE* file, int* LineNum ); int ReadAppearance( FILE* file, int* LineNum ); int ReadGeometry( FILE* file, int* LineNum ); - void Set_Object_Coords( std::vector< S3D_Vertex >& aVertices ); + void Set_Object_Coords( std::vector< S3D_VERTEX >& aVertices ); #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override @@ -155,19 +144,19 @@ public: /* Describes a complex 3D */ -class Struct3D_Shape : public EDA_ITEM +class STRUCT_3D_SHAPE : public EDA_ITEM { public: - S3D_Vertex* m_3D_Coord; + S3D_VERTEX* m_3D_Coord; int* m_3D_CoordIndex; int m_3D_Points; public: - Struct3D_Shape( EDA_ITEM* aParent ); - ~Struct3D_Shape(); + STRUCT_3D_SHAPE( EDA_ITEM* aParent ); + ~STRUCT_3D_SHAPE(); - Struct3D_Shape* Next() const { return (Struct3D_Shape*) Pnext; } - Struct3D_Shape* Back() const { return (Struct3D_Shape*) Pback; } + STRUCT_3D_SHAPE* Next() const { return (STRUCT_3D_SHAPE*) Pnext; } + STRUCT_3D_SHAPE* Back() const { return (STRUCT_3D_SHAPE*) Pback; } int ReadData( FILE* file, int* LineNum ); @@ -197,8 +186,8 @@ public: * Function GetValue * @return the vertex in internal units. */ - S3D_Vertex GetValue(); - void SetValue( S3D_Vertex vertex ); + S3D_VERTEX GetValue(); + void SetValue( S3D_VERTEX vertex ); void Enable( bool enbl ); void SetToolTip( const wxString& text ); }; diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 95cc19eb26..73c17c8432 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * @@ -63,10 +63,8 @@ class ZONE_CONTAINER; #define LIB3D_PATH wxT( "packages3d" ) - -class EDA_3D_CANVAS; class EDA_3D_FRAME; -class S3D_Vertex; +class S3D_VERTEX; class SEGVIA; @@ -126,11 +124,37 @@ public: void DrawGrid( double aGriSizeMM ); - void Draw3D_Track( TRACK* track ); + /** + * Function Draw3D_Track + * @param aTrack = the aTrack to draw + */ + void Draw3D_Track( TRACK* aTrack ); + + /** + * Function Draw3D_Via + * draws 3D via as a cylinder and filled circles. + */ + void Draw3D_Via( SEGVIA* via ); + + /** + * Function Draw3D_DrawSegment + * draws a 3D segment (line, arc or circle). + */ + void Draw3D_DrawSegment( DRAWSEGMENT* segment ); + + /** + * Function Draw3D_Zone + * draw all solid areas in aZone + * @param aZone = the zone to draw + */ + void Draw3D_Zone( ZONE_CONTAINER* aZone ); /** * Function Draw3D_SolidPolygonsInZones * draw all solid polygons used as filled areas in a zone + * Function used by Draw3D_Zone + * Note: polygons are drawn, but not the thick polygon outlines + * Use Draw3D_Zone to draw aZone * @param aZone = the zone to draw */ void Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ); @@ -143,13 +167,6 @@ public: */ void Draw3D_Polygon( std::vector& aCornersList, double aZpos ); - /** - * Function Draw3D_Via - * draws 3D via as a cylinder and filled circles. - */ - void Draw3D_Via( SEGVIA* via ); - void Draw3D_DrawSegment( DRAWSEGMENT* segment ); - /** * Function Draw3D_DrawText * draws 3D segments to create text objects. @@ -242,6 +259,6 @@ private: }; void SetGLColor( int color ); -void Set_Object_Data( std::vector< S3D_Vertex >& aVertices ); +void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices ); #endif /* __3D_VIEWER_H__ */ diff --git a/3d-viewer/info3d_visu.h b/3d-viewer/info3d_visu.h index 3f9dbad540..0ef7c3177b 100644 --- a/3d-viewer/info3d_visu.h +++ b/3d-viewer/info3d_visu.h @@ -30,7 +30,7 @@ #ifndef __INFO3D_VISU_H__ #define __INFO3D_VISU_H__ -#include // m_auimanager member. +#include // m_auimanager member. #include // Layers id definitions #if !wxUSE_GLCANVAS @@ -51,44 +51,52 @@ #include <3d_struct.h> -#define m_ROTX m_Rot[0] -#define m_ROTY m_Rot[1] -#define m_ROTZ m_Rot[2] +#define m_ROTX m_Rot[0] +#define m_ROTY m_Rot[1] +#define m_ROTZ m_Rot[2] + + +class S3D_COLOR /* 3D color (R, G, B) 3 floats range 0 to 1.0*/ +{ +public: + double m_Red, m_Green, m_Blue; +public: S3D_COLOR() + { + m_Red = m_Green = m_Blue = 0; + } +}; /* information needed to display 3D board */ class INFO3D_VISU { - public: - enum DISPLAY3D_FLG - { - FL_AXIS=0, FL_MODULE, FL_ZONE, - FL_COMMENTS, FL_DRAWINGS, FL_ECO1, FL_ECO2, + enum DISPLAY3D_FLG { + FL_AXIS=0, FL_MODULE, FL_ZONE, + FL_COMMENTS, FL_DRAWINGS, FL_ECO1, FL_ECO2, FL_GRID, FL_LAST }; - double m_Beginx, m_Beginy; // position of mouse - double m_Quat[4]; // orientation of object - double m_Rot[4]; // man rotation of object - double m_Zoom; // field of view in degrees - double m_3D_Grid; // 3D grid valmue, in mm - S3D_Color m_BgColor; - bool m_DrawFlags[FL_LAST]; // show these special items - wxPoint m_BoardPos; - wxSize m_BoardSize; - int m_CopperLayersCount; // Number of copper layers actually used by the board + double m_Beginx, m_Beginy; // position of mouse + double m_Quat[4]; // orientation of object + double m_Rot[4]; // man rotation of object + double m_Zoom; // field of view in degrees + double m_3D_Grid; // 3D grid valmue, in mm + S3D_COLOR m_BgColor; + bool m_DrawFlags[FL_LAST]; // show these special items + wxPoint m_BoardPos; + wxSize m_BoardSize; + int m_CopperLayersCount; // Number of copper layers actually used by the board const BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings - double m_EpoxyThickness; // Epoxy thickness (normalized) - double m_NonCopperLayerThickness; // Non copper layers thickness - - double m_BoardScale; /* Normalization scale for coordinates: - * when scaled between -1.0 and +1.0 */ - double m_LayerZcoord[LAYER_COUNT]; // Z position of each layer (normalized) - double m_ActZpos; + double m_EpoxyThickness; // Epoxy thickness (normalized) + double m_NonCopperLayerThickness; // Non copper layers thickness + double m_BoardScale; /* Normalization scale for coordinates: + * when scaled between -1.0 and +1.0 */ + double m_LayerZcoord[LAYER_COUNT]; // Z position of each layer (normalized) + double m_ActZpos; public: INFO3D_VISU(); ~INFO3D_VISU(); }; @@ -96,4 +104,4 @@ public: INFO3D_VISU(); extern INFO3D_VISU g_Parm_3D_Visu; extern double DataScale3D; // 3D scale units. -#endif /* __INFO3D_VISU_H__ */ +#endif /* __INFO3D_VISU_H__ */ diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index dc81ae474f..e3f9341207 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -10,25 +10,7 @@ include_directories( ${INC_AFTER} ) -set(EESCHEMA_SRCS - annotate.cpp - backanno.cpp - block.cpp - block_libedit.cpp - build_BOM.cpp - busentry.cpp - bus-wire-junction.cpp - class_drc_erc_item.cpp - class_libentry.cpp - class_library.cpp - class_netlist_object.cpp - cmp_library_keywords.cpp - cmp_library_lexer.cpp - component_references_lister.cpp - controle.cpp - cross-probing.cpp - dangling_ends.cpp - database.cpp +set(EESCHEMA_DLGS dialogs/dialog_color_config.cpp dialogs/dialog_plot_schematic_DXF.cpp dialogs/dialog_plot_schematic_DXF_base.cpp @@ -67,6 +49,7 @@ set(EESCHEMA_SRCS dialogs/dialog_lib_edit_pin_base.cpp dialogs/dialog_lib_new_component.cpp dialogs/dialog_lib_new_component_base.cpp + dialogs/dialog_netlist_base.cpp dialogs/dialog_print_using_printer_base.cpp dialogs/dialog_print_using_printer.cpp dialogs/dialog_sch_edit_sheet_pin.cpp @@ -77,6 +60,28 @@ set(EESCHEMA_SRCS dialogs/dialog_schematic_find_base.cpp dialogs/dialog_SVG_print.cpp dialogs/dialog_SVG_print_base.cpp + ) + +set(EESCHEMA_SRCS + annotate.cpp + backanno.cpp + block.cpp + block_libedit.cpp + build_BOM.cpp + busentry.cpp + bus-wire-junction.cpp + class_drc_erc_item.cpp + class_libentry.cpp + class_library.cpp + class_netlist_object.cpp + cmp_library_keywords.cpp + cmp_library_lexer.cpp + component_references_lister.cpp + controle.cpp + cross-probing.cpp + dangling_ends.cpp + database.cpp + ${EESCHEMA_DLGS} edit_component_in_schematic.cpp edit_bitmap.cpp edit_label.cpp diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 71db4e2072..9a5dc23343 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -204,6 +204,10 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; + // Cursor is left off grid only if no block in progress + if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) + snapToGrid = true; + if( snapToGrid ) pos = screen->GetNearestGridPosition( pos ); @@ -298,6 +302,10 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; + // Cursor is left off grid only if no block in progress + if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) + snapToGrid = true; + if( snapToGrid ) pos = screen->GetNearestGridPosition( pos ); diff --git a/eeschema/dialogs/annotate_dialog.cpp b/eeschema/dialogs/annotate_dialog.cpp index d6ac66abb6..8d2fc2ade2 100644 --- a/eeschema/dialogs/annotate_dialog.cpp +++ b/eeschema/dialogs/annotate_dialog.cpp @@ -6,8 +6,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2011 jean-pierre Charras - * Copyright (C) 1992-2011 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2012 jean-pierre Charras + * Copyright (C) 1992-2012 Kicad Developers, see change_log.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 @@ -37,6 +37,8 @@ #define KEY_ANNOTATE_SORT_OPTION wxT("AnnotateSortOption") #define KEY_ANNOTATE_ALGO_OPTION wxT("AnnotateAlgoOption") +#define KEY_ANNOTATE_AUTOCLOSE_OPTION wxT("AnnotateAutoCloseOption") +#define KEY_ANNOTATE_USE_SILENTMODE wxT("AnnotateSilentMode") DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent ) @@ -92,6 +94,14 @@ void DIALOG_ANNOTATE::InitValues() m_rbStartSheetNumLarge->SetValue(1); break; } + + m_Config->Read(KEY_ANNOTATE_AUTOCLOSE_OPTION, &option, 0l); + if( option ) + m_cbAutoCloseDlg->SetValue(1); + + m_Config->Read(KEY_ANNOTATE_USE_SILENTMODE, &option, 0l); + if( option ) + m_cbUseSilentMode->SetValue(1); } annotate_down_right_bitmap->SetBitmap( KiBitmap( annotate_down_right_xpm ) ); @@ -112,10 +122,19 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) { m_Config->Write(KEY_ANNOTATE_SORT_OPTION, GetSortOrder()); m_Config->Write(KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo()); + m_Config->Write(KEY_ANNOTATE_AUTOCLOSE_OPTION, GetAnnotateAutoCloseOpt()); + m_Config->Write(KEY_ANNOTATE_USE_SILENTMODE, GetAnnotateSilentMode()); } + // Display a message info in verbose mode, + // or if a reset of the previous annotation is asked. + bool promptUser = ! GetAnnotateSilentMode(); + if( GetResetItems() ) + { message = _( "Clear and annotate all of the components " ); + promptUser = true; + } else message = _( "Annotate only the unannotated components " ); @@ -125,10 +144,14 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) message += _( "on the current sheet?" ); message += _( "\n\nThis operation will change the current annotation and cannot be undone." ); - response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); - if (response == wxCANCEL) - return; + if( promptUser ) + { + response = wxMessageBox( message, wxT( "" ), wxICON_EXCLAMATION | wxOK | wxCANCEL ); + + if (response == wxCANCEL) + return; + } m_Parent->AnnotateComponents( GetLevel(), (ANNOTATE_ORDER_T) GetSortOrder(), (ANNOTATE_OPTION_T) GetAnnotateAlgo(), @@ -136,6 +159,17 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) m_Parent->GetCanvas()->Refresh(); m_btnClear->Enable(); + + if( GetAnnotateAutoCloseOpt() ) + { + if( IsModal() ) + EndModal( wxID_OK ); + else + { + SetReturnCode( wxID_OK ); + this->Show( false ); + } + } } diff --git a/eeschema/dialogs/annotate_dialog.h b/eeschema/dialogs/annotate_dialog.h index a3e28bad7f..4c0a8c50ec 100644 --- a/eeschema/dialogs/annotate_dialog.h +++ b/eeschema/dialogs/annotate_dialog.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2009 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2012 KiCad Developers, see change_log.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 @@ -45,6 +45,7 @@ public: DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent ); ~DIALOG_ANNOTATE(){}; +private: /// Initialises member variables void InitValues(); void OnCancelClick( wxCommandEvent& event ); @@ -56,6 +57,14 @@ public: bool GetResetItems( void ); int GetSortOrder( void ); int GetAnnotateAlgo( void ); + bool GetAnnotateAutoCloseOpt() + { + return m_cbAutoCloseDlg->GetValue(); + } + bool GetAnnotateSilentMode() + { + return m_cbUseSilentMode->GetValue(); + } }; #endif diff --git a/eeschema/dialogs/dialog_annotate_base.cpp b/eeschema/dialogs/dialog_annotate_base.cpp index 9cf8d86127..32347a6fb1 100644 --- a/eeschema/dialogs/dialog_annotate_base.cpp +++ b/eeschema/dialogs/dialog_annotate_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -43,6 +43,7 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con m_rbResetAnnotation = new wxRadioButton( this, ID_RESET_ANNOTATION, _("&Reset existing annotation"), wxDefaultPosition, wxDefaultSize, 0 ); bscopeOptSizer->Add( m_rbResetAnnotation, 0, wxALL, 3 ); + bupperSizer->Add( bscopeOptSizer, 0, wxEXPAND|wxLEFT|wxALIGN_RIGHT, 25 ); m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); @@ -69,6 +70,7 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con annotate_down_right_bitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerXpos->Add( annotate_down_right_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT, 12 ); + b_orderOptSizer->Add( bSizerXpos, 0, wxEXPAND|wxRIGHT, 5 ); wxBoxSizer* bSizerYpos; @@ -83,8 +85,10 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con annotate_right_down_bitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); bSizerYpos->Add( annotate_right_down_bitmap, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 12 ); + b_orderOptSizer->Add( bSizerYpos, 0, wxEXPAND|wxRIGHT, 5 ); + bupperSizer->Add( b_orderOptSizer, 0, wxEXPAND|wxLEFT, 25 ); m_staticline5 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); @@ -111,6 +115,7 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con bSizerChoiceInc->Add( 0, 0, 1, wxEXPAND, 5 ); + bSizer1AlgoChoice->Add( bSizerChoiceInc, 0, wxEXPAND|wxRIGHT, 5 ); wxBoxSizer* bSizerChoiceIncBySheet; @@ -122,6 +127,7 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con bSizerChoiceIncBySheet->Add( 0, 0, 1, wxEXPAND, 5 ); + bSizer1AlgoChoice->Add( bSizerChoiceIncBySheet, 1, wxEXPAND, 5 ); wxBoxSizer* bSizerChoiceIncBySheetLarge; @@ -133,15 +139,63 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con bSizerChoiceIncBySheetLarge->Add( 0, 0, 1, wxEXPAND, 5 ); + bSizer1AlgoChoice->Add( bSizerChoiceIncBySheetLarge, 1, wxEXPAND, 5 ); + bSizerAnnotAlgo->Add( bSizer1AlgoChoice, 1, wxEXPAND|wxLEFT, 25 ); + bupperSizer->Add( bSizerAnnotAlgo, 0, wxEXPAND|wxRIGHT, 5 ); m_staticline4 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bupperSizer->Add( m_staticline4, 0, wxEXPAND | wxALL, 5 ); + wxBoxSizer* bSizerDldOptions; + bSizerDldOptions = new wxBoxSizer( wxVERTICAL ); + + m_staticTextDlgOpts = new wxStaticText( this, wxID_ANY, _("Dialog"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDlgOpts->Wrap( -1 ); + m_staticTextDlgOpts->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + + bSizerDldOptions->Add( m_staticTextDlgOpts, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bSizerDlgChoices; + bSizerDlgChoices = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizerChoiceClose; + bSizerChoiceClose = new wxBoxSizer( wxHORIZONTAL ); + + m_cbAutoCloseDlg = new wxCheckBox( this, wxID_ANY, _("Automatically close this dialog"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerChoiceClose->Add( m_cbAutoCloseDlg, 0, wxALL, 5 ); + + + bSizerChoiceClose->Add( 0, 0, 1, wxEXPAND, 5 ); + + + bSizerDlgChoices->Add( bSizerChoiceClose, 0, wxEXPAND|wxRIGHT, 5 ); + + wxBoxSizer* bSizerChoiceSilentMode; + bSizerChoiceSilentMode = new wxBoxSizer( wxHORIZONTAL ); + + m_cbUseSilentMode = new wxCheckBox( this, wxID_ANY, _("Silent mode"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerChoiceSilentMode->Add( m_cbUseSilentMode, 0, wxALL, 5 ); + + + bSizerChoiceSilentMode->Add( 0, 0, 1, wxEXPAND, 5 ); + + + bSizerDlgChoices->Add( bSizerChoiceSilentMode, 1, wxEXPAND, 5 ); + + + bSizerDldOptions->Add( bSizerDlgChoices, 1, wxEXPAND|wxLEFT, 25 ); + + m_staticline41 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerDldOptions->Add( m_staticline41, 0, wxEXPAND | wxALL, 5 ); + + + bupperSizer->Add( bSizerDldOptions, 0, wxEXPAND|wxRIGHT, 5 ); + wxBoxSizer* bButtonsSizer; bButtonsSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -154,10 +208,13 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con m_btnApply = new wxButton( this, wxID_APPLY, _("Annotation"), wxDefaultPosition, wxDefaultSize, 0 ); bButtonsSizer->Add( m_btnApply, 0, wxALL|wxEXPAND, 5 ); + bupperSizer->Add( bButtonsSizer, 0, wxALIGN_CENTER_HORIZONTAL, 6 ); + bmainSizer->Add( bupperSizer, 1, wxALL|wxEXPAND, 6 ); + this->SetSizer( bmainSizer ); this->Layout(); diff --git a/eeschema/dialogs/dialog_annotate_base.fbp b/eeschema/dialogs/dialog_annotate_base.fbp index 66c706cbcd..86690d2e6c 100644 --- a/eeschema/dialogs/dialog_annotate_base.fbp +++ b/eeschema/dialogs/dialog_annotate_base.fbp @@ -1,12 +1,14 @@ - + C++ 1 source_name + 0 0 + res UTF-8 connect dialog_annotate_base @@ -18,10 +20,13 @@ . 1 + 1 1 0 0 + 0 + wxAUI_MGR_DEFAULT @@ -37,20 +42,22 @@ DIALOG_ANNOTATE_BASE - 432,382 + 432,454 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - + DIALOG_SHIM; dialog_shim.h Annotate Schematic - - wxFILTER_NONE - wxDefaultValidator - + + + + + + @@ -98,28 +105,55 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 ,90,92,-1,70,0 + 0 0 wxID_ANY Scope + + 0 + + 0 + 1 m_staticTextScope + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -163,23 +197,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_ENTIRE_SCHEMATIC Use the &entire schematic + + 0 + + 0 + 1 m_rbEntireSchematic + 1 + + protected + 1 + Resizable + 1 wxRB_GROUP + 0 wxFILTER_NONE @@ -220,23 +285,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_CURRENT_PAGE Use the current &page only + + 0 + + 0 + 1 m_rbCurrPage + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -277,27 +373,54 @@ wxEXPAND | wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 + + 0 + 1 m_staticline1 + 1 + + protected + 1 + Resizable + 1 wxLI_HORIZONTAL + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -331,23 +454,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_KEEP_ANNOTATION &Keep existing annotation + + 0 + + 0 + 1 m_rbKeepAnnotation + 1 + + protected + 1 + Resizable + 1 wxRB_GROUP + 0 wxFILTER_NONE @@ -388,23 +542,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_RESET_ANNOTATION &Reset existing annotation + + 0 + + 0 + 1 m_rbResetAnnotation + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -447,27 +632,54 @@ wxEXPAND | wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 + + 0 + 1 m_staticline2 + 1 + + protected + 1 + Resizable + 1 wxLI_HORIZONTAL + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -501,28 +713,55 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 ,90,92,-1,70,0 + 0 0 wxID_ANY Annotation Order + + 0 + + 0 + 1 m_staticTextOrder + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -575,23 +814,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_SORT_BY_X_POSITION Sort components by &X position + + 0 + + 0 + 1 m_rbSortBy_X_Position + 1 + + protected + 1 + Resizable + 1 wxRB_GROUP + 0 wxFILTER_NONE @@ -642,27 +912,54 @@ wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + + - ; Load From Resource + Load From Resource; + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 + + 0 + 1 annotate_down_right_bitmap + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -707,23 +1004,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_SORT_BY_Y_POSITION Sort components by &Y position + + 0 + + 0 + 1 m_rbSortBy_Y_Position + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -774,27 +1102,54 @@ wxALIGN_CENTER_VERTICAL|wxRIGHT 0 + 1 + 1 + 1 + 1 + + + + + - ; Load From Resource + Load From Resource; + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 + + 0 + 1 annotate_right_down_bitmap + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -832,27 +1187,54 @@ wxEXPAND | wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 + + 0 + 1 m_staticline5 + 1 + + protected + 1 + Resizable + 1 wxLI_HORIZONTAL + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -895,28 +1277,55 @@ wxTOP|wxRIGHT|wxLEFT 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 ,90,92,-1,70,0 + 0 0 wxID_ANY Annotation Choice + + 0 + + 0 + 1 m_staticTextAnnotateAlgo + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -969,23 +1378,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_SORT_BY_X_POSITION Use first free number in schematic + + 0 + + 0 + 1 m_rbUseIncremental + 1 + + protected + 1 + Resizable + 1 wxRB_GROUP + 0 wxFILTER_NONE @@ -1047,23 +1487,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Start to sheet number*100 and use first free number + + 0 + + 0 + 1 m_rbUseSheetNum + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -1125,23 +1596,54 @@ wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Start to sheet number*1000 and use first free number + + 0 + + 0 + 1 m_rbStartSheetNumLarge + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -1198,27 +1700,54 @@ wxEXPAND | wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 + + 0 + 1 m_staticline4 + 1 + + protected + 1 + Resizable + 1 wxLI_HORIZONTAL + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -1247,6 +1776,410 @@ + + 5 + wxEXPAND|wxRIGHT + 0 + + + bSizerDldOptions + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + Dialog + + 0 + + + 0 + + 1 + m_staticTextDlgOpts + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 25 + wxEXPAND|wxLEFT + 1 + + + bSizerDlgChoices + wxVERTICAL + none + + 5 + wxEXPAND|wxRIGHT + 0 + + + bSizerChoiceClose + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Automatically close this dialog + + 0 + + + 0 + + 1 + m_cbAutoCloseDlg + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + + + 5 + wxEXPAND + 1 + + + bSizerChoiceSilentMode + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Silent mode + + 0 + + + 0 + + 1 + m_cbUseSilentMode + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline41 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 wxALIGN_CENTER_HORIZONTAL @@ -1261,24 +2194,55 @@ wxALL|wxEXPAND 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 0 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_CANCEL Close + + 0 + + 0 + 1 m_btnClose + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -1318,24 +2282,55 @@ wxALL|wxEXPAND 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 0 + 0 + Dock + 0 + Left 1 + 1 + 0 0 ID_CLEAR_ANNOTATION_CMP Clear Annotation + + 0 + + 0 + 1 m_btnClear + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -1375,24 +2370,55 @@ wxALL|wxEXPAND 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 0 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_APPLY Annotation + + 0 + + 0 + 1 m_btnApply + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE diff --git a/eeschema/dialogs/dialog_annotate_base.h b/eeschema/dialogs/dialog_annotate_base.h index 2883b386cf..eb319b3868 100644 --- a/eeschema/dialogs/dialog_annotate_base.h +++ b/eeschema/dialogs/dialog_annotate_base.h @@ -1,15 +1,17 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Sep 8 2010) +// C++ code generated with wxFormBuilder (version Apr 10 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __dialog_annotate_base__ -#define __dialog_annotate_base__ +#ifndef __DIALOG_ANNOTATE_BASE_H__ +#define __DIALOG_ANNOTATE_BASE_H__ +#include +#include #include - +#include "dialog_shim.h" #include #include #include @@ -23,6 +25,7 @@ #include #include #include +#include #include #include @@ -39,7 +42,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_ANNOTATE_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_ANNOTATE_BASE : public wxDialog +class DIALOG_ANNOTATE_BASE : public DIALOG_SHIM { private: @@ -53,20 +56,19 @@ class DIALOG_ANNOTATE_BASE : public wxDialog wxStaticLine* m_staticline2; wxStaticText* m_staticTextOrder; wxRadioButton* m_rbSortBy_X_Position; - wxStaticBitmap* annotate_down_right_bitmap; wxRadioButton* m_rbSortBy_Y_Position; - wxStaticBitmap* annotate_right_down_bitmap; wxStaticLine* m_staticline5; wxStaticText* m_staticTextAnnotateAlgo; wxRadioButton* m_rbUseIncremental; - wxRadioButton* m_rbUseSheetNum; - wxRadioButton* m_rbStartSheetNumLarge; - wxStaticLine* m_staticline4; + wxStaticText* m_staticTextDlgOpts; + wxCheckBox* m_cbAutoCloseDlg; + wxCheckBox* m_cbUseSilentMode; + wxStaticLine* m_staticline41; wxButton* m_btnClose; wxButton* m_btnClear; wxButton* m_btnApply; @@ -79,9 +81,9 @@ class DIALOG_ANNOTATE_BASE : public wxDialog public: - DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Annotate Schematic"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 432,382 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Annotate Schematic"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 432,454 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_ANNOTATE_BASE(); }; -#endif //__dialog_annotate_base__ +#endif //__DIALOG_ANNOTATE_BASE_H__ diff --git a/eeschema/dialogs/dialog_netlist_base.cpp b/eeschema/dialogs/dialog_netlist_base.cpp new file mode 100644 index 0000000000..6d17c77280 --- /dev/null +++ b/eeschema/dialogs/dialog_netlist_base.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 10 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_netlist_base.h" + +/////////////////////////////////////////////////////////////////////////// + +BEGIN_EVENT_TABLE( NETLIST_DIALOG_BASE, DIALOG_SHIM ) + EVT_NOTEBOOK_PAGE_CHANGED( ID_CHANGE_NOTEBOOK_PAGE, NETLIST_DIALOG_BASE::_wxFB_OnNetlistTypeSelection ) + EVT_BUTTON( ID_CREATE_NETLIST, NETLIST_DIALOG_BASE::_wxFB_GenNetlist ) + EVT_BUTTON( wxID_CANCEL, NETLIST_DIALOG_BASE::_wxFB_OnCancelClick ) + EVT_BUTTON( ID_ADD_PLUGIN, NETLIST_DIALOG_BASE::_wxFB_OnAddPlugin ) + EVT_BUTTON( ID_DEL_PLUGIN, NETLIST_DIALOG_BASE::_wxFB_OnDelPlugin ) +END_EVENT_TABLE() + +NETLIST_DIALOG_BASE::NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bUpperSizer; + bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bRightSizer; + bRightSizer = new wxBoxSizer( wxVERTICAL ); + + m_NoteBook = new wxNotebook( this, ID_CHANGE_NOTEBOOK_PAGE, wxDefaultPosition, wxDefaultSize, 0 ); + + bRightSizer->Add( m_NoteBook, 1, wxEXPAND | wxALL, 5 ); + + + bUpperSizer->Add( bRightSizer, 1, wxEXPAND, 5 ); + + wxBoxSizer* bLeftSizer; + bLeftSizer = new wxBoxSizer( wxVERTICAL ); + + + bLeftSizer->Add( 0, 0, 0, wxTOP, 15 ); + + m_buttonNetlist = new wxButton( this, ID_CREATE_NETLIST, _("Netlist"), wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizer->Add( m_buttonNetlist, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizer->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_buttonAddPlugin = new wxButton( this, ID_ADD_PLUGIN, _("Add Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizer->Add( m_buttonAddPlugin, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_buttonDelPlugin = new wxButton( this, ID_DEL_PLUGIN, _("Remove Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizer->Add( m_buttonDelPlugin, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bLeftSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + + m_cbUseDefaultNetlistName = new wxCheckBox( this, wxID_ANY, _("Use default netname"), wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizer->Add( m_cbUseDefaultNetlistName, 0, wxALL, 5 ); + + + bUpperSizer->Add( bLeftSizer, 0, wxEXPAND, 5 ); + + + bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); + + m_staticTextDefaultFN = new wxStaticText( this, wxID_ANY, _("Default Netlist Filename:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDefaultFN->Wrap( -1 ); + bMainSizer->Add( m_staticTextDefaultFN, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_textCtrlDefaultFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + bMainSizer->Add( m_textCtrlDefaultFileName, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + this->SetSizer( bMainSizer ); + this->Layout(); + + this->Centre( wxBOTH ); +} + +NETLIST_DIALOG_BASE::~NETLIST_DIALOG_BASE() +{ +} + +BEGIN_EVENT_TABLE( NETLIST_DIALOG_ADD_PLUGIN_BASE, DIALOG_SHIM ) + EVT_BUTTON( wxID_OK, NETLIST_DIALOG_ADD_PLUGIN_BASE::_wxFB_OnOKClick ) + EVT_BUTTON( wxID_CANCEL, NETLIST_DIALOG_ADD_PLUGIN_BASE::_wxFB_OnCancelClick ) + EVT_BUTTON( wxID_BROWSE_PLUGINS, NETLIST_DIALOG_ADD_PLUGIN_BASE::_wxFB_OnBrowsePlugins ) +END_EVENT_TABLE() + +NETLIST_DIALOG_ADD_PLUGIN_BASE::NETLIST_DIALOG_ADD_PLUGIN_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizerLeft; + bSizerLeft = new wxBoxSizer( wxVERTICAL ); + + m_staticTextCmd = new wxStaticText( this, wxID_ANY, _("Netlist command:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextCmd->Wrap( -1 ); + bSizerLeft->Add( m_staticTextCmd, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_textCtrlCommand = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textCtrlCommand->SetMinSize( wxSize( 300,-1 ) ); + + bSizerLeft->Add( m_textCtrlCommand, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_staticTextName = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextName->Wrap( -1 ); + bSizerLeft->Add( m_staticTextName, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerLeft->Add( m_textCtrlName, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + bSizerMain->Add( bSizerLeft, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizerRight; + bSizerRight = new wxBoxSizer( wxVERTICAL ); + + m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonOK->SetDefault(); + bSizerRight->Add( m_buttonOK, 0, wxALL|wxEXPAND, 5 ); + + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_buttonCancel, 0, wxALL|wxEXPAND, 5 ); + + m_buttonPlugin = new wxButton( this, wxID_BROWSE_PLUGINS, _("Browse Plugins"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_buttonPlugin, 0, wxALL|wxEXPAND, 5 ); + + + bSizerMain->Add( bSizerRight, 0, wxEXPAND, 5 ); + + + this->SetSizer( bSizerMain ); + this->Layout(); + + this->Centre( wxBOTH ); +} + +NETLIST_DIALOG_ADD_PLUGIN_BASE::~NETLIST_DIALOG_ADD_PLUGIN_BASE() +{ +} diff --git a/eeschema/dialogs/dialog_netlist_base.fbp b/eeschema/dialogs/dialog_netlist_base.fbp new file mode 100644 index 0000000000..60fe1c5839 --- /dev/null +++ b/eeschema/dialogs/dialog_netlist_base.fbp @@ -0,0 +1,1622 @@ + + + + + + C++ + 0 + source_name + 0 + 0 + res + UTF-8 + table + dialog_netlist_base + 1000 + none + 1 + dialog_netlist_base + + . + + 1 + 1 + 1 + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + NETLIST_DIALOG_BASE + + 404,334 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Netlist + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bUpperSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bRightSizer + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_CHANGE_NOTEBOOK_PAGE + + 0 + + + 0 + + 1 + m_NoteBook + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + + + + + + + + + + + + + + + + + OnNetlistTypeSelection + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bLeftSizer + wxVERTICAL + none + + 15 + wxTOP + 0 + + 0 + protected + 0 + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_CREATE_NETLIST + Netlist + + 0 + + + 0 + + 1 + m_buttonNetlist + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + GenNetlist + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_CANCEL + Cancel + + 0 + + + 0 + + 1 + m_buttonCancel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_ADD_PLUGIN + Add Plugin + + 0 + + + 0 + + 1 + m_buttonAddPlugin + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddPlugin + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_DEL_PLUGIN + Remove Plugin + + 0 + + + 0 + + 1 + m_buttonDelPlugin + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnDelPlugin + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Use default netname + + 0 + + + 0 + + 1 + m_cbUseDefaultNetlistName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Default Netlist Filename: + + 0 + + + 0 + + 1 + m_staticTextDefaultFN + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textCtrlDefaultFileName + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + NETLIST_DIALOG_ADD_PLUGIN_BASE + + 312,144 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Plugins: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMain + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizerLeft + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Netlist command: + + 0 + + + 0 + + 1 + m_staticTextCmd + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + 300,-1 + 1 + m_textCtrlCommand + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Name: + + 0 + + + 0 + + 1 + m_staticTextName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textCtrlName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizerRight + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_OK + OK + + 0 + + + 0 + + 1 + m_buttonOK + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnOKClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_CANCEL + Cancel + + 0 + + + 0 + + 1 + m_buttonCancel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_BROWSE_PLUGINS + Browse Plugins + + 0 + + + 0 + + 1 + m_buttonPlugin + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnBrowsePlugins + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_netlist_base.h b/eeschema/dialogs/dialog_netlist_base.h new file mode 100644 index 0000000000..2605c8e84c --- /dev/null +++ b/eeschema/dialogs/dialog_netlist_base.h @@ -0,0 +1,122 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 10 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_NETLIST_BASE_H__ +#define __DIALOG_NETLIST_BASE_H__ + +#include +#include +#include +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class NETLIST_DIALOG_BASE +/////////////////////////////////////////////////////////////////////////////// +class NETLIST_DIALOG_BASE : public DIALOG_SHIM +{ + DECLARE_EVENT_TABLE() + private: + + // Private event handlers + void _wxFB_OnNetlistTypeSelection( wxNotebookEvent& event ){ OnNetlistTypeSelection( event ); } + void _wxFB_GenNetlist( wxCommandEvent& event ){ GenNetlist( event ); } + void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); } + void _wxFB_OnAddPlugin( wxCommandEvent& event ){ OnAddPlugin( event ); } + void _wxFB_OnDelPlugin( wxCommandEvent& event ){ OnDelPlugin( event ); } + + + protected: + enum + { + ID_CHANGE_NOTEBOOK_PAGE = 1000, + ID_CREATE_NETLIST, + ID_ADD_PLUGIN, + ID_DEL_PLUGIN + }; + + wxNotebook* m_NoteBook; + wxButton* m_buttonNetlist; + wxButton* m_buttonCancel; + wxButton* m_buttonAddPlugin; + wxButton* m_buttonDelPlugin; + wxStaticLine* m_staticline1; + wxCheckBox* m_cbUseDefaultNetlistName; + wxStaticText* m_staticTextDefaultFN; + wxTextCtrl* m_textCtrlDefaultFileName; + + // Virtual event handlers, overide them in your derived class + virtual void OnNetlistTypeSelection( wxNotebookEvent& event ) { event.Skip(); } + virtual void GenNetlist( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnAddPlugin( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDelPlugin( wxCommandEvent& event ) { event.Skip(); } + + + public: + + NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Netlist"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 404,334 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~NETLIST_DIALOG_BASE(); + +}; + +/////////////////////////////////////////////////////////////////////////////// +/// Class NETLIST_DIALOG_ADD_PLUGIN_BASE +/////////////////////////////////////////////////////////////////////////////// +class NETLIST_DIALOG_ADD_PLUGIN_BASE : public DIALOG_SHIM +{ + DECLARE_EVENT_TABLE() + private: + + // Private event handlers + void _wxFB_OnOKClick( wxCommandEvent& event ){ OnOKClick( event ); } + void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); } + void _wxFB_OnBrowsePlugins( wxCommandEvent& event ){ OnBrowsePlugins( event ); } + + + protected: + enum + { + wxID_BROWSE_PLUGINS = 1000 + }; + + wxStaticText* m_staticTextCmd; + wxTextCtrl* m_textCtrlCommand; + wxStaticText* m_staticTextName; + wxTextCtrl* m_textCtrlName; + wxButton* m_buttonOK; + wxButton* m_buttonCancel; + wxButton* m_buttonPlugin; + + // Virtual event handlers, overide them in your derived class + virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnBrowsePlugins( wxCommandEvent& event ) { event.Skip(); } + + + public: + + NETLIST_DIALOG_ADD_PLUGIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plugins:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 312,144 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~NETLIST_DIALOG_ADD_PLUGIN_BASE(); + +}; + +#endif //__DIALOG_NETLIST_BASE_H__ diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 59d0189ca5..cf93b1c235 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -248,7 +248,9 @@ enum id_eeschema_frm ID_LIBVIEW_LIBWINDOW, ID_LIBVIEW_CMPWINDOW, ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, - ID_SET_RELATIVE_OFFSET + ID_SET_RELATIVE_OFFSET, + + ID_END_EESCHEMA_ID_LIST }; diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp index 8a89a3d88e..1fe657f83f 100644 --- a/eeschema/netlist_control.cpp +++ b/eeschema/netlist_control.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2012 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 @@ -54,6 +54,15 @@ #include #include +#include + +/* Event id for notebook page buttons: */ +enum id_netlist { + ID_CREATE_NETLIST = ID_END_EESCHEMA_ID_LIST + 1, + ID_CURRENT_FORMAT_IS_DEFAULT, + ID_RUN_SIMULATOR, + ID_ADD_SUBCIRCUIT_PREFIX +}; //Imported function: int TestDuplicateSheetNames( bool aCreateMarker ); @@ -61,44 +70,14 @@ int TestDuplicateSheetNames( bool aCreateMarker ); // ID for configuration: #define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" ) #define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" ) +#define NETLIST_USE_DEFAULT_NETNAME wxT( "NetlistUseDefaultNetname" ) -/** - * Function ReturnUserNetlistTypeName - * to retrieve user netlist type names - * @param first_item = true: return first name of the list, false = return next - * @return a wxString : name of the type netlist or empty string - * this function must be called first with "first_item" = true - * and after with "first_item" = false to get all the other existing netlist names - */ -wxString ReturnUserNetlistTypeName( bool first_item ) -{ - static int index; - wxString name, msg; - if( first_item ) - index = 0; - else - index++; - - msg = CUSTOM_NETLIST_TITLE; - msg << index + 1; - - if( wxGetApp().GetSettings() ) - name = wxGetApp().GetSettings()->Read( msg ); - - return name; -} - - -BEGIN_EVENT_TABLE( NETLIST_DIALOG, wxDialog ) - EVT_BUTTON( wxID_CANCEL, NETLIST_DIALOG::OnCancelClick ) +BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE ) EVT_BUTTON( ID_CREATE_NETLIST, NETLIST_DIALOG::GenNetlist ) - EVT_BUTTON( ID_SETUP_PLUGIN, NETLIST_DIALOG::AddNewPluginPanel ) - EVT_BUTTON( ID_DELETE_PLUGIN, NETLIST_DIALOG::DeletePluginPanel ) - EVT_BUTTON( ID_VALIDATE_PLUGIN, NETLIST_DIALOG::ValidatePluginPanel ) EVT_CHECKBOX( ID_CURRENT_FORMAT_IS_DEFAULT, - NETLIST_DIALOG::SelectNetlistType ) + NETLIST_DIALOG::SelectDefaultNetlistType ) EVT_CHECKBOX( ID_ADD_SUBCIRCUIT_PREFIX, NETLIST_DIALOG::EnableSubcircuitPrefix ) EVT_BUTTON( ID_RUN_SIMULATOR, NETLIST_DIALOG::RunSimulator ) @@ -115,9 +94,7 @@ END_EVENT_TABLE() */ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title, - int id_NetType, - int idCheckBox, - int idCreateFile ) : + NETLIST_TYPE_ID id_NetType ) : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_SUNKEN ) { m_IdNetType = id_NetType; @@ -162,15 +139,13 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, UpperBoxSizer->Add( m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); UpperBoxSizer->Add( m_RightOptionsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - if( idCheckBox ) - { - wxStaticText* text = new wxStaticText( this, -1, _( "Options:" ) ); - m_LeftBoxSizer->Add( text, 0, wxGROW | wxALL, 5 ); + wxStaticText* text = new wxStaticText( this, -1, _( "Options:" ) ); + m_LeftBoxSizer->Add( text, 0, wxGROW | wxALL, 5 ); - m_IsCurrentFormat = new wxCheckBox( this, idCheckBox, _( "Default format" ) ); - m_LeftBoxSizer->Add( m_IsCurrentFormat, 0, wxGROW | wxALL, 5 ); - m_IsCurrentFormat->SetValue( selected ); - } + m_IsCurrentFormat = new wxCheckBox( this, ID_CURRENT_FORMAT_IS_DEFAULT, + _( "Default format" ) ); + m_LeftBoxSizer->Add( m_IsCurrentFormat, 0, wxGROW | wxALL, 5 ); + m_IsCurrentFormat->SetValue( selected ); if( id_NetType == NET_TYPE_PCBNEW ) { @@ -182,39 +157,6 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, m_NetOption->SetSelection( fmtOption ); m_LeftBoxSizer->Add( m_NetOption, 0, wxGROW | wxALL, 5 ); } - - - /* Create the buttons: Create Netlist or browse Plugin and Cancel - * and a third button for plugins : Remove or Ok button */ - if( idCreateFile ) - { - wxButton* Button; - - if( idCreateFile == ID_SETUP_PLUGIN ) /* This is the "add plugin" panel */ - Button = new wxButton( this, idCreateFile, _( "&Browse Plugin" ) ); - else - Button = new wxButton( this, idCreateFile, _( "&Netlist" ) ); - - m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button->SetDefault(); - m_ButtonCancel = new wxButton( this, wxID_CANCEL, _( "&Cancel" ) ); - m_RightBoxSizer->Add( m_ButtonCancel, 0, wxGROW | wxALL, 5 ); - - /* Add special buttons to plugin panels: - * for panel plugins: added the "delete" button - * for the last panel (add plugin) a Ok button is added - */ - if( idCreateFile == ID_SETUP_PLUGIN ) /* This is the "add plugin" panel: add Ok button */ - { - Button = new wxButton( this, ID_VALIDATE_PLUGIN, _( "&Ok" ) ); - m_RightOptionsBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - } - else if( id_NetType >= PANELCUSTOMBASE ) /* This is a plugin panel: add delete button */ - { - Button = new wxButton( this, ID_DELETE_PLUGIN, _( "&Delete" ) ); - m_RightOptionsBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - } - } } const wxString NETLIST_PAGE_DIALOG::GetPageNetFmtName() @@ -232,53 +174,39 @@ const wxString NETLIST_PAGE_DIALOG::GetPageNetFmtName() NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) : - wxDialog( parent, -1, _( "Netlist" ), wxDefaultPosition, - wxDefaultSize, DIALOG_STYLE | MAYBE_RESIZE_BORDER ) + NETLIST_DIALOG_BASE( parent ) { - int ii; - m_Parent = parent; + m_Config = wxGetApp().GetSettings(); + + long tmp; + m_Config->Read( NETLIST_USE_DEFAULT_NETNAME, &tmp, 0l ); + m_cbUseDefaultNetlistName->SetValue( tmp ); + + m_NetFmtName = m_Parent->GetNetListFormatName(); - for( ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ ) + for( int ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ ) { m_PanelNetType[ii] = NULL; } - wxBoxSizer* GeneralBoxSizer = new wxBoxSizer( wxVERTICAL ); - SetSizer( GeneralBoxSizer ); - - m_NoteBook = new wxNotebook( this, ID_NETLIST_NOTEBOOK, - wxDefaultPosition, wxDefaultSize, - wxNB_TOP ); // @todo: tabs on top are being hidden on linux - - GeneralBoxSizer->Add( m_NoteBook, 0, wxGROW | wxALL, 5 ); - // Add notebook pages: // Add Panel FORMAT PCBNEW m_PanelNetType[PANELPCBNEW] = - new NETLIST_PAGE_DIALOG( m_NoteBook, - wxT( "Pcbnew" ), - NET_TYPE_PCBNEW, - ID_CURRENT_FORMAT_IS_DEFAULT, - ID_CREATE_NETLIST ); + new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "Pcbnew" ), + NET_TYPE_PCBNEW ); // Add Panel FORMAT ORCADPCB2 m_PanelNetType[PANELORCADPCB2] = - new NETLIST_PAGE_DIALOG( m_NoteBook, - wxT( "OrcadPCB2" ), - NET_TYPE_ORCADPCB2, - ID_CURRENT_FORMAT_IS_DEFAULT, - ID_CREATE_NETLIST ); + new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "OrcadPCB2" ), + NET_TYPE_ORCADPCB2 ); // Add Panel FORMAT CADSTAR m_PanelNetType[PANELCADSTAR] = - new NETLIST_PAGE_DIALOG( m_NoteBook, - wxT( "CadStar" ), - NET_TYPE_CADSTAR, - ID_CURRENT_FORMAT_IS_DEFAULT, - ID_CREATE_NETLIST ); + new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "CadStar" ), + NET_TYPE_CADSTAR ); // Add Panel spice InstallPageSpice(); @@ -286,13 +214,38 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) : // Add custom panels: InstallCustomPages(); -// GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); Centre(); } +/** + * Function ReturnUserNetlistTypeName + * to retrieve user netlist type names + * @param first_item = true: return first name of the list, false = return next + * @return a wxString : name of the type netlist or empty string + * this function must be called first with "first_item" = true + * and after with "first_item" = false to get all the other existing netlist names + */ +const wxString NETLIST_DIALOG::ReturnUserNetlistTypeName( bool first_item ) +{ + static int index; + wxString name, msg; + + if( first_item ) + index = 0; + else + index++; + + msg = CUSTOM_NETLIST_TITLE; + msg << index + 1; + + name = m_Config->Read( msg ); + + return name; +} + void NETLIST_DIALOG::InstallPageSpice() { wxButton* Button; @@ -300,15 +253,8 @@ void NETLIST_DIALOG::InstallPageSpice() wxString title = wxT( "Spice" ); page = m_PanelNetType[PANELSPICE] = - new NETLIST_PAGE_DIALOG( m_NoteBook, - title, - NET_TYPE_SPICE, - 0, 0 ); + new NETLIST_PAGE_DIALOG( m_NoteBook, title, NET_TYPE_SPICE ); - page->m_IsCurrentFormat = new wxCheckBox( page, ID_CURRENT_FORMAT_IS_DEFAULT, - _( "Default format" ) ); - page->m_IsCurrentFormat->SetValue( m_NetFmtName == title ); - page->m_LeftBoxSizer->Add( page->m_IsCurrentFormat, 1, wxGROW | wxALL, 5 ); page->m_AddSubPrefix = new wxCheckBox( page, ID_ADD_SUBCIRCUIT_PREFIX, _( "Prefix references 'U' and 'IC' with 'X'" ) ); @@ -340,15 +286,8 @@ void NETLIST_DIALOG::InstallPageSpice() 5 ); // Add buttons - Button = new wxButton( page, ID_CREATE_NETLIST, _( "Netlist" ) ); - page->m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button->SetDefault(); - Button = new wxButton( page, ID_RUN_SIMULATOR, _( "&Run Simulator" ) ); page->m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - - Button = new wxButton( page, wxID_CANCEL, _( "&Cancel" ) ); - page->m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); } @@ -356,147 +295,109 @@ void NETLIST_DIALOG::InstallPageSpice() */ void NETLIST_DIALOG::InstallCustomPages() { - int ii, CustomCount; - wxString title, previoustitle, msg; - NETLIST_PAGE_DIALOG* CurrPage; + int ii; + wxString title, msg; + NETLIST_PAGE_DIALOG* currPage; - CustomCount = CUSTOMPANEL_COUNTMAX; - previoustitle = wxT( "dummy_title" ); - - for( ii = 0; ii < CustomCount; ii++ ) + for( ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) { title = ReturnUserNetlistTypeName( ii == 0 ? true : false ); - if( title.IsEmpty() && previoustitle.IsEmpty() ) + if( title.IsEmpty() ) break; // No more panel to install - /* Install the panel "Add Plugin" after - * the last initialized panel */ - - previoustitle = title; - - if( title.IsEmpty() ) - CurrPage = - m_PanelNetType[PANELCUSTOMBASE + ii] = - new NETLIST_PAGE_DIALOG( m_NoteBook, - _( "Add Plugin" ), - NET_TYPE_CUSTOM1 + ii, - ID_CURRENT_FORMAT_IS_DEFAULT, - ID_SETUP_PLUGIN ); - else /* Install a plugin panel */ - CurrPage = - m_PanelNetType[PANELCUSTOMBASE + ii] = - new NETLIST_PAGE_DIALOG( m_NoteBook, - title, - NET_TYPE_CUSTOM1 + ii, - ID_CURRENT_FORMAT_IS_DEFAULT, - ID_CREATE_NETLIST ); - + // Install a plugin panel msg = CUSTOM_NETLIST_COMMAND; msg << ii + 1; - wxString Command = wxGetApp().GetSettings()->Read( msg ); + wxString command = m_Config->Read( msg ); - CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage, - -1, _( "Netlist command:" ) ), 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - - CurrPage->m_CommandStringCtrl = new wxTextCtrl( CurrPage, -1, Command, - wxDefaultPosition, wxDefaultSize ); - - CurrPage->m_CommandStringCtrl->SetInsertionPoint( 1 ); - CurrPage->m_LowBoxSizer->Add( CurrPage->m_CommandStringCtrl, - 0, - wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, - 5 ); - - CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage, - -1, _( "Title:" ) ), 0, - wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - - CurrPage->m_TitleStringCtrl = new wxTextCtrl( CurrPage, -1, title, - wxDefaultPosition, wxDefaultSize ); - - CurrPage->m_TitleStringCtrl->SetInsertionPoint( 1 ); - CurrPage->m_LowBoxSizer->Add( CurrPage->m_TitleStringCtrl, - 0, - wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, - 5 ); + currPage = AddOneCustomPage( title, command, + (NETLIST_TYPE_ID)(NET_TYPE_CUSTOM1 + ii) ); + m_PanelNetType[PANELCUSTOMBASE + ii] = currPage; } } - -/* - * Browse plugin files, add a new panel - * and set m_CommandStringCtrl field - */ -void NETLIST_DIALOG::AddNewPluginPanel( wxCommandEvent& event ) +NETLIST_PAGE_DIALOG* NETLIST_DIALOG::AddOneCustomPage( const wxString & aTitle, + const wxString & aCommandString, + NETLIST_TYPE_ID aNetTypeId ) { - wxString FullFileName, Mask, Path; + NETLIST_PAGE_DIALOG* currPage; - Mask = wxT( "*" ); - Path = wxGetApp().GetExecutablePath(); - FullFileName = EDA_FileSelector( _( "Plugin files:" ), - Path, - FullFileName, - wxEmptyString, - Mask, - this, - wxFD_OPEN, - true - ); - if( FullFileName.IsEmpty() ) - return; + currPage = new NETLIST_PAGE_DIALOG( m_NoteBook, aTitle, aNetTypeId ); - NETLIST_PAGE_DIALOG* CurrPage; - CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); - if( CurrPage == NULL ) - return; + currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, + -1, _( "Netlist command:" ) ), 0, + wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - // Creates a default command line, suitable for external tool xslproc: - // try to build a default command line depending on plugin extension - wxString cmdLine; - wxFileName fn( FullFileName ); - wxString ext = fn.GetExt(); + currPage->m_CommandStringCtrl = new wxTextCtrl( currPage, -1, aCommandString, + wxDefaultPosition, wxDefaultSize ); - if( ext == wxT("xsl" ) ) - cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) ); - else if( ext == wxT("exe" ) || ext.IsEmpty() ) - cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) ); - else - cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) ); + currPage->m_CommandStringCtrl->SetInsertionPoint( 1 ); + currPage->m_LowBoxSizer->Add( currPage->m_CommandStringCtrl, + 0, + wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); - CurrPage->m_CommandStringCtrl->SetValue( cmdLine ); + currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, + -1, _( "Title:" ) ), 0, + wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - /* Get a title for this page */ - wxString title = CurrPage->m_TitleStringCtrl->GetValue(); + currPage->m_TitleStringCtrl = new wxTextCtrl( currPage, -1, aTitle, + wxDefaultPosition, wxDefaultSize ); - if( title.IsEmpty() ) - DisplayInfoMessage( this, - _( "Do not forget to choose a title for this netlist control page" ) ); + currPage->m_TitleStringCtrl->SetInsertionPoint( 1 ); + currPage->m_LowBoxSizer->Add( currPage->m_TitleStringCtrl, + 0, + wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, + 5 ); + return currPage; } /* Called when the check box "default format" is clicked */ -void NETLIST_DIALOG::SelectNetlistType( wxCommandEvent& event ) +void NETLIST_DIALOG::SelectDefaultNetlistType( wxCommandEvent& event ) { int ii; - NETLIST_PAGE_DIALOG* CurrPage; + NETLIST_PAGE_DIALOG* currPage; for( ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ ) if( m_PanelNetType[ii] ) m_PanelNetType[ii]->m_IsCurrentFormat->SetValue( false ); - CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); + currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); - if( CurrPage == NULL ) + if( currPage == NULL ) return; - m_Parent->SetNetListFormatName( CurrPage->GetPageNetFmtName() ); - CurrPage->m_IsCurrentFormat->SetValue( true ); + m_Parent->SetNetListFormatName( currPage->GetPageNetFmtName() ); + currPage->m_IsCurrentFormat->SetValue( true ); } +/* Called when a netlist type is selected. + * Enable/disable relevant/irrelevant widgets, and display the default + * netlist name, for known types + */ +void NETLIST_DIALOG::OnNetlistTypeSelection( wxNotebookEvent& event ) +{ + NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); + if( currPage == NULL ) + return; + + m_buttonDelPlugin->Enable( currPage->m_IdNetType >= NET_TYPE_CUSTOM1 ); + m_cbUseDefaultNetlistName->Enable( currPage->m_IdNetType < NET_TYPE_CUSTOM1 ); + + wxString fileExt; + if( ReturnFilenamePrms( currPage->m_IdNetType, &fileExt, NULL ) ) + { + wxFileName fn = g_RootSheet->GetScreen()->GetFileName(); + fn.SetExt( fileExt ); + m_textCtrlDefaultFileName->SetValue( fn.GetFullName() ); + } + else + m_textCtrlDefaultFileName->Clear(); +} /* Called when the check box m_AddSubPrefix * "default format" is clicked @@ -505,14 +406,14 @@ void NETLIST_DIALOG::SelectNetlistType( wxCommandEvent& event ) void NETLIST_DIALOG::EnableSubcircuitPrefix( wxCommandEvent& event ) { - NETLIST_PAGE_DIALOG* CurrPage; + NETLIST_PAGE_DIALOG* currPage; - CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); + currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); - if( CurrPage == NULL || CurrPage->m_AddSubPrefix == NULL ) + if( currPage == NULL || currPage->m_AddSubPrefix == NULL ) return; - m_Parent->SetAddReferencePrefix( CurrPage->m_AddSubPrefix->IsChecked() ); + m_Parent->SetAddReferencePrefix( currPage->m_AddSubPrefix->IsChecked() ); } void NETLIST_DIALOG::NetlistUpdateOpt() @@ -553,24 +454,92 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) NetlistUpdateOpt(); - NETLIST_PAGE_DIALOG* CurrPage; - CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); + NETLIST_PAGE_DIALOG* currPage; + currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); unsigned netlist_opt = 0; /* Calculate the netlist filename */ fn = g_RootSheet->GetScreen()->GetFileName(); + ReturnFilenamePrms( currPage->m_IdNetType, &fileExt, &fileWildcard ); - switch( CurrPage->m_IdNetType ) + // Set some parameters + switch( currPage->m_IdNetType ) + { + case NET_TYPE_SPICE: + // Set spice netlist options: + if( g_OptNetListUseNames ) + netlist_opt |= NET_USE_NETNAMES; + if( currPage->m_AddSubPrefix->GetValue() ) + netlist_opt |= NET_USE_X_PREFIX; + break; + + case NET_TYPE_CADSTAR: + break; + + case NET_TYPE_PCBNEW: + if( currPage->m_NetOption->GetSelection() != 0 ) + netlist_opt = NET_PCBNEW_USE_NEW_FORMAT; + break; + + case NET_TYPE_ORCADPCB2: + break; + + default: // custom, NET_TYPE_CUSTOM1 and greater + title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue().GetData() ); + } + + fn.SetExt( fileExt ); + wxString fullfilname = fn.GetFullName(); + + if( !GetUseDefaultNetlistName() || currPage->m_IdNetType >= NET_TYPE_CUSTOM1 ) + { + wxFileDialog dlg( this, title, fn.GetPath(), + fullfilname, fileWildcard, + wxFD_SAVE ); + + if( dlg.ShowModal() == wxID_CANCEL ) + return; + + fullfilname = dlg.GetPath(); + } + + m_Parent->ClearMsgPanel(); + + if( currPage->m_CommandStringCtrl ) + m_Parent->SetNetListerCommand( currPage->m_CommandStringCtrl->GetValue() ); + else + m_Parent->SetNetListerCommand( wxEmptyString ); + + m_Parent->CreateNetlist( currPage->m_IdNetType, fullfilname, netlist_opt ); + + WriteCurrentNetlistSetup(); + + EndModal( wxID_OK ); +} + +/** + * Function ReturnFilenamePrms + * returns the filename extension and the wildcard string for this curr + * or a void name if there is no default name + * @param aNetTypeId = the netlist type ( NET_TYPE_PCBNEW ... ) + * @param aExt = a reference to a wxString to return the defaut file ext. + * @param aWildCard = reference to a wxString to return the defaut wildcard. + * @return true for known netlist type, false for custom formats + */ +bool NETLIST_DIALOG::ReturnFilenamePrms( NETLIST_TYPE_ID aNetTypeId, + wxString * aExt, wxString * aWildCard ) +{ + wxString fileExt; + wxString fileWildcard; + + bool ret = true; + + switch( aNetTypeId ) { case NET_TYPE_SPICE: fileExt = wxT( "cir" ); fileWildcard = _( "SPICE netlist file (.cir)|*.cir" ); - // Set spice netlist options: - if( g_OptNetListUseNames ) - netlist_opt |= NET_USE_NETNAMES; - if( CurrPage->m_AddSubPrefix->GetValue() ) - netlist_opt |= NET_USE_X_PREFIX; break; case NET_TYPE_CADSTAR: @@ -579,47 +548,25 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) break; case NET_TYPE_PCBNEW: - if( CurrPage->m_NetOption->GetSelection() != 0 ) - netlist_opt = NET_PCBNEW_USE_NEW_FORMAT; - fileExt = NetlistFileExtension; - fileWildcard = NetlistFileWildcard; - break; - case NET_TYPE_ORCADPCB2: fileExt = NetlistFileExtension; fileWildcard = NetlistFileWildcard; break; default: // custom, NET_TYPE_CUSTOM1 and greater - fileExt = wxEmptyString; fileWildcard = AllFilesWildcard; - title.Printf( _( "%s Export" ), CurrPage->m_TitleStringCtrl->GetValue().GetData() ); + ret = false; } - fn.SetExt( fileExt ); + if( aExt ) + *aExt = fileExt; - wxFileDialog dlg( this, title, fn.GetPath(), - fn.GetFullName(), fileWildcard, - wxFD_SAVE ); + if( aWildCard ) + *aWildCard = fileWildcard; - if( dlg.ShowModal() == wxID_CANCEL ) - return; - - m_Parent->ClearMsgPanel(); - - if( CurrPage->m_CommandStringCtrl ) - m_Parent->SetNetListerCommand( CurrPage->m_CommandStringCtrl->GetValue() ); - else - m_Parent->SetNetListerCommand( wxEmptyString ); - - m_Parent->CreateNetlist( CurrPage->m_IdNetType, dlg.GetPath(), netlist_opt ); - - WriteCurrentNetlistSetup(); - - EndModal( NET_OK ); + return ret; } - /* Function CreateNetlist * > test for some issues (missing or duplicate references and sheet names) * > build netlist info @@ -670,7 +617,7 @@ Do you want to annotate schematic?" ) ) ) void NETLIST_DIALOG::OnCancelClick( wxCommandEvent& event ) { - EndModal( NET_ABORT ); + EndModal( wxID_CANCEL ); } @@ -691,19 +638,19 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) fn.SetExt( wxT( "cir" ) ); CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" ); - NETLIST_PAGE_DIALOG* CurrPage; - CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); - g_OptNetListUseNames = CurrPage->m_NetOption->GetSelection() == 0; + NETLIST_PAGE_DIALOG* currPage; + currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); + g_OptNetListUseNames = currPage->m_NetOption->GetSelection() == 0; // Set spice netlist options: unsigned netlist_opt = 0; if( g_OptNetListUseNames ) netlist_opt |= NET_USE_NETNAMES; - if( CurrPage->m_AddSubPrefix && CurrPage->m_AddSubPrefix->GetValue() ) + if( currPage->m_AddSubPrefix && currPage->m_AddSubPrefix->GetValue() ) netlist_opt |= NET_USE_X_PREFIX; - if( ! m_Parent->CreateNetlist( CurrPage->m_IdNetType, fn.GetFullPath(), + if( ! m_Parent->CreateNetlist( currPage->m_IdNetType, fn.GetFullPath(), netlist_opt ) ) return; @@ -718,59 +665,60 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) { wxString msg, Command; - wxConfig* config = wxGetApp().GetSettings(); NetlistUpdateOpt(); + m_Config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() ); + // Update the new titles for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) { - NETLIST_PAGE_DIALOG* CurrPage = m_PanelNetType[ii + PANELCUSTOMBASE]; + NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE]; - if( CurrPage == NULL ) + if( currPage == NULL ) break; msg = wxT( "Custom" ); msg << ii + 1; - if( CurrPage->m_TitleStringCtrl ) + if( currPage->m_TitleStringCtrl ) { - wxString title = CurrPage->m_TitleStringCtrl->GetValue(); - CurrPage->SetPageNetFmtName( title ); + wxString title = currPage->m_TitleStringCtrl->GetValue(); + currPage->SetPageNetFmtName( title ); if( msg != title ) // Title has changed, Update config { msg = CUSTOM_NETLIST_TITLE; msg << ii + 1; - config->Write( msg, title ); + m_Config->Write( msg, title ); } } - if( CurrPage->m_CommandStringCtrl ) + if( currPage->m_CommandStringCtrl ) { - Command = CurrPage->m_CommandStringCtrl->GetValue(); + Command = currPage->m_CommandStringCtrl->GetValue(); msg = CUSTOM_NETLIST_COMMAND; msg << ii + 1; - config->Write( msg, Command ); + m_Config->Write( msg, Command ); } } } /** - * Function DeletePluginPanel + * Function OnDelPlugin * Remove a panel relative to a netlist plugin */ -void NETLIST_DIALOG::DeletePluginPanel( wxCommandEvent& event ) +void NETLIST_DIALOG::OnDelPlugin( wxCommandEvent& event ) { - NETLIST_PAGE_DIALOG* CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); + NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); - CurrPage->m_CommandStringCtrl->SetValue( wxEmptyString ); - CurrPage->m_TitleStringCtrl->SetValue( wxEmptyString ); + currPage->m_CommandStringCtrl->SetValue( wxEmptyString ); + currPage->m_TitleStringCtrl->SetValue( wxEmptyString ); - if( CurrPage->m_IsCurrentFormat->IsChecked() ) + if( currPage->m_IsCurrentFormat->IsChecked() ) { - CurrPage->m_IsCurrentFormat->SetValue( false ); + currPage->m_IsCurrentFormat->SetValue( false ); m_PanelNetType[PANELPCBNEW]->m_IsCurrentFormat->SetValue( true ); } @@ -778,27 +726,119 @@ void NETLIST_DIALOG::DeletePluginPanel( wxCommandEvent& event ) EndModal( NET_PLUGIN_CHANGE ); } - /** - * Function ValidatePluginPanel - * Validate the panel info relative to a new netlist plugin + * Function OnAddPlugin + * Add a new panel for a new netlist plugin */ -void NETLIST_DIALOG::ValidatePluginPanel( wxCommandEvent& event ) +void NETLIST_DIALOG::OnAddPlugin( wxCommandEvent& event ) { - NETLIST_PAGE_DIALOG* CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); - - if( CurrPage->m_CommandStringCtrl->GetValue() == wxEmptyString ) - { - DisplayError( this, _( "Error. You must provide a command String" ) ); - return; - } - - if( CurrPage->m_TitleStringCtrl->GetValue() == wxEmptyString ) - { - DisplayError( this, _( "Error. You must provide a Title" ) ); + NETLIST_DIALOG_ADD_PLUGIN dlg( this ); + if( dlg.ShowModal() != wxID_OK ) return; + + // Creates a new custom plugin page + wxString title = dlg.GetPluginTitle(); + + // Verify it does not exists + int netTypeId = PANELCUSTOMBASE; // the first not used type id + NETLIST_PAGE_DIALOG* currPage; + for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) + { + netTypeId = PANELCUSTOMBASE + ii; + currPage = m_PanelNetType[ii + PANELCUSTOMBASE]; + + if( currPage == NULL ) + break; + + if( currPage->GetPageNetFmtName() == title ) + { + wxMessageBox( _("This plugin already exists. Abort") ); + return; + } } + wxString cmd = dlg.GetPluginTCommandLine(); + currPage = AddOneCustomPage( title,cmd, (NETLIST_TYPE_ID)netTypeId ); + m_PanelNetType[netTypeId] = currPage; WriteCurrentNetlistSetup(); + + // Close and reopen dialog to rebuild the dialog after changes EndModal( NET_PLUGIN_CHANGE ); } + + +NETLIST_DIALOG_ADD_PLUGIN::NETLIST_DIALOG_ADD_PLUGIN( NETLIST_DIALOG* parent ) : + NETLIST_DIALOG_ADD_PLUGIN_BASE( parent ) +{ + m_Parent = parent; + GetSizer()->SetSizeHints( this ); +} + +/** + * Function OnOKClick + * Validate info relative to a new netlist plugin + */ +void NETLIST_DIALOG_ADD_PLUGIN::OnOKClick( wxCommandEvent& event ) +{ + if( m_textCtrlCommand->GetValue() == wxEmptyString ) + { + wxMessageBox( _( "Error. You must provide a command String" ) ); + return; + } + + if( m_textCtrlName->GetValue() == wxEmptyString ) + { + wxMessageBox( _( "Error. You must provide a Title" ) ); + return; + } + + EndModal( wxID_OK ); +} + +void NETLIST_DIALOG_ADD_PLUGIN::OnCancelClick( wxCommandEvent& event ) +{ + EndModal( wxID_CANCEL ); +} + +/* + * Browse plugin files, and set m_CommandStringCtrl field + */ +void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) +{ + wxString FullFileName, Mask, Path; + + Mask = wxT( "*" ); + Path = wxGetApp().GetExecutablePath(); + FullFileName = EDA_FileSelector( _( "Plugin files:" ), + Path, + FullFileName, + wxEmptyString, + Mask, + this, + wxFD_OPEN, + true + ); + if( FullFileName.IsEmpty() ) + return; + + // Creates a default command line, suitable for external tool xslproc: + // try to build a default command line depending on plugin extension + wxString cmdLine; + wxFileName fn( FullFileName ); + wxString ext = fn.GetExt(); + + if( ext == wxT("xsl" ) ) + cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) ); + else if( ext == wxT("exe" ) || ext.IsEmpty() ) + cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) ); + else + cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) ); + + m_textCtrlCommand->SetValue( cmdLine ); + + /* Get a title for this page */ + wxString title = m_textCtrlName->GetValue(); + + if( title.IsEmpty() ) + wxMessageBox( _( "Do not forget to choose a title for this netlist control page" ) ); +} diff --git a/eeschema/netlist_control.h b/eeschema/netlist_control.h index 64dcbf392e..d4bea729c3 100644 --- a/eeschema/netlist_control.h +++ b/eeschema/netlist_control.h @@ -1,24 +1,52 @@ -/***************************************************************************** +/** + * @file netlist_control.h + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. * - * netlist_control.h + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr + * Copyright (C) 2011 Wayne Stambaugh + * Copyright (C) 1992-2012 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ #ifndef _NETLIST_CONTROL_H_ #define _NETLIST_CONTROL_H_ +#include -/* Event id for notebook page buttons: */ -enum id_netlist { - ID_CREATE_NETLIST = 1550, - ID_CURRENT_FORMAT_IS_DEFAULT, - ID_RUN_SIMULATOR, - ID_SETUP_PLUGIN, - ID_VALIDATE_PLUGIN, - ID_DELETE_PLUGIN, - ID_NETLIST_NOTEBOOK, - ID_CHANGE_NOTEBOOK_PAGE, - ID_ADD_SUBCIRCUIT_PREFIX, +#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins + +// Id to select netlist type +enum NETLIST_TYPE_ID { + NET_TYPE_UNINIT = 0, + NET_TYPE_PCBNEW, + NET_TYPE_ORCADPCB2, + NET_TYPE_CADSTAR, + NET_TYPE_SPICE, + NET_TYPE_CUSTOM1, /* NET_TYPE_CUSTOM1 + * is the first id for user netlist format + * NET_TYPE_CUSTOM1+CUSTOMPANEL_COUNTMAX-1 + * is the last id for user netlist format + */ + NET_TYPE_CUSTOM_MAX = NET_TYPE_CUSTOM1 + CUSTOMPANEL_COUNTMAX - 1 }; /* panel (notebook page) identifiers */ @@ -31,19 +59,17 @@ enum panel_netlist_index { * others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */ }; -/* Values returned when the netlist dialog is demiss */ -enum gen_netlist_diag { - NET_OK, - NET_ABORT, - NET_PLUGIN_CHANGE -}; +// Values returned when the netlist dialog is demiss +#define NET_PLUGIN_CHANGE 1 +// other values in use are wxID_OK and wxID_CANCEL + /* wxPanels for creating the NoteBook pages for each netlist format: */ class NETLIST_PAGE_DIALOG : public wxPanel { public: - int m_IdNetType; + NETLIST_TYPE_ID m_IdNetType; wxCheckBox* m_IsCurrentFormat; wxCheckBox* m_AddSubPrefix; wxTextCtrl* m_CommandStringCtrl; @@ -63,11 +89,9 @@ public: * @param parent = wxNotebook * parent * @param title = title (name) of the notebook page * @param id_NetType = netlist type id - * @param idCheckBox = event ID attached to the "format is default" check box - * @param idCreateFile = event ID attached to the "create netlist" button */ NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title, - int id_NetType, int idCheckBox, int idCreateFile ); + NETLIST_TYPE_ID id_NetType ); ~NETLIST_PAGE_DIALOG() { }; /** @@ -79,27 +103,10 @@ public: */ const wxString GetPageNetFmtName(); - void SetPageNetFmtName( const wxString &aName ) { m_pageNetFmtName =aName; } + void SetPageNetFmtName( const wxString &aName ) { m_pageNetFmtName = aName; } }; -#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins - -// Id to select netlist type -enum TypeNetForm { - NET_TYPE_UNINIT = 0, - NET_TYPE_PCBNEW, - NET_TYPE_ORCADPCB2, - NET_TYPE_CADSTAR, - NET_TYPE_SPICE, - NET_TYPE_CUSTOM1, /* NET_TYPE_CUSTOM1 - * is the first id for user netlist format - * NET_TYPE_CUSTOM1+CUSTOMPANEL_COUNTMAX-1 - * is the last id for user netlist format - */ - NET_TYPE_CUSTOM_MAX = NET_TYPE_CUSTOM1 + CUSTOMPANEL_COUNTMAX - 1 -}; - // Options for Spice netlist generation (OR'ed bits enum netlistOptions { NET_USE_NETNAMES = 1, // for Spice netlist : use netnames instead of numbers @@ -108,14 +115,16 @@ enum netlistOptions { }; /* Dialog frame for creating netlists */ -class NETLIST_DIALOG : public wxDialog +class NETLIST_DIALOG : public NETLIST_DIALOG_BASE { public: SCH_EDIT_FRAME* m_Parent; wxString m_NetFmtName; - wxNotebook* m_NoteBook; NETLIST_PAGE_DIALOG* m_PanelNetType[4 + CUSTOMPANEL_COUNTMAX]; +private: + wxConfig* m_Config; + public: // Constructor and destructor @@ -124,20 +133,73 @@ public: private: void InstallCustomPages(); + NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle, + const wxString & aCommandString, + NETLIST_TYPE_ID aNetTypeId ); void InstallPageSpice(); void GenNetlist( wxCommandEvent& event ); void RunSimulator( wxCommandEvent& event ); void NetlistUpdateOpt(); void OnCancelClick( wxCommandEvent& event ); - void SelectNetlistType( wxCommandEvent& event ); + void OnNetlistTypeSelection( wxNotebookEvent& event ); + void SelectDefaultNetlistType( wxCommandEvent& event ); void EnableSubcircuitPrefix( wxCommandEvent& event ); - void AddNewPluginPanel( wxCommandEvent& event ); - void DeletePluginPanel( wxCommandEvent& event ); - void ValidatePluginPanel( wxCommandEvent& event ); + void OnAddPlugin( wxCommandEvent& event ); + void OnDelPlugin( wxCommandEvent& event ); void WriteCurrentNetlistSetup( void ); + bool GetUseDefaultNetlistName() + { + return m_cbUseDefaultNetlistName->IsChecked(); + } + + /** + * Function ReturnUserNetlistTypeName + * to retrieve user netlist type names + * @param first_item = true: return first name of the list, false = return next + * @return a wxString : name of the type netlist or empty string + * this function must be called first with "first_item" = true + * and after with "first_item" = false to get all the other existing netlist names + */ + const wxString ReturnUserNetlistTypeName( bool first_item ); + + /** + * Function ReturnFilenamePrms + * returns the filename extension and the wildcard string for this curr + * or a void name if there is no default name + * @param aNetTypeId = the netlist type ( NET_TYPE_PCBNEW ... ) + * @param aExt = a reference to a wxString to return the defaut file ext. + * @param aWildCard = reference to a wxString to return the defaut wildcard. + * @return true for known netlist type, false for custom formats + */ + bool ReturnFilenamePrms( NETLIST_TYPE_ID aNetTypeId, + wxString * aExt, wxString * aWildCard ); + DECLARE_EVENT_TABLE() }; + +class NETLIST_DIALOG_ADD_PLUGIN : public NETLIST_DIALOG_ADD_PLUGIN_BASE +{ +private: + NETLIST_DIALOG* m_Parent; + +public: + NETLIST_DIALOG_ADD_PLUGIN( NETLIST_DIALOG* parent ); + const wxString GetPluginTitle() + { + return m_textCtrlName->GetValue(); + } + const wxString GetPluginTCommandLine() + { + return m_textCtrlCommand->GetValue(); + } + +private: + void OnOKClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnBrowsePlugins( wxCommandEvent& event ); +}; + #endif /* _NETLIST_CONTROL_H_ */ diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 824f9fd5b9..4598512775 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -338,22 +338,8 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree // Compute the outlines of the segment, and creates a polygon - corner = wxPoint( 0, radius ); - RotatePoint( &corner, -delta_angle ); - corner += startp; - polypoint.x = corner.x; - polypoint.y = corner.y; - aCornerBuffer.push_back( polypoint ); - - corner = wxPoint( seg_len, radius ); - RotatePoint( &corner, -delta_angle ); - corner += startp; - polypoint.x = corner.x; - polypoint.y = corner.y; - aCornerBuffer.push_back( polypoint ); - // add right rounded end: - for( int ii = delta; ii < 1800; ii += delta ) + for( int ii = 0; ii < 1800; ii += delta ) { corner = wxPoint( 0, radius ); RotatePoint( &corner, ii ); @@ -365,6 +351,7 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, aCornerBuffer.push_back( polypoint ); } + // Finish arc: corner = wxPoint( seg_len, -radius ); RotatePoint( &corner, -delta_angle ); corner += startp; @@ -372,15 +359,8 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, polypoint.y = corner.y; aCornerBuffer.push_back( polypoint ); - corner = wxPoint( 0, -radius ); - RotatePoint( &corner, -delta_angle ); - corner += startp; - polypoint.x = corner.x; - polypoint.y = corner.y; - aCornerBuffer.push_back( polypoint ); - // add left rounded end: - for( int ii = delta; ii < 1800; ii += delta ) + for( int ii = 0; ii < 1800; ii += delta ) { corner = wxPoint( 0, -radius ); RotatePoint( &corner, ii ); @@ -391,6 +371,14 @@ void TransformRoundedEndsSegmentToPolygon( std::vector & aCornerBuffer, aCornerBuffer.push_back( polypoint ); } + // Finish arc: + corner = wxPoint( 0, radius ); + RotatePoint( &corner, -delta_angle ); + corner += startp; + polypoint.x = corner.x; + polypoint.y = corner.y; + aCornerBuffer.push_back( polypoint ); + aCornerBuffer.back().end_contour = true; } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index a02fb14ff5..a8da80bab7 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -335,10 +335,10 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH { // If there's no intrusion and DRC is active, we pass the cursor // "as is", and let ShowNewTrackWhenMovingCursor figure out what to do. - if( !Drc_On || !g_CurrentTrackSegment - || (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() - || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, - GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) ) + if( !Drc_On || !g_CurrentTrackSegment || + (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() || + !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, + GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) ) { GetScreen()->SetCrossHairPosition( curs_pos, snapToGrid ); } @@ -350,7 +350,7 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH pos = GetScreen()->GetCrossHairPosition(); GetScreen()->SetCrossHairPosition( oldpos, false ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( pos, false ); + GetScreen()->SetCrossHairPosition( pos, snapToGrid ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 8879da732e..cba561e225 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -5,7 +5,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2011 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2011 Jean-Pierre Charras * Copyright (C) 2012 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * @@ -267,15 +267,12 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() m_ReferenceCtrl->SetValue( m_ReferenceCopy->m_Text ); m_ValueCtrl->SetValue( m_ValueCopy->m_Text ); - -#if wxCHECK_VERSION( 2, 8, 0 ) m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) ); m_AttributsCtrl->SetItemToolTip( 1, _( "Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) ); m_AttributsCtrl->SetItemToolTip( 2, _( "Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) ); -#endif /* Controls on right side of the dialog */ switch( m_CurrentModule->m_Attributs & 255 ) @@ -299,12 +296,12 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() m_AutoPlaceCtrl->SetSelection( (m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 ); -#if wxCHECK_VERSION( 2, 8, 0 ) + m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) ); m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) ); -#endif + m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 ); m_CostRot180Ctrl->SetValue( m_CurrentModule->m_CntRot180 ); @@ -349,7 +346,7 @@ void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay( } else { - S3D_Vertex dummy_vertex; + S3D_VERTEX dummy_vertex; dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0; m_3D_Scale->SetValue( dummy_vertex ); } @@ -474,6 +471,10 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) } S3D_MASTER* new3DShape = new S3D_MASTER( NULL ); +#ifdef __WINDOWS__ + // Store filename in Unix notation + shortfilename.Replace( wxT( "\\" ), wxT( "/" ) ); +#endif new3DShape->m_Shape3DName = shortfilename; m_Shapes3D_list.push_back( new3DShape ); m_3D_ShapeNameListBox->Append( shortfilename ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index a823a69760..16157b3f72 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -4,6 +4,32 @@ * @brief Dialog for editing a module properties in module editor (modedit) */ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2011 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr + * Copyright (C) 2012 Dick Hollenbeck, dick@softplc.com + * Copyright (C) 2004-2011 KiCad Developers, see change_log.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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + #include #include #include @@ -199,7 +225,7 @@ void DIALOG_MODULE_MODULE_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStru } else { - S3D_Vertex dummy_vertex; + S3D_VERTEX dummy_vertex; dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0; m_3D_Scale->SetValue( dummy_vertex ); } @@ -316,6 +342,11 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) } S3D_MASTER* new3DShape = new S3D_MASTER(NULL); +#ifdef __WINDOWS__ + // Store filename in Unix notation + shortfilename.Replace( wxT( "\\" ), wxT( "/" ) ); +#endif + new3DShape->m_Shape3DName = shortfilename; m_Shapes3D_list.push_back( new3DShape ); m_3D_ShapeNameListBox->Append( shortfilename ); diff --git a/pcbnew/dialogs/dialog_export_3Dfiles_base.fbp b/pcbnew/dialogs/dialog_export_3Dfiles_base.fbp index f48396c50a..ba97d1ac4d 100644 --- a/pcbnew/dialogs/dialog_export_3Dfiles_base.fbp +++ b/pcbnew/dialogs/dialog_export_3Dfiles_base.fbp @@ -1,6 +1,6 @@ - + C++