7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

More NULL expunging.

This commit is contained in:
Wayne Stambaugh 2021-07-18 10:06:48 -04:00
parent 6001ac0704
commit 4c457b5ed3
63 changed files with 2501 additions and 2639 deletions

View File

@ -154,10 +154,10 @@ private:
if( nextZ )
nextZ->prevZ = prevZ;
next = NULL;
prev = NULL;
nextZ = NULL;
prevZ = NULL;
next = nullptr;
prev = nullptr;
nextZ = nullptr;
prevZ = nullptr;
}
void updateOrder()

View File

@ -139,7 +139,7 @@ public:
virtual SHAPE* Clone() const
{
assert( false );
return NULL;
return nullptr;
};
/**

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -275,7 +276,7 @@ public:
const query_iterator qend()
{
return query_iterator( m_shapes.end(), m_shapes.end(), NULL, 0, false );
return query_iterator( m_shapes.end(), m_shapes.end(), nullptr, 0, false );
}
iterator begin()

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
@ -30,6 +30,7 @@
#include <geometry/shape.h>
#include <geometry/shape_file_io.h>
SHAPE_FILE_IO::SHAPE_FILE_IO()
{
m_groupActive = false;
@ -37,6 +38,7 @@ SHAPE_FILE_IO::SHAPE_FILE_IO()
m_file = stdout;
}
SHAPE_FILE_IO::SHAPE_FILE_IO( const std::string& aFilename, SHAPE_FILE_IO::IO_MODE aMode )
{
m_groupActive = false;
@ -54,7 +56,7 @@ SHAPE_FILE_IO::SHAPE_FILE_IO( const std::string& aFilename, SHAPE_FILE_IO::IO_MO
}
else
{
m_file = NULL;
m_file = nullptr;
}
m_mode = aMode;
@ -84,7 +86,7 @@ SHAPE* SHAPE_FILE_IO::Read()
do {
if (fscanf(m_file, "%s", tmp) != 1)
return NULL;
return nullptr;
if( !strcmp( tmp, "shape" )
break;
@ -92,7 +94,7 @@ SHAPE* SHAPE_FILE_IO::Read()
int type;
SHAPE *rv = NULL;
SHAPE *rv = nullptr;
fscanf(m_file,"%d %s", &type, tmp);
@ -104,14 +106,14 @@ SHAPE* SHAPE_FILE_IO::Read()
}
if(!rv)
return NULL;
return nullptr;
rv.Parse ( )
fprintf(m_file,"shape %d %s %s\n", aShape->Type(), aName.c_str(), sh.c_str() );
*/
assert( false );
return NULL;
return nullptr;
}

View File

@ -105,7 +105,7 @@ SHAPE* SHAPE_POLY_SET::Clone() const
bool SHAPE_POLY_SET::GetRelativeIndices( int aGlobalIdx,
SHAPE_POLY_SET::VERTEX_INDEX* aRelativeIndices ) const
SHAPE_POLY_SET::VERTEX_INDEX* aRelativeIndices ) const
{
int polygonIdx = 0;
unsigned int contourIdx = 0;
@ -652,7 +652,8 @@ void SHAPE_POLY_SET::booleanOp( ClipperLib::ClipType aType, const SHAPE_POLY_SET
CLIPPER_Z_VALUE zval = newIntersectPoints.at( pt );
// Fixup arc end points to match the new intersection points found in clipper
//@todo consider editing the intersection point to be the "true" arc intersection
// @todo consider editing the intersection point to be the "true" arc
// intersection.
if( poly[i].IsSharedPt( j ) )
{
poly[i].amendArcEnd( shape.first, pt );
@ -845,7 +846,7 @@ struct FractureEdge
{
FractureEdge( int y = 0 ) :
m_connected( false ),
m_next( NULL )
m_next( nullptr )
{
m_p1.x = m_p2.y = y;
}
@ -854,7 +855,7 @@ struct FractureEdge
m_connected( connected ),
m_p1( p1 ),
m_p2( p2 ),
m_next( NULL )
m_next( nullptr )
{
}
@ -880,7 +881,7 @@ static int processEdge( FractureEdgeSet& edges, FractureEdge* edge )
int min_dist = std::numeric_limits<int>::max();
int x_nearest = 0;
FractureEdge* e_nearest = NULL;
FractureEdge* e_nearest = nullptr;
for( FractureEdge* e : edges )
{
@ -951,7 +952,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths )
{
FractureEdgeSet edges;
FractureEdgeSet border_edges;
FractureEdge* root = NULL;
FractureEdge* root = nullptr;
bool first = true;
@ -965,7 +966,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths )
const std::vector<VECTOR2I>& points = path.CPoints();
int pointCount = points.size();
FractureEdge* prev = NULL, * first_edge = NULL;
FractureEdge* prev = nullptr, * first_edge = nullptr;
int x_min = std::numeric_limits<int>::max();
@ -980,7 +981,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths )
// Do not use path.CPoint() here; open-coding it using the local variables "points"
// and "pointCount" gives a non-trivial performance boost to zone fill times.
FractureEdge* fe = new FractureEdge( first, points[ i ],
points[ i+1 == pointCount ? 0 : i+1 ] );
points[ i+1 == pointCount ? 0 : i+1 ] );
if( !root )
root = fe;
@ -1015,7 +1016,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths )
{
int x_min = std::numeric_limits<int>::max();
FractureEdge* smallestX = NULL;
FractureEdge* smallestX = nullptr;
// find the left-most hole edge and merge with the outline
for( FractureEdge* border_edge : border_edges )
@ -1274,7 +1275,7 @@ int SHAPE_POLY_SET::NormalizeAreaOutlines()
Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
// If any hole, substract it to main outline
// If any hole, subtract it to main outline
if( holesBuffer.OutlineCount() )
{
holesBuffer.Simplify( SHAPE_POLY_SET::PM_FAST );
@ -2022,7 +2023,8 @@ SHAPE_POLY_SET SHAPE_POLY_SET::Fillet( int aRadius, int aErrorMax )
SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon( CORNER_MODE aMode,
unsigned int aDistance, int aIndex, int aErrorMax )
unsigned int aDistance,
int aIndex, int aErrorMax )
{
// Null segments create serious issues in calculations. Remove them:
RemoveNullSegments();
@ -2204,6 +2206,7 @@ SHAPE_POLY_SET &SHAPE_POLY_SET::operator=( const SHAPE_POLY_SET& aOther )
return *this;
}
MD5_HASH SHAPE_POLY_SET::GetHash() const
{
if( !m_hash.IsValid() )
@ -2323,7 +2326,7 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition )
if( aPartition )
{
// This partitions into regularly-sized grids (1cm in pcbnew)
// This partitions into regularly-sized grids (1cm in Pcbnew)
SHAPE_POLY_SET flattened( *this );
flattened.ClearArcs();
partitionPolyIntoRegularCellGrid( flattened, 1e7, tmpSet );
@ -2344,7 +2347,7 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition )
m_triangulatedPolys.push_back( std::make_unique<TRIANGULATED_POLYGON>() );
PolygonTriangulation tess( *m_triangulatedPolys.back() );
// If the tesselation fails, we re-fracture the polygon, which will
// If the tessellation fails, we re-fracture the polygon, which will
// first simplify the system before fracturing and removing the holes
// This may result in multiple, disjoint polygons.
if( !tess.TesselatePolygon( tmpSet.Polygon( 0 ).front() ) )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 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
@ -41,7 +41,7 @@ bool KIPLATFORM::APP::Init()
{
#if !defined( KICAD_SHOW_GTK_MESSAGES )
// Attach a logger that will consume the annoying GTK error messages
g_log_set_writer_func( nullLogWriter, NULL, NULL );
g_log_set_writer_func( nullLogWriter, nullptr, nullptr );
#endif
return true;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Ian McInerney <Ian.S.McInerney at ieee.org>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 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
@ -90,7 +90,8 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
{
// This function is based on the code inside the function post_process_ui in gtkfilechooserwidget.c
// This function is based on the code inside the function post_process_ui in
// gtkfilechooserwidget.c
GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( aChoice->m_widget ) );
if( !cells )
@ -101,7 +102,7 @@ void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice )
if( !cell )
return;
g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, NULL );
g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, nullptr );
// Only the list of cells must be freed, the renderer isn't ours to free
g_list_free( cells );
@ -114,7 +115,7 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow )
GtkWidget* widget = static_cast<GtkWidget*>( aWindow->GetHandle() );
if( widget && gtk_check_version( 3, 10, 0 ) == NULL )
if( widget && gtk_check_version( 3, 10, 0 ) == nullptr )
val = gtk_widget_get_scale_factor( widget );
return val;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Ian McInerney <Ian.S.McInerney at ieee.org>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 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
@ -44,10 +44,10 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError )
SHFILEOPSTRUCT fileOp;
::ZeroMemory( &fileOp, sizeof( fileOp ) );
fileOp.hwnd = NULL; // Set to null since there is no progress dialog
fileOp.hwnd = nullptr; // Set to null since there is no progress dialog
fileOp.wFunc = FO_DELETE;
fileOp.pFrom = temp.c_str();
fileOp.pTo = NULL; // Set to to NULL since we aren't moving the file
fileOp.pTo = nullptr; // Set to to NULL since we aren't moving the file
fileOp.fFlags = FOF_ALLOWUNDO | FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT;
int eVal = SHFileOperation( &fileOp );
@ -70,7 +70,7 @@ bool KIPLATFORM::ENV::IsNetworkPath( const wxString& aPath )
wxString KIPLATFORM::ENV::GetDocumentsPath()
{
// If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get()
// If called by a python script in stand-alone (outside KiCad), wxStandardPaths::Get()
// complains about not existing app. so use a dummy app
if( wxTheApp == nullptr )
{
@ -84,7 +84,7 @@ wxString KIPLATFORM::ENV::GetDocumentsPath()
wxString KIPLATFORM::ENV::GetUserConfigPath()
{
// If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get()
// If called by a python script in stand-alone (outside KiCad), wxStandardPaths::Get()
// complains about not existing app. so use a dummy app
if( wxTheApp == nullptr )
{
@ -100,9 +100,9 @@ wxString KIPLATFORM::ENV::GetUserCachePath()
{
// Unfortunately AppData/Local is the closest analog to "Cache" directories of other platforms
// Make sure we dont include the "appinfo" (appended app name)
// Make sure we don't include the "appinfo" (appended app name)
// If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get()
// If called by a python script in stand-alone (outside KiCad), wxStandardPaths::Get()
// complains about not existing app. so use a dummy app
if( wxTheApp == nullptr )
{

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2021 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
@ -118,7 +118,7 @@ namespace SEXPR
}
else if( *it == ')' )
{
return NULL;
return nullptr;
}
else if( *it == '"' )
{

View File

@ -6,7 +6,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
@ -57,7 +57,7 @@ public:
PLEDITOR_PRINTOUT( PL_EDITOR_FRAME* aParent, const wxString& aTitle ) :
wxPrintout( aTitle )
{
wxASSERT( aParent != NULL );
wxASSERT( aParent != nullptr );
m_parent = aParent;
}
@ -93,9 +93,10 @@ public:
if( show )
{
bool centre = false;
if( s_size.x == 0 || s_size.y == 0 )
{
s_size = (m_parent->GetSize() * 3) / 4;
s_size = ( m_parent->GetSize() * 3 ) / 4;
s_pos = wxDefaultPosition;
centre = true;
}
@ -115,6 +116,7 @@ public:
ret = wxPreviewFrame::Show( show );
}
return ret;
}
@ -154,9 +156,7 @@ void PLEDITOR_PRINTOUT::GetPageInfo( int* minPage, int* maxPage,
*maxPage = *selPageTo = 2;
}
/*
* This is the real print function: print the active screen
*/
void PLEDITOR_PRINTOUT::PrintPage( int aPageNum )
{
wxPoint tmp_startvisu;

View File

@ -38,25 +38,39 @@
PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) :
PANEL_PROPERTIES_BASE( aParent ),
m_scintillaTricks( nullptr ),
m_textCtrlTextSizeXBinder( aParent, m_staticTextTsizeX, m_textCtrlTextSizeX, m_TextTextSizeXUnits ),
m_textCtrlTextSizeYBinder( aParent, m_staticTextTsizeY, m_textCtrlTextSizeY, m_TextTextSizeYUnits ),
m_textCtrlConstraintXBinder( aParent, m_staticTextConstraintX, m_textCtrlConstraintX, m_TextConstraintXUnits ),
m_textCtrlConstraintYBinder( aParent, m_staticTextConstraintY, m_textCtrlConstraintY, m_TextConstraintYUnits ),
m_textCtrlTextSizeXBinder( aParent, m_staticTextTsizeX, m_textCtrlTextSizeX,
m_TextTextSizeXUnits ),
m_textCtrlTextSizeYBinder( aParent, m_staticTextTsizeY, m_textCtrlTextSizeY,
m_TextTextSizeYUnits ),
m_textCtrlConstraintXBinder( aParent, m_staticTextConstraintX, m_textCtrlConstraintX,
m_TextConstraintXUnits ),
m_textCtrlConstraintYBinder( aParent, m_staticTextConstraintY, m_textCtrlConstraintY,
m_TextConstraintYUnits ),
m_textCtrlPosXBinder( aParent, m_staticTextPosX, m_textCtrlPosX, m_TextPosXUnits ),
m_textCtrlPosYBinder( aParent, m_staticTextPosY, m_textCtrlPosY, m_TextPosYUnits ),
m_textCtrlEndXBinder( aParent, m_staticTextEndX, m_textCtrlEndX, m_TextEndXUnits ),
m_textCtrlEndYBinder( aParent, m_staticTextEndY, m_textCtrlEndY, m_TextEndYUnits ),
m_textCtrlStepXBinder( aParent, m_staticTextStepX, m_textCtrlStepX, m_TextStepXUnits ),
m_textCtrlStepYBinder( aParent, m_staticTextStepY, m_textCtrlStepY, m_TextStepYUnits ),
m_textCtrlDefaultTextSizeXBinder( aParent, m_staticTextDefTsX, m_textCtrlDefaultTextSizeX, m_TextDefaultTextSizeXUnits ),
m_textCtrlDefaultTextSizeYBinder( aParent, m_staticTextDefTsY, m_textCtrlDefaultTextSizeY, m_TextDefaultTextSizeYUnits ),
m_textCtrlDefaultLineWidthBinder( aParent, m_staticTextDefLineW, m_textCtrlDefaultLineWidth, m_TextDefaultLineWidthUnits ),
m_textCtrlDefaultTextThicknessBinder( aParent, m_staticTextDefTextThickness, m_textCtrlDefaultTextThickness, m_TextDefaultTextThicknessUnits ),
m_textCtrlLeftMarginBinder( aParent, m_staticTextLeftMargin, m_textCtrlLeftMargin, m_TextLeftMarginUnits ),
m_textCtrlRightMarginBinder( aParent, m_staticTextDefRightMargin, m_textCtrlRightMargin, m_TextRightMarginUnits ),
m_textCtrlTopMarginBinder( aParent, m_staticTextTopMargin, m_textCtrlTopMargin, m_TextTopMarginUnits ),
m_textCtrlBottomMarginBinder( aParent, m_staticTextBottomMargin, m_textCtrlBottomMargin, m_TextBottomMarginUnits ),
m_textCtrlThicknessBinder( aParent, m_staticTextThickness, m_textCtrlThickness, m_TextLineThicknessUnits )
m_textCtrlDefaultTextSizeXBinder( aParent, m_staticTextDefTsX, m_textCtrlDefaultTextSizeX,
m_TextDefaultTextSizeXUnits ),
m_textCtrlDefaultTextSizeYBinder( aParent, m_staticTextDefTsY, m_textCtrlDefaultTextSizeY,
m_TextDefaultTextSizeYUnits ),
m_textCtrlDefaultLineWidthBinder( aParent, m_staticTextDefLineW,
m_textCtrlDefaultLineWidth, m_TextDefaultLineWidthUnits ),
m_textCtrlDefaultTextThicknessBinder( aParent, m_staticTextDefTextThickness,
m_textCtrlDefaultTextThickness,
m_TextDefaultTextThicknessUnits ),
m_textCtrlLeftMarginBinder( aParent, m_staticTextLeftMargin, m_textCtrlLeftMargin,
m_TextLeftMarginUnits ),
m_textCtrlRightMarginBinder( aParent, m_staticTextDefRightMargin, m_textCtrlRightMargin,
m_TextRightMarginUnits ),
m_textCtrlTopMarginBinder( aParent, m_staticTextTopMargin, m_textCtrlTopMargin,
m_TextTopMarginUnits ),
m_textCtrlBottomMarginBinder( aParent, m_staticTextBottomMargin, m_textCtrlBottomMargin,
m_TextBottomMarginUnits ),
m_textCtrlThicknessBinder( aParent, m_staticTextThickness, m_textCtrlThickness,
m_TextLineThicknessUnits )
{
m_parent = aParent;
@ -102,7 +116,6 @@ wxSize PROPERTIES_FRAME::GetMinSize() const
}
// Data transfer from general properties to widgets
void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel()
{
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
@ -120,13 +133,17 @@ void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel()
m_textCtrlDefaultTextThicknessBinder.SetDoubleValue(
From_User_Unit( EDA_UNITS::MILLIMETRES, model.m_DefaultTextThickness ) );
m_textCtrlLeftMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetLeftMargin() ) );
m_textCtrlRightMarginBinder.SetDoubleValue(From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetRightMargin() ) );
m_textCtrlTopMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetTopMargin() ) );
m_textCtrlBottomMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetBottomMargin() ) );
m_textCtrlLeftMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES,
model.GetLeftMargin() ) );
m_textCtrlRightMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES,
model.GetRightMargin() ) );
m_textCtrlTopMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES,
model.GetTopMargin() ) );
m_textCtrlBottomMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES,
model.GetBottomMargin() ) );
}
// Data transfer from widgets to general properties
bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral()
{
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
@ -159,7 +176,6 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral()
}
// Data transfer from item to widgets in properties frame
void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
{
if( !aItem )
@ -221,6 +237,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
{
DS_DATA_ITEM_TEXT* item = static_cast<DS_DATA_ITEM_TEXT*>( aItem );
item->m_FullText = item->m_TextBase;
// Replace our '\' 'n' sequence by the EOL char
item->ReplaceAntiSlashSequence();
m_stcText->SetValue( item->m_FullText );
@ -266,6 +283,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON )
{
DS_DATA_ITEM_POLYGONS* item = static_cast<DS_DATA_ITEM_POLYGONS*>( aItem );
// Rotation (poly and text)
msg.Printf( wxT("%.3f"), item->m_Orient );
m_textCtrlRotation->SetValue( msg );
@ -274,6 +292,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
if( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP )
{
DS_DATA_ITEM_BITMAP* item = static_cast<DS_DATA_ITEM_BITMAP*>( aItem );
// select definition in PPI
msg.Printf( wxT("%d"), item->GetPPI() );
m_textCtrlBitmapDPI->SetValue( msg );
@ -284,7 +303,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
m_SizerTextOptions->Show( aItem->GetType() == DS_DATA_ITEM::DS_TEXT );
m_sbSizerEndPosition->Show( aItem->GetType() == DS_DATA_ITEM::DS_SEGMENT
|| aItem->GetType() == DS_DATA_ITEM::DS_RECT );
|| aItem->GetType() == DS_DATA_ITEM::DS_RECT );
m_textCtrlThicknessBinder.Show( aItem->GetType() != DS_DATA_ITEM::DS_BITMAP );
@ -324,13 +343,13 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
// until the frame is resized). Joys of multiplatform dev.
m_swItemProperties->Fit();
#endif
// send a size event to be sure scrollbars will be added/removed as needed
m_swItemProperties->PostSizeEvent();
m_swItemProperties->Refresh();
}
// Event function called by clicking on the OK button
void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event )
{
PL_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PL_SELECTION_TOOL>();
@ -344,6 +363,7 @@ void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event )
{
DS_DATA_ITEM* dataItem = drawItem->GetPeer();
CopyPrmsFromPanelToItem( dataItem );
// Be sure what is displayed is what is set for item
// (mainly, texts can be modified if they contain "\n")
CopyPrmsFromItemToPanel( dataItem );
@ -379,10 +399,9 @@ void PROPERTIES_FRAME::OnSetDefaultValues( wxCommandEvent& event )
}
// Data transfer from properties frame to item parameters
bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
{
if( aItem == NULL )
if( aItem == nullptr )
return false;
wxString msg;
@ -399,7 +418,8 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
}
// Import thickness
aItem->m_LineWidth = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlThicknessBinder.GetValue() );
aItem->m_LineWidth = To_User_Unit( EDA_UNITS::MILLIMETRES,
m_textCtrlThicknessBinder.GetValue() );
// Import Start point
aItem->m_Pos.m_Pos.x = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlPosXBinder.GetValue() );
@ -431,8 +451,10 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
msg.ToLong( &itmp );
aItem->m_RepeatCount = itmp;
aItem->m_IncrementVector.x = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlStepXBinder.GetValue() );
aItem->m_IncrementVector.y = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlStepYBinder.GetValue() );
aItem->m_IncrementVector.x = To_User_Unit( EDA_UNITS::MILLIMETRES,
m_textCtrlStepXBinder.GetValue() );
aItem->m_IncrementVector.y = To_User_Unit( EDA_UNITS::MILLIMETRES,
m_textCtrlStepYBinder.GetValue() );
if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT )
{
@ -456,7 +478,7 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
switch( m_choiceVjustify->GetSelection() )
{
case 0: item->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; break;
case 0: item->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; break;
case 1: item->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; break;
case 2: item->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break;
}

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
* This program is free software; you can redistribute it and/or
@ -49,42 +50,41 @@ static struct IFACE : public KIFACE_I
void OnKifaceEnd() override;
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
int aCtlBits = 0 ) override
{
switch( aClassId )
{
case FRAME_PL_EDITOR:
{
PL_EDITOR_FRAME* frame = new PL_EDITOR_FRAME( aKiway, aParent );
return frame;
}
{
PL_EDITOR_FRAME* frame = new PL_EDITOR_FRAME( aKiway, aParent );
return frame;
break;
}
default:
;
}
return NULL;
return nullptr;
}
/**
* Function IfaceOrAddress
* return a pointer to the requested object. The safest way to use this
* is to retrieve a pointer to a static instance of an interface, similar to
* how the KIFACE interface is exported. But if you know what you are doing
* Return a pointer to the requested object.
*
* The safest way to use this is to retrieve a pointer to a static instance of an interface,
* similar to how the KIFACE interface is exported. But if you know what you are doing
* use it to retrieve anything you want.
*
* @param aDataId identifies which object you want the address of.
*
* @return void* - and must be cast into the know type.
* @return the object requested and must be cast into the know type.
*/
void* IfaceOrAddress( int aDataId ) override
{
return NULL;
return nullptr;
}
/**
* Function SaveFileAs
* Saving a file under a different name is delegated to the various KIFACEs because
* the project doesn't know the internal format of the various files (which may have
* paths in them that need updating).
@ -97,10 +97,13 @@ static struct IFACE : public KIFACE_I
} // namespace
using namespace PGE;
static PGM_BASE* process;
KIFACE_I& Kiface() { return kiface; }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2021 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2021 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
@ -76,13 +76,15 @@ public:
{
// add new item an try to keep alphabetic order,
// and because name have numbers inside, use a KiCad compare function
// that handles number as numbers not ascii chars
// that handles number as numbers not ASCII chars
unsigned ii = 0;
for( ; ii < m_List.size(); ii++ )
{
if( UTIL::RefDesStringCompare( aItem->m_Name, m_List[ii]->m_Name ) < 0 )
break;
}
m_List.insert( m_List.begin() + ii, aItem );
}
@ -95,7 +97,7 @@ public:
return m_List[ii];
}
}
return NULL;
return nullptr;
}
void Remove( const wxString & aRegName )

View File

@ -6,7 +6,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -50,7 +50,7 @@ bool PCB_CALCULATOR_FRAME::ReadDataFile()
{
FILE* file = wxFopen( GetDataFilename(), wxT( "rt" ) );
if( file == NULL )
if( file == nullptr )
return false;
// Switch the locale to standard C (needed to read/write floating point numbers)
@ -84,6 +84,7 @@ bool PCB_CALCULATOR_FRAME::ReadDataFile()
return true;
}
bool PCB_CALCULATOR_FRAME::WriteDataFile()
{
// Switch the locale to standard C (needed to read/write floating point numbers)
@ -117,11 +118,13 @@ PCB_CALCULATOR_DATAFILE::PCB_CALCULATOR_DATAFILE( REGULATOR_LIST * aList )
m_list = aList;
}
static const char* regtype_str[] =
{
"normal", "3terminal"
};
int PCB_CALCULATOR_DATAFILE::WriteHeader( OUTPUTFORMATTER* aFormatter ) const
{
int nestlevel = 0;
@ -141,6 +144,7 @@ void PCB_CALCULATOR_DATAFILE::Format( OUTPUTFORMATTER* aFormatter,
{
// Write regulators list:
aFormatter->Print( aNestLevel++, "(%s\n", getTokenName( T_regulators ) );
for( unsigned ii = 0; ii < m_list->m_List.size(); ii++ )
{
REGULATOR_DATA * item = m_list->m_List[ii];
@ -148,15 +152,18 @@ void PCB_CALCULATOR_DATAFILE::Format( OUTPUTFORMATTER* aFormatter,
aFormatter->Quotew(item->m_Name ).c_str() );
aFormatter->Print( aNestLevel+1, "(%s %g)\n", getTokenName( T_reg_vref ),
item->m_Vref );
if( item->m_Iadj != 0 && item->m_Type == 1)
{
aFormatter->Print( aNestLevel+1, "(%s %g)\n", getTokenName( T_reg_iadj ),
item->m_Iadj );
}
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_reg_type ),
regtype_str[item->m_Type] );
aFormatter->Print( aNestLevel, ")\n" );
}
}
aFormatter->Print( --aNestLevel, ")\n" );
}
@ -167,16 +174,14 @@ void PCB_CALCULATOR_DATAFILE::Parse( PCB_CALCULATOR_DATAFILE_PARSER* aParser )
}
// PCB_CALCULATOR_DATAFILE_PARSER
PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( LINE_READER* aReader ) :
PCB_CALCULATOR_DATAFILE_LEXER( aReader )
{
}
PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, const wxString& aSource ) :
PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine,
const wxString& aSource ) :
PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource )
{
}
@ -185,6 +190,7 @@ PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, con
void PCB_CALCULATOR_DATAFILE_PARSER::Parse( PCB_CALCULATOR_DATAFILE* aDataList )
{
T token;
while( ( token = NextTok() ) != T_EOF)
{
if( token == T_LEFT )
@ -200,6 +206,7 @@ void PCB_CALCULATOR_DATAFILE_PARSER::Parse( PCB_CALCULATOR_DATAFILE* aDataList )
}
}
void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFILE* aDataList )
{
T token;
@ -236,28 +243,34 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL
{
case T_reg_vref: // the voltage reference value
token = NextTok();
if( token != T_NUMBER )
Expecting( T_NUMBER );
sscanf( CurText(), "%lf" , &vref);
NeedRIGHT();
break;
case T_reg_iadj: // the Iadj reference value
token = NextTok();
if( token != T_NUMBER )
Expecting( T_NUMBER );
sscanf( CurText(), "%lf" , &iadj);
NeedRIGHT();
break;
case T_reg_type: // type: normal or 3 terminal reg
token = NextTok();
if( strcasecmp( CurText(), regtype_str[0] ) == 0 )
if( strcasecmp( CurText(), regtype_str[0] ) == 0 )
type = 0;
else if( strcasecmp( CurText(), regtype_str[1] ) == 0 )
type = 1;
else
Unexpected( CurText() );
NeedRIGHT();
break;
@ -271,7 +284,8 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL
{
if( type != 1 )
iadj = 0.0;
REGULATOR_DATA * new_item = new REGULATOR_DATA(name, vref, type, iadj );
REGULATOR_DATA* new_item = new REGULATOR_DATA( name, vref, type, iadj );
aDataList->m_list->Add( new_item );
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2015 jean-pierre.charras
* Copyright (C) 2015 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2021 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
@ -26,10 +26,7 @@
#include "pcb_calculator_settings.h"
// Pcb_calculator data file extension:
const wxString PcbCalcDataFileExt( wxT("pcbcalc") );
// PCB_CALCULATOR_APP
const wxString PcbCalcDataFileExt( wxT( "pcbcalc" ) );
namespace PCBCALC {
@ -46,35 +43,38 @@ static struct IFACE : public KIFACE_I
void OnKifaceEnd() override;
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
int aCtlBits = 0 ) override
{
return new PCB_CALCULATOR_FRAME( aKiway, aParent );
}
/**
* Function IfaceOrAddress
* return a pointer to the requested object. The safest way to use this
* is to retrieve a pointer to a static instance of an interface, similar to
* how the KIFACE interface is exported. But if you know what you are doing
* Return a pointer to the requested object.
*
* The safest way to use this is to retrieve a pointer to a static instance of an interface,
* similar to how the KIFACE interface is exported. But if you know what you are doing
* use it to retrieve anything you want.
*
* @param aDataId identifies which object you want the address of.
*
* @return void* - and must be cast into the know type.
* @return the requested object and must be cast into the know type.
*/
void* IfaceOrAddress( int aDataId ) override
{
return NULL;
return nullptr;
}
} kiface( "pcb_calculator", KIWAY::FACE_PCB_CALCULATOR );
} // namespace
using namespace PCBCALC;
static PGM_BASE* process;
KIFACE_I& Kiface() { return kiface; }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2015 jean-pierre.charras
* Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -28,7 +28,8 @@
// extension of pcb_calculator data filename:
const wxString DataFileNameExt( wxT("pcbcalc") );
const wxString DataFileNameExt( wxT( "pcbcalc" ) );
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
PCB_CALCULATOR_FRAME_BASE( aParent ),
@ -40,9 +41,9 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_bpButtonSynthetize->SetBitmap( KiBitmap( BITMAPS::small_up ) );
SetKiway( this, aKiway );
m_currTransLine = NULL;
m_currTransLine = nullptr;
m_currTransLineType = DEFAULT_TYPE;
m_currAttenuator = NULL;
m_currAttenuator = nullptr;
m_RegulatorListChanged = false;
m_TWMode = TW_MASTER_CURRENT;
m_TWNested = false;
@ -52,16 +53,16 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Populate transline list ordered like in dialog menu list
const static TRANSLINE_TYPE_ID tltype_list[8] =
{
MICROSTRIP_TYPE,
CPW_TYPE,
GROUNDED_CPW_TYPE,
RECTWAVEGUIDE_TYPE,
COAX_TYPE,
C_MICROSTRIP_TYPE,
STRIPLINE_TYPE,
TWISTEDPAIR_TYPE
};
{
MICROSTRIP_TYPE,
CPW_TYPE,
GROUNDED_CPW_TYPE,
RECTWAVEGUIDE_TYPE,
COAX_TYPE,
C_MICROSTRIP_TYPE,
STRIPLINE_TYPE,
TWISTEDPAIR_TYPE
};
for( int ii = 0; ii < 8; ii++ )
m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) );
@ -277,7 +278,7 @@ void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
if( aCfg == NULL )
if( aCfg == nullptr )
return;
EDA_BASE_FRAME::LoadSettings( aCfg );
@ -321,7 +322,7 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
if( aCfg == NULL )
if( aCfg == nullptr )
return;
EDA_BASE_FRAME::SaveSettings( aCfg );
@ -355,11 +356,6 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
}
/**
* Function OnTranslineAnalyse
* Run a new analyse for the current transline with current parameters
* and displays the electrical parameters
*/
void PCB_CALCULATOR_FRAME::OnTranslineAnalyse( wxCommandEvent& event )
{
if( m_currTransLine )
@ -370,11 +366,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineAnalyse( wxCommandEvent& event )
}
/**
* Function OnTranslineSynthetize
* Run a new synthezis for the current transline with current parameters
* and displays the geometrical parameters
*/
void PCB_CALCULATOR_FRAME::OnTranslineSynthetize( wxCommandEvent& event )
{
if( m_currTransLine )
@ -385,9 +376,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineSynthetize( wxCommandEvent& event )
}
/* returns the full filename of the selected pcb_calculator data file
* the extension file is forced
*/
const wxString PCB_CALCULATOR_FRAME::GetDataFilename()
{
if( m_regulators_fileNameCtrl->GetValue().IsEmpty() )
@ -399,15 +387,12 @@ const wxString PCB_CALCULATOR_FRAME::GetDataFilename()
}
/* Initialize the full filename of the selected pcb_calculator data file
* force the standard extension of the file (.pcbcalc)
* aFilename = the full filename, with or without extension
*/
void PCB_CALCULATOR_FRAME::SetDataFilename( const wxString & aFilename)
void PCB_CALCULATOR_FRAME::SetDataFilename( const wxString& aFilename )
{
if( aFilename.IsEmpty() )
{
m_regulators_fileNameCtrl->SetValue( wxEmptyString );
}
else
{
wxFileName fn( aFilename );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -63,21 +63,22 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate()
{
switch( m_choiceRegType->GetSelection() )
{
default:
case 0:
m_bitmapRegul4pins->Show( true );
m_bitmapRegul3pins->Show( false );
m_RegulIadjValue->Enable( false );
m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R2" ) );
break;
default:
case 0:
m_bitmapRegul4pins->Show( true );
m_bitmapRegul3pins->Show( false );
m_RegulIadjValue->Enable( false );
m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R2" ) );
break;
case 1:
m_bitmapRegul4pins->Show( false );
m_bitmapRegul3pins->Show( true );
m_RegulIadjValue->Enable( true );
m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R1 + Iadj * R2" ) );
break;
case 1:
m_bitmapRegul4pins->Show( false );
m_bitmapRegul3pins->Show( true );
m_RegulIadjValue->Enable( true );
m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R1 + Iadj * R2" ) );
break;
}
// The new icon size must be taken in account
m_panelRegulators->GetSizer()->Layout();
@ -100,6 +101,7 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event )
{
wxString name = m_choiceRegulatorSelector->GetStringSelection();
REGULATOR_DATA * item = m_RegulatorList.GetReg( name );
if( item )
{
m_lastSelectedRegulatorName = item->m_Name;
@ -111,16 +113,12 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event )
m_RegulIadjValue->SetValue( value );
}
// Call RegulatorPageUpdate to enable/sisable tools,
// Call RegulatorPageUpdate to enable/disable tools,
// even if no item selected
RegulatorPageUpdate();
}
/*
* Called when ckicking on button Browse:
* Select a new data file, and load it on request
*/
void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event )
{
wxString fullfilename = GetDataFilename();
@ -143,6 +141,7 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event )
return;
SetDataFilename( fullfilename );
if( wxFileExists( fullfilename ) && m_RegulatorList.GetCount() > 0 ) // Read file
{
if( wxMessageBox( _("Do you want to load this file and replace current regulator list?" ) )
@ -157,7 +156,6 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event )
m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() );
SelectLastSelectedRegulator();
}
else
{
wxString msg;
@ -172,6 +170,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event )
DIALOG_REGULATOR_FORM dlg( this, wxEmptyString );
if( dlg.ShowModal() != wxID_OK )
return;
if( !dlg.IsOK() )
{
wxMessageBox( _("Bad or missing parameters!") );
@ -181,7 +180,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event )
REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData();
// Add new item, if not existing
if( m_RegulatorList.GetReg( new_item->m_Name ) == NULL )
if( m_RegulatorList.GetReg( new_item->m_Name ) == nullptr )
{
// Add item in list
m_RegulatorList.Add( new_item );
@ -203,12 +202,14 @@ void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event )
{
wxString name = m_choiceRegulatorSelector->GetStringSelection();
REGULATOR_DATA * item = m_RegulatorList.GetReg( name );
if( item == NULL )
if( item == nullptr )
return;
DIALOG_REGULATOR_FORM dlg( this, name );
dlg.CopyRegulatorDataToDialog( item );
if( dlg.ShowModal() != wxID_OK )
return;
@ -232,6 +233,7 @@ void PCB_CALCULATOR_FRAME::OnRemoveRegulator( wxCommandEvent& event )
m_RegulatorListChanged = true;
m_choiceRegulatorSelector->Clear();
m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() );
if( m_lastSelectedRegulatorName == name )
m_lastSelectedRegulatorName.Empty();
@ -243,14 +245,17 @@ void PCB_CALCULATOR_FRAME::SelectLastSelectedRegulator()
{
// Find last selected in regulator list:
int idx = -1;
if( ! m_lastSelectedRegulatorName.IsEmpty() )
if( !m_lastSelectedRegulatorName.IsEmpty() )
{
for( unsigned ii = 0; ii < m_RegulatorList.GetCount(); ii++ )
{
if( m_RegulatorList.m_List[ii]->m_Name == m_lastSelectedRegulatorName )
{
idx = ii;
break;
}
}
}
m_choiceRegulatorSelector->SetSelection( idx );
@ -259,18 +264,22 @@ void PCB_CALCULATOR_FRAME::SelectLastSelectedRegulator()
}
// Calculate a value from the 3 other values
// Vref is given by the regulator properties, so
// we can calculate only R1, R2 or Vout
void PCB_CALCULATOR_FRAME::RegulatorsSolve()
{
int id;
if( m_rbRegulR1->GetValue() )
{
id = 0; // for R1 calculation
}
else if( m_rbRegulR2->GetValue() )
{
id = 1; // for R2 calculation
}
else if( m_rbRegulVout->GetValue() )
{
id = 2; // for Vout calculation
}
else
{
wxMessageBox( wxT("Selection error" ) );
@ -297,9 +306,8 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
txt = m_RegulVoutValue->GetValue();
vout = DoubleFromString(txt);
// Some tests:
if( vout < vref && id != 2)
if( vout < vref && id != 2 )
{
m_RegulMessage->SetLabel( _("Vout must be greater than vref" ) );
return;
@ -307,11 +315,11 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
if( vref == 0.0 )
{
m_RegulMessage->SetLabel( _("Vref set to 0 !" ) );
m_RegulMessage->SetLabel( _( "Vref set to 0 !" ) );
return;
}
if( (r1 < 0 && id != 0 ) || (r2 <= 0 && id != 1) )
if( ( r1 < 0 && id != 0 ) || ( r2 <= 0 && id != 1 ) )
{
m_RegulMessage->SetLabel( _("Incorrect value for R1 R2" ) );
return;
@ -323,52 +331,45 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
// 3 terminal regulator
txt = m_RegulIadjValue->GetValue();
double iadj = DoubleFromString(txt);
// iadj is given in micro amp, so convert it in amp.
iadj /= 1000000;
switch( id )
{
case 0:
r1 = vref * r2 / ( vout - vref - (r2 * iadj) );
break;
case 0:
r1 = vref * r2 / ( vout - vref - ( r2 * iadj ) );
break;
case 1:
r2 = ( vout - vref ) / ( iadj + (vref/r1) );
break;
case 1:
r2 = ( vout - vref ) / ( iadj + ( vref / r1 ) );
break;
case 2:
vout = vref * (r1 + r2) / r1;
vout += r2 * iadj;
break;
case 2:
vout = vref * ( r1 + r2 ) / r1;
vout += r2 * iadj;
break;
}
}
else
{ // Standard 4 terminal regulator
switch( id )
{
case 0:
r1 = ( vout / vref - 1 ) * r2;
break;
case 1:
r2 = r1 / ( vout / vref - 1);
break;
case 2:
vout = vref * (r1 + r2) / r2;
break;
case 0: r1 = ( vout / vref - 1 ) * r2; break;
case 1: r2 = r1 / ( vout / vref - 1 ); break;
case 2: vout = vref * ( r1 + r2 ) / r2; break;
}
}
// write values to panel:
txt.Printf(wxT("%g"), r1 / r1scale );
m_RegulR1Value->SetValue(txt);
txt.Printf(wxT("%g"), r2 / r2scale);
m_RegulR2Value->SetValue(txt);
txt.Printf(wxT("%g"), vref);
m_RegulVrefValue->SetValue(txt);
txt.Printf(wxT("%g"), vout);
m_RegulVoutValue->SetValue(txt);
// write values to panel:
txt.Printf( wxT( "%g" ), r1 / r1scale );
m_RegulR1Value->SetValue( txt );
txt.Printf( wxT( "%g" ), r2 / r2scale );
m_RegulR2Value->SetValue( txt );
txt.Printf( wxT( "%g" ), vref );
m_RegulVrefValue->SetValue( txt );
txt.Printf( wxT( "%g" ), vout );
m_RegulVoutValue->SetValue( txt );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -35,7 +35,7 @@ extern double DoubleFromString( const wxString& TextValue );
// A helper function to find the choice in a list of values
// return true if a index in aList that matches aValue is found.
static bool findMatch(wxArrayString& aList, const wxString& aValue, int& aIdx )
static bool findMatch( wxArrayString& aList, const wxString& aValue, int& aIdx )
{
bool success = false;
// Find the previous choice index:
@ -108,11 +108,6 @@ static bool findMatch(wxArrayString& aList, const wxString& aValue, int& aIdx )
}
/**
* Function OnEpsilonR_Button
* Shows a list of current relative dielectric constant(Er)
* and set the selected value in main dialog frame
*/
void PCB_CALCULATOR_FRAME::OnTranslineEpsilonR_Button( wxCommandEvent& event )
{
wxArrayString list = StandardRelativeDielectricConstantList();
@ -131,11 +126,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineEpsilonR_Button( wxCommandEvent& event )
}
/**
* Function OnTanD_Button
* Shows a list of current dielectric loss factor (tangent delta)
* and set the selected value in main dialog frame
*/
void PCB_CALCULATOR_FRAME::OnTranslineTanD_Button( wxCommandEvent& event )
{
wxArrayString list = StandardLossTangentList();
@ -147,18 +137,13 @@ void PCB_CALCULATOR_FRAME::OnTranslineTanD_Button( wxCommandEvent& event )
findMatch( list, prevChoiceStr, prevChoice );
int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Dielectric Loss Factor" ), list,
prevChoice, NULL );
prevChoice, nullptr );
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
m_Value_TanD->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
}
/**
* Function OnTranslineRho_Button
* Shows a list of current Specific resistance list (rho)
* and set the selected value in main dialog frame
*/
void PCB_CALCULATOR_FRAME::OnTranslineRho_Button( wxCommandEvent& event )
{
wxArrayString list = StandardResistivityList();
@ -170,7 +155,7 @@ void PCB_CALCULATOR_FRAME::OnTranslineRho_Button( wxCommandEvent& event )
findMatch( list, prevChoiceStr, prevChoice );
int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Specific Resistance" ), list,
prevChoice, NULL );
prevChoice, nullptr );
if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled.
m_Value_Rho->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
@ -186,14 +171,6 @@ struct DLG_PRM_DATA
};
/**
* Function TranslineTypeSelection
* Must be called after selection of a new transline.
* Update all values, labels and tool tips of parameters needed
* by the new transline
* Irrelevant parameters texts are blanked.
* @param aType = the transline_type_id of the new selected transline
*/
void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType )
{
m_currTransLineType = aType;
@ -221,17 +198,19 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
wxStaticText* left_msg_list[] =
{
m_left_message1, m_left_message2, m_left_message3, m_left_message4, m_left_message5,
m_left_message6, m_left_message7, NULL
m_left_message6, m_left_message7, nullptr
};
wxStaticText* msg_list[] =
{
m_Message1, m_Message2, m_Message3, m_Message4, m_Message5, m_Message6, m_Message7, NULL
m_Message1, m_Message2, m_Message3, m_Message4, m_Message5, m_Message6, m_Message7, nullptr
};
unsigned jj = 0;
for( ; jj < tr_ident->m_Messages.GetCount(); jj++ )
{
if( left_msg_list[jj] == NULL )
if( left_msg_list[jj] == nullptr )
break;
left_msg_list[jj]->SetLabel( tr_ident->m_Messages[jj] );
@ -246,12 +225,12 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
}
// Init parameters dialog items
// Init parameters dialog items
struct DLG_PRM_DATA substrateprms[] =
{
{ m_EpsilonR_label, m_Value_EpsilonR, NULL },
{ m_TanD_label, m_Value_TanD, NULL },
{ m_Rho_label, m_Value_Rho, NULL },
{ m_EpsilonR_label, m_Value_EpsilonR, nullptr },
{ m_TanD_label, m_Value_TanD, nullptr },
{ m_Rho_label, m_Value_Rho, nullptr },
{ m_substrate_prm4_label, m_Substrate_prm4_Value, m_SubsPrm4_choiceUnit },
{ m_substrate_prm5_label, m_Substrate_prm5_Value, m_SubsPrm5_choiceUnit },
{ m_substrate_prm6_label, m_Substrate_prm6_Value, m_SubsPrm6_choiceUnit },
@ -259,7 +238,8 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
{ m_substrate_prm8_label, m_Substrate_prm8_Value, m_SubsPrm8_choiceUnit },
{ m_substrate_prm9_label, m_Substrate_prm9_Value, m_SubsPrm9_choiceUnit }
};
#define substrateprms_cnt (sizeof(substrateprms)/sizeof(substrateprms[0]))
#define substrateprms_cnt (sizeof(substrateprms)/sizeof(substrateprms[0]))
struct DLG_PRM_DATA physprms[] =
{
@ -267,7 +247,8 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
{ m_phys_prm2_label, m_Phys_prm2_Value, m_choiceUnit_Param2 },
{ m_phys_prm3_label, m_Phys_prm3_Value, m_choiceUnit_Param3 }
};
#define physprms_cnt (sizeof(physprms)/sizeof(physprms[0]))
#define physprms_cnt (sizeof(physprms)/sizeof(physprms[0]))
struct DLG_PRM_DATA elecprms[] =
{
@ -275,13 +256,15 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
{ m_elec_prm2_label, m_Elec_prm2_Value, m_choiceUnit_ElecPrm2 },
{ m_elec_prm3_label, m_Elec_prm3_Value, m_choiceUnit_ElecPrm3 }
};
#define elecprms_cnt (sizeof(elecprms)/sizeof(elecprms[0]))
#define elecprms_cnt (sizeof(elecprms)/sizeof(elecprms[0]))
struct DLG_PRM_DATA frequencyprms[] =
{
{ m_Frequency_label,m_Value_Frequency_Ctrl, m_choiceUnit_Frequency }
};
#define frequencyprms_cnt (sizeof(frequencyprms)/sizeof(frequencyprms[0]))
#define frequencyprms_cnt (sizeof(frequencyprms)/sizeof(frequencyprms[0]))
unsigned idxsubs = 0;
unsigned idxphys = 0;
@ -291,7 +274,8 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
for( unsigned ii = 0; ii < tr_ident->GetPrmsCount(); ii++ )
{
TRANSLINE_PRM* prm = tr_ident->GetPrm( ii );
struct DLG_PRM_DATA * data = NULL;
struct DLG_PRM_DATA * data = nullptr;
switch( prm->m_Type )
{
case PRM_TYPE_SUBS:
@ -408,11 +392,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType
}
}
/**
* Function TransfDlgDataToTranslineParams
* Read values entered in dialog frame, and copy these values
* in current transline parameters, converted in normalized units
*/
void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams()
{
TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType];
@ -437,10 +417,6 @@ void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams()
}
/**
* Function OnTranslineSelection
* Called on new transmission line selection
*/
void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event )
{
enum TRANSLINE_TYPE_ID id = (enum TRANSLINE_TYPE_ID) event.GetSelection();
@ -454,11 +430,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event )
}
/**
* Function OnTransLineResetButtonClick
* Called when the user clicks the reset button. This sets
* the parameters to their default values.
*/
void PCB_CALCULATOR_FRAME::OnTransLineResetButtonClick( wxCommandEvent& event )
{
TranslineTypeSelection( DEFAULT_TYPE );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011-2014 Jean-Pierre Charras
* Copyright (C) 2004-2014 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2021 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
@ -42,16 +42,9 @@
#include "transline_ident.h"
/*
* TRANSLINE_PRM
* A class to handle one parameter of transline
*/
TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId,
const char* aKeywordCfg,
const wxString& aDlgLabel,
const wxString& aToolTip,
double aValue,
bool aConvUnit )
TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg,
const wxString& aDlgLabel, const wxString& aToolTip,
double aValue, bool aConvUnit )
{
m_Type = aType;
m_Id = aId;
@ -60,8 +53,8 @@ TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId,
m_ToolTip = aToolTip;
m_Value = aValue;
m_ConvUnit = aConvUnit;
m_ValueCtrl = NULL;
m_UnitCtrl = NULL;
m_ValueCtrl = nullptr;
m_UnitCtrl = nullptr;
m_UnitSelection = 0;
m_NormalizedValue = 0;
}
@ -85,23 +78,11 @@ double TRANSLINE_PRM::FromUserUnit()
}
/*
* TRANSLINE_IDENT
* A class to handle a list of parameters of a given transline
* Important note:
* the first string of TRANSLINE_PRM (m_KeyWord) is a keyword in config file.
* it can contain only ASCII7 chars
* the second string of TRANSLINE_PRM (m_DlgLabel) is a string translated for dialog,
* so mark it for translation (m_KeyWord and m_DlgLabel are usually the same in English)
* and of course do not mark translatable m_DlgLabel that obviously cannot be translated,
* like "H" or "H_t"
*/
TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
{
m_Type = aType; // The type of transline handled
m_Icon = NULL; // An xpm icon to display in dialogs
m_TLine = NULL; // The TRANSLINE itself
m_Icon = nullptr; // An xpm icon to display in dialogs
m_TLine = nullptr; // The TRANSLINE itself
m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu
// Add common prms:
@ -118,7 +99,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
// Default value is for copper
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, RHO_PRM,
"Rho", wxT( "ρ" ),
_( "Electrical resistivity or specific electrical resistance of conductor (ohm*meter)" ),
_( "Electrical resistivity or specific electrical resistance of "
"conductor (ohm*meter)" ),
1.72e-8, false ) );
// Default value is in GHz
@ -149,10 +131,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
"Rough", _( "Roughness" ),
_( "Conductor roughness" ), 0.0, true ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
"mu Rel S", wxString::Format( wxT( "μ(%s)" ), _( "substrate" ) ),
"mu Rel S", wxString::Format( wxT( "μ(%s)" ),
_( "substrate" ) ),
_( "Relative permeability (mu) of substrate" ), 1, false ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu Rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1,
false ) );
@ -183,7 +167,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
"T", "T", _( "Strip thickness" ), 0.035, true ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu Rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1,
false ) );
@ -216,7 +201,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
"T", "T", _( "Strip thickness" ), 0.035, true ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu Rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1,
false ) );
@ -248,10 +234,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
m_Messages.Add( _( "TM-modes:" ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
"mu Rel I", wxString::Format( wxT( "μ(%s)" ), _( "insulator" ) ),
"mu Rel I", wxString::Format( wxT( "μ(%s)" ),
_( "insulator" ) ),
_( "Relative permeability (mu) of insulator" ), 1, false ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu Rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1,
false ) );
@ -281,10 +269,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
m_Messages.Add( _( "TM-modes:" ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM,
"mu Rel I", wxString::Format( wxT( "μ(%s)" ), _( "insulator" ) ),
"mu Rel I", wxString::Format( wxT( "μ(%s)" ),
_( "insulator" ) ),
_( "Relative permeability (mu) of insulator" ), 1, false ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu Rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1,
false ) );
@ -327,7 +317,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
"Rough", _( "Roughness" ),
_( "Conductor roughness" ), 0.0, true ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1,
false ) );
@ -340,10 +331,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_E_PRM,
"Zeven", _( "Zeven" ),
_( "Even mode impedance (lines driven by common voltages)" ), 50.0, true ) );
_( "Even mode impedance (lines driven by common voltages)" ),
50.0, true ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_O_PRM,
"Zodd", _( "Zodd" ),
_( "Odd mode impedance (lines driven by opposite (differential) voltages)" ), 50.0, true ) );
_( "Odd mode impedance (lines driven by opposite "
"(differential) voltages)" ), 50.0, true ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM,
"Ang_l", "Ang_l",
_( "Electrical length" ), 0.0, true ) );
@ -366,7 +359,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM,
"T", "T", _( "Strip thickness" ), 0.035, true ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu Rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1, false ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM,
@ -395,11 +389,13 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType )
"Twists", _( "Twists" ),
_( "Number of twists per length" ), 0.0, false ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM,
"mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ),
"mu Rel C", wxString::Format( wxT( "μ(%s)" ),
_( "conductor" ) ),
_( "Relative permeability (mu) of conductor" ), 1,
false ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TWISTEDPAIR_EPSILONR_ENV_PRM,
"ErEnv", wxString::Format( wxT( "εr(%s)" ), _( "environment" ) ),
"ErEnv", wxString::Format( wxT( "εr(%s)" ),
_( "environment" ) ),
_( "Relative permittivity of environment" ), 1,
false ) );
AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_IN_PRM,

View File

@ -53,6 +53,10 @@ enum PRM_TYPE {
PRM_TYPE_FREQUENCY
};
/**
* A class to handle one parameter of transline.
*/
class TRANSLINE_PRM
{
public:
@ -62,12 +66,10 @@ public:
* @param aDlgLabel is a I18n string used to identify the parameter in dialog.
* usually aDlgLabel is same as aKeywordCfg, but translatable.
*/
TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId,
const char* aKeywordCfg = "",
TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg = "",
const wxString& aDlgLabel = wxEmptyString,
const wxString& aToolTip = wxEmptyString,
double aValue = 0.0,
bool aConvUnit = false );
double aValue = 0.0, bool aConvUnit = false );
double ToUserUnit();
double FromUserUnit();
@ -86,8 +88,14 @@ public:
};
// A class to handle the list of available transm. lines
// with messages, tooptips ...
/**
* A class to handle a list of parameters of a given transline.
*
* @note The first string of TRANSLINE_PRM (m_KeyWord) is a keyword in config file.
* It can contain only ASCII7 chars. The second string of TRANSLINE_PRM is a
* string translated for dialog so mark it for translation. Do not mark translatable
* m_DlgLabel that obviously cannot be translated, like "H" or "H_t".
*/
class TRANSLINE_IDENT
{
public:
@ -105,7 +113,7 @@ public:
if( aIdx < m_prms_List.size() )
return m_prms_List[aIdx];
else
return NULL;
return nullptr;
}
unsigned GetPrmsCount() const

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 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
@ -52,24 +53,41 @@
// read and instantiate an IDF component outline
static SCENEGRAPH* loadIDFOutline( const wxString& aFileName );
// read and render an IDF board assembly
static SCENEGRAPH* loadIDFBoard( const wxString& aFileName );
// model a single extruded outline
// idxColor = color index to use
// aParent = parent SCENEGRAPH object, if any
static SCENEGRAPH* addOutline( IDF3_COMP_OUTLINE* outline, int idxColor, SGNODE* aParent );
// model the board extrusion
static SCENEGRAPH* makeBoard( IDF3_BOARD& brd, SGNODE* aParent );
// model all included components
static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent );
// model any .OTHER_OUTLINE items
static bool makeOtherOutlines( IDF3_BOARD& brd, SGNODE* aParent );
// convert the IDF outline to VRML intermediate data
static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >* items );
// convert IDF segment data to VRML segment data
static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg );
// convert the VRML intermediate data into SG* data
static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top, double bottom );
static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top,
double bottom );
class LOCALESWITCH
@ -105,63 +123,63 @@ static SGNODE* getColor( IFSG_SHAPE& shape, int colorIdx )
// green for PCB
material.SetSpecular( 0.13f, 0.81f, 0.22f );
material.SetDiffuse( 0.13f, 0.81f, 0.22f );
// default ambient intensity
material.SetShininess( 0.3f );
break;
case 1:
// magenta
material.SetSpecular( 0.8f, 0.0f, 0.8f );
material.SetDiffuse( 0.6f, 0.0f, 0.6f );
// default ambient intensity
material.SetShininess( 0.3f );
break;
case 2:
// red
material.SetSpecular( 0.69f, 0.14f, 0.14f );
material.SetDiffuse( 0.69f, 0.14f, 0.14f );
// default ambient intensity
material.SetShininess( 0.3f );
break;
case 3:
// orange
material.SetSpecular( 1.0f, 0.44f, 0.0f );
material.SetDiffuse( 1.0f, 0.44f, 0.0f );
// default ambient intensity
material.SetShininess( 0.3f );
break;
case 4:
// yellow
material.SetSpecular( 0.93f, 0.94f, 0.16f );
material.SetDiffuse( 0.93f, 0.94f, 0.16f );
// default ambient intensity
material.SetShininess( 0.3f );
break;
case 5:
// blue
material.SetSpecular( 0.1f, 0.11f, 0.88f );
material.SetDiffuse( 0.1f, 0.11f, 0.88f );
// default ambient intensity
material.SetShininess( 0.3f );
break;
default:
// violet
material.SetSpecular( 0.32f, 0.07f, 0.64f );
material.SetDiffuse( 0.32f, 0.07f, 0.64f );
// default ambient intensity
material.SetShininess( 0.3f );
break;
}
@ -178,8 +196,8 @@ const char* GetKicadPluginName( void )
}
void GetPluginVersion( unsigned char* Major,
unsigned char* Minor, unsigned char* Patch, unsigned char* Revision )
void GetPluginVersion( unsigned char* Major, unsigned char* Minor, unsigned char* Patch,
unsigned char* Revision )
{
if( Major )
*Major = PLUGIN_3D_IDF_MAJOR;
@ -192,10 +210,9 @@ void GetPluginVersion( unsigned char* Major,
if( Revision )
*Revision = PLUGIN_3D_IDF_REVNO;
return;
}
// number of extensions supported
#ifdef _WIN32
#define NEXTS 2
@ -203,12 +220,15 @@ void GetPluginVersion( unsigned char* Major,
#define NEXTS 4
#endif
// number of filter sets supported
#define NFILS 2
static char ext0[] = "idf";
static char ext1[] = "emn";
#ifdef _WIN32
static char fil0[] = "IDF (*.idf)|*.idf";
static char fil1[] = "IDF BRD v2/v3 (*.emn)|*.emn";
@ -235,8 +255,6 @@ static struct FILE_DATA
extensions[2] = ext2;
extensions[3] = ext3;
#endif
return;
}
} file_data;
@ -251,7 +269,7 @@ int GetNExtensions( void )
char const* GetModelExtension( int aIndex )
{
if( aIndex < 0 || aIndex >= NEXTS )
return NULL;
return nullptr;
return file_data.extensions[aIndex];
}
@ -266,7 +284,7 @@ int GetNFilters( void )
char const* GetFileFilter( int aIndex )
{
if( aIndex < 0 || aIndex >= NFILS )
return NULL;
return nullptr;
return file_data.filters[aIndex];
}
@ -281,15 +299,15 @@ bool CanRender( void )
SCENEGRAPH* Load( char const* aFileName )
{
if( NULL == aFileName )
return NULL;
if( nullptr == aFileName )
return nullptr;
wxFileName fname;
fname.Assign( wxString::FromUTF8Unchecked( aFileName ) );
wxString ext = fname.GetExt();
SCENEGRAPH* data = NULL;
SCENEGRAPH* data = nullptr;
if( !ext.Cmp( wxT( "idf" ) ) || !ext.Cmp( wxT( "IDF" ) ) )
{
@ -302,16 +320,16 @@ SCENEGRAPH* Load( char const* aFileName )
}
// DEBUG: WRITE OUT IDF FILE TO CONFIRM NORMALS
#if defined( DEBUG_IDF ) && DEBUG_IDF > 3
#if defined( DEBUG_IDF ) && DEBUG_IDF > 3
if( data )
{
wxFileName fn( aFileName );
wxString output = wxT( "_idf-" );
output.append( fn.GetName() );
output.append( wxT(".wrl") );
S3D::WriteVRML( output.ToUTF8(), true, (SGNODE*)(data), true, true );
output.append( wxT( ".wrl" ) );
S3D::WriteVRML( output.ToUTF8(), true, (SGNODE*) ( data ), true, true );
}
#endif
#endif
return data;
}
@ -339,28 +357,28 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >*
if( nvcont < 0 )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] cannot create an outline";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
if( (*scont)->size() < 1 )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] invalid contour: no vertices";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -369,20 +387,21 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >*
eseg = (*scont)->end();
iseg = 0;
while( sseg != eseg )
{
lseg = **sseg;
if( !addSegment( model, &lseg, nvcont, iseg ) )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] cannot add segment";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -409,14 +428,14 @@ static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg
{
if( iseg != 0 )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] adding a circle to an existing vertex list";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -437,9 +456,10 @@ static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg
}
static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top, double bottom )
static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top,
double bottom )
{
vpcb.Tesselate( NULL );
vpcb.Tesselate( nullptr );
std::vector< double > vertices;
std::vector< int > idxPlane;
std::vector< int > idxSide;
@ -453,30 +473,30 @@ static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, do
if( !vpcb.Get3DTriangles( vertices, idxPlane, idxSide, top, bottom ) )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] no vertex data";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return NULL;
return nullptr;
}
if( ( idxPlane.size() % 3 ) || ( idxSide.size() % 3 ) )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] index lists are not a multiple of 3 (not a triangle list)";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return NULL;
return nullptr;
}
std::vector< SGPOINT > vlist;
@ -487,14 +507,24 @@ static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, do
vlist.emplace_back( vertices[j], vertices[j+1], vertices[j+2] );
// create the intermediate scenegraph
IFSG_TRANSFORM* tx0 = new IFSG_TRANSFORM( aParent ); // tx0 = Transform for this outline
IFSG_SHAPE* shape = new IFSG_SHAPE( *tx0 ); // shape will hold (a) all vertices and (b) a local list of normals
IFSG_FACESET* face = new IFSG_FACESET( *shape ); // this face shall represent the top and bottom planes
IFSG_COORDS* cp = new IFSG_COORDS( *face ); // coordinates for all faces
IFSG_TRANSFORM* tx0 = new IFSG_TRANSFORM( aParent ); // tx0 = Transform for this outline
// shape will hold (a) all vertices and (b) a local list of normals
IFSG_SHAPE* shape = new IFSG_SHAPE( *tx0 );
// this face shall represent the top and bottom planes
IFSG_FACESET* face = new IFSG_FACESET( *shape );
// coordinates for all faces
IFSG_COORDS* cp = new IFSG_COORDS( *face );
cp->SetCoordsList( nvert, &vlist[0] );
IFSG_COORDINDEX* coordIdx = new IFSG_COORDINDEX( *face ); // coordinate indices for top and bottom planes only
// coordinate indices for top and bottom planes only.
IFSG_COORDINDEX* coordIdx = new IFSG_COORDINDEX( *face );
coordIdx->SetIndices( idxPlane.size(), &idxPlane[0] );
IFSG_NORMALS* norms = new IFSG_NORMALS( *face ); // normals for the top and bottom planes
// normals for the top and bottom planes.
IFSG_NORMALS* norms = new IFSG_NORMALS( *face );
// number of TOP (and bottom) vertices
j = nvert / 2;
@ -573,16 +603,16 @@ static SCENEGRAPH* addOutline( IDF3_COMP_OUTLINE* outline, int idxColor, SGNODE*
if( !getOutlineModel( vpcb, outline->GetOutlines() ) )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] no valid outline data";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return NULL;
return nullptr;
}
vpcb.EnsureWinding( 0, false );
@ -607,13 +637,13 @@ static SCENEGRAPH* loadIDFOutline( const wxString& aFileName )
{
LOCALESWITCH switcher;
IDF3_BOARD brd( IDF3::CAD_ELEC );
IDF3_COMP_OUTLINE* outline = NULL;
IDF3_COMP_OUTLINE* outline = nullptr;
outline = brd.GetComponentOutline( aFileName );
if( NULL == outline )
if( nullptr == outline )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -623,12 +653,12 @@ static SCENEGRAPH* loadIDFOutline( const wxString& aFileName )
ostr << aFileName << "'";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return NULL;
return nullptr;
}
SCENEGRAPH* data = addOutline( outline, -1, NULL );
SCENEGRAPH* data = addOutline( outline, -1, nullptr );
return data;
}
@ -642,7 +672,7 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName )
// note: if the IDF model is defective no outline substitutes shall be made
if( !brd.ReadFile( aFileName, true ) )
{
#ifdef DEBUG
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -651,9 +681,9 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName )
ostr << " * [INFO] IDF file '" << aFileName.ToUTF8() << "'";
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return NULL;
return nullptr;
}
IFSG_TRANSFORM tx0( true );
@ -663,7 +693,7 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName )
bool noComp = false;
bool noOther = false;
if( NULL == makeBoard( brd, topNode ) )
if( nullptr == makeBoard( brd, topNode ) )
noBoard = true;
if( !makeComponents( brd, topNode ) )
@ -675,7 +705,7 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName )
if( noBoard && noComp && noOther )
{
tx0.Destroy();
return NULL;
return nullptr;
}
return (SCENEGRAPH*) topNode;
@ -684,18 +714,18 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName )
static SCENEGRAPH* makeBoard( IDF3_BOARD& brd, SGNODE* aParent )
{
if( NULL == aParent )
return NULL;
if( nullptr == aParent )
return nullptr;
VRML_LAYER vpcb;
// check if no board outline
if( brd.GetBoardOutlinesSize() < 1 )
return NULL;
return nullptr;
if( !getOutlineModel( vpcb, brd.GetBoardOutline()->GetOutlines() ) )
return NULL;
return nullptr;
vpcb.EnsureWinding( 0, false );
@ -747,7 +777,7 @@ static SCENEGRAPH* makeBoard( IDF3_BOARD& brd, SGNODE* aParent )
static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent )
{
if( NULL == aParent )
if( nullptr == aParent )
return false;
int ncomponents = 0;
@ -798,28 +828,27 @@ static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent )
pout = (IDF3_COMP_OUTLINE*)((*so)->GetOutline());
if( NULL == pout )
if( nullptr == pout )
{
++so;
continue;
}
dataItem = dataMap.find( pout->GetUID() );
SCENEGRAPH* sg = NULL;
SCENEGRAPH* sg = nullptr;
if( dataItem == dataMap.end() )
{
sg = addOutline( pout, -1, NULL );
sg = addOutline( pout, -1, nullptr );
if( NULL == sg )
if( nullptr == sg )
{
++so;
continue;
}
++ncomponents;
dataMap.insert( std::pair< std::string, SGNODE* >
( pout->GetUID(), (SGNODE*)sg ) );
dataMap.insert( std::pair< std::string, SGNODE* >( pout->GetUID(), (SGNODE*)sg ) );
}
else
{
@ -830,7 +859,7 @@ static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent )
IFSG_TRANSFORM txN( false );
txN.Attach( (SGNODE*)sg );
if( NULL == txN.GetParent() )
if( nullptr == txN.GetParent() )
tx0.AddChildNode( txN );
else
tx0.AddRefNode( txN );
@ -869,7 +898,7 @@ static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent )
static bool makeOtherOutlines( IDF3_BOARD& brd, SGNODE* aParent )
{
if( NULL == aParent )
if( nullptr == aParent )
return false;
VRML_LAYER vpcb;
@ -922,7 +951,7 @@ static bool makeOtherOutlines( IDF3_BOARD& brd, SGNODE* aParent )
top = bot + pout->GetThickness();
}
if( NULL == vrmlToSG( vpcb, -1, aParent, top, bot ) )
if( nullptr == vrmlToSG( vpcb, -1, aParent, top, bot ) )
{
vpcb.Clear();
++sc;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2020-2021 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
@ -96,13 +96,16 @@ typedef std::pair< std::string, std::vector< SGNODE* > > NODEITEM;
struct DATA;
bool processNode( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
std::vector< SGNODE* >* items );
std::vector< SGNODE* >* items );
bool processComp( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
std::vector< SGNODE* >* items );
std::vector< SGNODE* >* items );
bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
std::vector< SGNODE* >* items, Quantity_Color* color );
std::vector< SGNODE* >* items, Quantity_Color* color );
struct DATA
{
@ -120,8 +123,8 @@ struct DATA
DATA()
{
scene = NULL;
defaultColor = NULL;
scene = nullptr;
defaultColor = nullptr;
refColor.SetValues( Quantity_NOC_BLACK );
renderBoth = false;
hasSolid = false;
@ -137,7 +140,7 @@ struct DATA
while( sC != eC )
{
if( NULL == S3D::GetSGNodeParent( sC->second ) )
if( nullptr == S3D::GetSGNodeParent( sC->second ) )
S3D::DestroyNode( sC->second );
++sC;
@ -146,7 +149,7 @@ struct DATA
colors.clear();
}
if( defaultColor && NULL == S3D::GetSGNodeParent( defaultColor ) )
if( defaultColor && nullptr == S3D::GetSGNodeParent( defaultColor ) )
S3D::DestroyNode(defaultColor);
// destroy any faces with no parent
@ -157,7 +160,7 @@ struct DATA
while( sF != eF )
{
if( NULL == S3D::GetSGNodeParent( sF->second ) )
if( nullptr == S3D::GetSGNodeParent( sF->second ) )
S3D::DestroyNode( sF->second );
++sF;
@ -179,7 +182,7 @@ struct DATA
while( sV != eV )
{
if( NULL == S3D::GetSGNodeParent( *sV ) )
if( nullptr == S3D::GetSGNodeParent( *sV ) )
S3D::DestroyNode( *sV );
++sV;
@ -194,14 +197,12 @@ struct DATA
if( scene )
S3D::DestroyNode(scene);
return;
}
// find collection of tagged nodes
bool GetShape( const std::string& id, std::vector< SGNODE* >*& listPtr )
{
listPtr = NULL;
listPtr = nullptr;
NODEMAP::iterator item;
item = shapes.find( id );
@ -219,7 +220,7 @@ struct DATA
item = faces.find( id );
if( item == faces.end() )
return NULL;
return nullptr;
return item->second;
}
@ -227,7 +228,7 @@ struct DATA
// return color if found; if not found, create SGAPPEARANCE
SGNODE* GetColor( Quantity_Color* colorObj )
{
if( NULL == colorObj )
if( nullptr == colorObj )
{
if( defaultColor )
return defaultColor;
@ -279,7 +280,7 @@ FormatType fileType( const char* aFileName )
return FMT_NONE;
if( fname.GetExt().MakeUpper().EndsWith( "STPZ" ) ||
fname.GetExt().MakeUpper().EndsWith( "GZ" ) )
fname.GetExt().MakeUpper().EndsWith( "GZ" ) )
return FMT_STPZ;
char iline[82];
@ -344,8 +345,6 @@ void getTag( TDF_Label& label, std::string& aTag )
aTag.append( 1, *bI );
++bI;
}
return;
}
@ -372,7 +371,7 @@ bool getColor( DATA& data, TDF_Label label, Quantity_Color& color )
void addItems( SGNODE* parent, std::vector< SGNODE* >* lp )
{
if( NULL == lp )
if( nullptr == lp )
return;
std::vector< SGNODE* >::iterator sL = lp->begin();
@ -383,19 +382,17 @@ void addItems( SGNODE* parent, std::vector< SGNODE* >* lp )
{
item = *sL;
if( NULL == S3D::GetSGNodeParent( item ) )
if( nullptr == S3D::GetSGNodeParent( item ) )
S3D::AddSGNodeChild( parent, item );
else
S3D::AddSGNodeRef( parent, item );
++sL;
}
return;
}
bool readIGES( Handle(TDocStd_Document)& m_doc, const char* fname )
bool readIGES( Handle( TDocStd_Document ) & m_doc, const char* fname )
{
IGESCAFControl_Reader reader;
IFSelect_ReturnStatus stat = reader.ReadFile( fname );
@ -441,9 +438,9 @@ bool readSTEP( Handle(TDocStd_Document)& m_doc, const char* fname )
return false;
// set other translation options
reader.SetColorMode(true); // use model colors
reader.SetNameMode(false); // don't use label names
reader.SetLayerMode(false); // ignore LAYER data
reader.SetColorMode( true ); // use model colors
reader.SetNameMode( false ); // don't use label names
reader.SetLayerMode( false ); // ignore LAYER data
if ( !reader.Transfer( m_doc ) )
{
@ -539,27 +536,30 @@ SCENEGRAPH* LoadModel( char const* filename )
switch( modelFmt )
{
case FMT_IGES:
data.renderBoth = true;
case FMT_IGES:
data.renderBoth = true;
if( !readIGES( data.m_doc, filename ) )
return NULL;
break;
if( !readIGES( data.m_doc, filename ) )
return nullptr;
case FMT_STEP:
if( !readSTEP( data.m_doc, filename ) )
return NULL;
break;
break;
case FMT_STPZ:
if( !readSTEPZ( data.m_doc, filename ) )
return NULL;
break;
case FMT_STEP:
if( !readSTEP( data.m_doc, filename ) )
return nullptr;
break;
case FMT_STPZ:
if( !readSTEPZ( data.m_doc, filename ) )
return nullptr;
break;
default:
return NULL;
break;
default:
return nullptr;
break;
}
data.m_assy = XCAFDoc_DocumentTool::ShapeTool( data.m_doc->Main() );
@ -579,21 +579,21 @@ SCENEGRAPH* LoadModel( char const* filename )
while( id <= nshapes )
{
TopoDS_Shape shape = data.m_assy->GetShape( frshapes.Value(id) );
TopoDS_Shape shape = data.m_assy->GetShape( frshapes.Value( id ) );
if ( !shape.IsNull() && processNode( shape, data, data.scene, NULL ) )
if ( !shape.IsNull() && processNode( shape, data, data.scene, nullptr ) )
ret = true;
++id;
};
if( !ret )
return NULL;
return nullptr;
SCENEGRAPH* scene = (SCENEGRAPH*)data.scene;
// DEBUG: WRITE OUT VRML2 FILE TO CONFIRM STRUCTURE
#if ( defined( DEBUG_OCE ) && DEBUG_OCE > 3 )
#if ( defined( DEBUG_OCE ) && DEBUG_OCE > 3 )
if( data.scene )
{
wxFileName fn( wxString::FromUTF8Unchecked( filename ) );
@ -605,20 +605,20 @@ SCENEGRAPH* LoadModel( char const* filename )
output = wxT( "_iges-" );
output.append( fn.GetName() );
output.append( wxT(".wrl") );
output.append( wxT( ".wrl" ) );
S3D::WriteVRML( output.ToUTF8(), true, data.scene, true, true );
}
#endif
#endif
// set to NULL to prevent automatic destruction of the scene data
data.scene = NULL;
data.scene = nullptr;
return scene;
}
bool processShell( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
std::vector< SGNODE* >* items, Quantity_Color* color )
std::vector< SGNODE* >* items, Quantity_Color* color )
{
TopoDS_Iterator it;
bool ret = false;
@ -636,13 +636,13 @@ bool processShell( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
std::vector< SGNODE* >* items )
std::vector< SGNODE* >* items )
{
TDF_Label label;
data.hasSolid = true;
std::string partID;
Quantity_Color col;
Quantity_Color* lcolor = NULL;
Quantity_Color* lcolor = nullptr;
// Search the whole model first to make sure something exists (may or may not have color)
if( !data.m_assy->Search( shape, label ) )
@ -666,7 +666,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
if( !found_color )
{
if( data.m_assy->Search( shape, label, Standard_False, Standard_True, Standard_True ) &&
getColor( data, label, col ) )
getColor( data, label, col ) )
{
found_color = true;
lcolor = &col;
@ -676,19 +676,22 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
// If the components do not have color information, search all components without location
if( !found_color )
{
if( data.m_assy->Search( shape, label, Standard_False, Standard_False, Standard_True ) &&
getColor( data, label, col ) )
if( data.m_assy->Search( shape, label, Standard_False, Standard_False,
Standard_True ) &&
getColor( data, label, col ) )
{
found_color = true;
lcolor = &col;
}
}
// Our last chance to find the color looks for color as a subshape of top-level simple shapes
// Our last chance to find the color looks for color as a subshape of top-level simple
// shapes.
if( !found_color )
{
if( data.m_assy->Search( shape, label, Standard_False, Standard_False, Standard_False ) &&
getColor( data, label, col ) )
if( data.m_assy->Search( shape, label, Standard_False, Standard_False,
Standard_False ) &&
getColor( data, label, col ) )
{
found_color = true;
lcolor = &col;
@ -716,7 +719,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
childNode.SetRotation( SGVECTOR( axis.X(), axis.Y(), axis.Z() ), angle );
}
std::vector< SGNODE* >* component = NULL;
std::vector< SGNODE* >* component = nullptr;
if( !partID.empty() )
data.GetShape( partID, component );
@ -725,7 +728,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
{
addItems( pptr, component );
if( NULL != items )
if( nullptr != items )
items->push_back( pptr );
}
@ -742,7 +745,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
if( !ret )
childNode.Destroy();
else if( NULL != items )
else if( nullptr != items )
items->push_back( pptr );
return ret;
@ -750,7 +753,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
bool processComp( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
std::vector< SGNODE* >* items )
std::vector< SGNODE* >* items )
{
TopoDS_Iterator it;
IFSG_TRANSFORM childNode( parent );
@ -778,35 +781,39 @@ bool processComp( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
switch( stype )
{
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
if( processComp( subShape, data, pptr, items ) )
ret = true;
break;
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
if( processComp( subShape, data, pptr, items ) )
ret = true;
case TopAbs_SOLID:
if( processSolid( subShape, data, pptr, items ) )
ret = true;
break;
break;
case TopAbs_SHELL:
if( processShell( subShape, data, pptr, items, NULL ) )
ret = true;
break;
case TopAbs_SOLID:
if( processSolid( subShape, data, pptr, items ) )
ret = true;
case TopAbs_FACE:
if( processFace( TopoDS::Face( subShape ), data, pptr, items, NULL ) )
ret = true;
break;
break;
default:
break;
case TopAbs_SHELL:
if( processShell( subShape, data, pptr, items, nullptr ) )
ret = true;
break;
case TopAbs_FACE:
if( processFace( TopoDS::Face( subShape ), data, pptr, items, nullptr ) )
ret = true;
break;
default:
break;
}
}
if( !ret )
childNode.Destroy();
else if( NULL != items )
else if( nullptr != items )
items->push_back( pptr );
return ret;
@ -822,29 +829,33 @@ bool processNode( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
switch( stype )
{
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
if( processComp( shape, data, parent, items ) )
ret = true;
break;
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
if( processComp( shape, data, parent, items ) )
ret = true;
case TopAbs_SOLID:
if( processSolid( shape, data, parent, items ) )
ret = true;
break;
break;
case TopAbs_SHELL:
if( processShell( shape, data, parent, items, NULL ) )
ret = true;
break;
case TopAbs_SOLID:
if( processSolid( shape, data, parent, items ) )
ret = true;
case TopAbs_FACE:
if( processFace( TopoDS::Face( shape ), data, parent, items, NULL ) )
ret = true;
break;
break;
default:
break;
case TopAbs_SHELL:
if( processShell( shape, data, parent, items, nullptr ) )
ret = true;
break;
case TopAbs_FACE:
if( processFace( TopoDS::Face( shape ), data, parent, items, nullptr ) )
ret = true;
break;
default:
break;
}
return ret;
@ -852,13 +863,13 @@ bool processNode( const TopoDS_Shape& shape, DATA& data, SGNODE* parent,
bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
std::vector< SGNODE* >* items, Quantity_Color* color )
std::vector< SGNODE* >* items, Quantity_Color* color )
{
if( Standard_True == face.IsNull() )
return false;
bool reverse = ( face.Orientation() == TopAbs_REVERSED );
SGNODE* ashape = NULL;
SGNODE* ashape = nullptr;
std::string partID;
TDF_Label label;
@ -877,12 +888,12 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
if( ashape )
{
if( NULL == S3D::GetSGNodeParent( ashape ) )
if( nullptr == S3D::GetSGNodeParent( ashape ) )
S3D::AddSGNodeChild( parent, ashape );
else
S3D::AddSGNodeRef( parent, ashape );
if( NULL != items )
if( nullptr != items )
items->push_back( ashape );
if( useBothSides )
@ -891,12 +902,12 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
id2.append( "b" );
SGNODE* shapeB = data.GetFace( id2 );
if( NULL == S3D::GetSGNodeParent( shapeB ) )
if( nullptr == S3D::GetSGNodeParent( shapeB ) )
S3D::AddSGNodeChild( parent, shapeB );
else
S3D::AddSGNodeRef( parent, shapeB );
if( NULL != items )
if( nullptr != items )
items->push_back( shapeB );
}
@ -905,12 +916,12 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
TopLoc_Location loc;
Standard_Boolean isTessellate (Standard_False);
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation( face, loc );
Handle( Poly_Triangulation ) triangulation = BRep_Tool::Triangulation( face, loc );
if( triangulation.IsNull() || triangulation->Deflection() > USER_PREC + Precision::Confusion() )
isTessellate = Standard_True;
if (isTessellate)
if( isTessellate )
{
BRepMesh_IncrementalMesh IM(face, USER_PREC, Standard_False, USER_ANGLE );
triangulation = BRep_Tool::Triangulation( face, loc );
@ -944,7 +955,7 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
IFSG_COORDS vcoords( vface );
IFSG_COORDINDEX coordIdx( vface );
if( NULL == S3D::GetSGNodeParent( ocolor ) )
if( nullptr == S3D::GetSGNodeParent( ocolor ) )
S3D::AddSGNodeChild( vshape.GetRawPtr(), ocolor );
else
S3D::AddSGNodeRef( vshape.GetRawPtr(), ocolor );
@ -957,13 +968,13 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
std::vector< int > indices2;
gp_Trsf tx;
for(int i = 1; i <= triangulation->NbNodes(); i++)
for( int i = 1; i <= triangulation->NbNodes(); i++ )
{
gp_XYZ v( arrPolyNodes(i).Coord() );
vertices.emplace_back( v.X(), v.Y(), v.Z() );
}
for(int i = 1; i <= triangulation->NbTriangles(); i++)
for( int i = 1; i <= triangulation->NbTriangles(); i++ )
{
int a, b, c;
arrTriangles( i ).Get( a, b, c );
@ -974,7 +985,9 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
int tmp = b - 1;
b = c - 1;
c = tmp;
} else {
}
else
{
b--;
c--;
}
@ -993,12 +1006,11 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
vcoords.SetCoordsList( vertices.size(), &vertices[0] );
coordIdx.SetIndices( indices.size(), &indices[0] );
vface.CalcNormals( NULL );
vface.CalcNormals( nullptr );
vshape.SetParent( parent );
if( !partID.empty() )
data.faces.insert( std::pair< std::string,
SGNODE* >( partID, vshape.GetRawPtr() ) );
data.faces.insert( std::pair< std::string, SGNODE* >( partID, vshape.GetRawPtr() ) );
// The outer surface of an IGES model is indeterminate so
// we must render both sides of a surface.
@ -1014,12 +1026,11 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
vcoords2.SetCoordsList( vertices.size(), &vertices[0] );
coordIdx2.SetIndices( indices2.size(), &indices2[0] );
vface2.CalcNormals( NULL );
vface2.CalcNormals( nullptr );
vshape2.SetParent( parent );
if( !partID.empty() )
data.faces.insert( std::pair< std::string,
SGNODE* >( id2, vshape2.GetRawPtr() ) );
data.faces.insert( std::pair< std::string, SGNODE* >( id2, vshape2.GetRawPtr() ) );
}
return true;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2020 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2020-2021 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
@ -23,8 +23,7 @@
*/
/*
* Description:
* This plugin implements a STEP/IGES model renderer for KiCad via OCE
* This plugin implements a STEP/IGES model renderer for KiCad via OCE
*/
#include <wx/filename.h>
@ -66,6 +65,7 @@ void GetPluginVersion( unsigned char* Major,
return;
}
static struct FILE_DATA
{
std::vector<std::string> extensions;
@ -75,13 +75,21 @@ static struct FILE_DATA
{
#ifdef _WIN32
extensions = { "stp","step","stpz","stp.gz","step.gz","igs","iges" };
filters = { "STEP (*.stp;*.step;*.stpz;*.stp.gz;*.step.gz)|*.stp;*.step;*.stpz;*stp.gz;*.step.gz",
"IGES (*.igs;*.iges)|*.igs;*.iges" };
filters = {
"STEP (*.stp;*.step;*.stpz;*.stp.gz;*.step.gz)|*.stp;*.step;*.stpz;*stp.gz;*.step.gz",
"IGES (*.igs;*.iges)|*.igs;*.iges" };
#else
extensions = { "stp","STP","stpZ","stpz","STPZ","step","STEP","stp.gz","STP.GZ","step.gz","STEP.GZ","igs","IGS","iges","IGES" };
filters = { "STEP (*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;*.STEP.GZ)"
"|*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;*.STEP.GZ",
"IGES (*.igs;*.IGS;*.iges;*.IGES)|*.igs;*.IGS;*.iges;*.IGES" };
extensions = {
"stp","STP","stpZ","stpz","STPZ","step","STEP","stp.gz","STP.GZ","step.gz","STEP.GZ",
"igs","IGS","iges","IGES"
};
filters = {
"STEP (*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;"
"*.STEP.GZ)|*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;"
"*.step.gz;*.STEP.GZ",
"IGES (*.igs;*.IGS;*.iges;*.IGES)|*.igs;*.IGS;*.iges;*.IGES"
};
#endif
}
@ -97,7 +105,7 @@ int GetNExtensions( void )
char const* GetModelExtension( int aIndex )
{
if( aIndex < 0 || aIndex >= int( file_data.extensions.size() ) )
return NULL;
return nullptr;
return file_data.extensions[aIndex].c_str();
}
@ -112,7 +120,7 @@ int GetNFilters( void )
char const* GetFileFilter( int aIndex )
{
if( aIndex < 0 || aIndex >= int( file_data.filters.size() ) )
return NULL;
return nullptr;
return file_data.filters[aIndex].c_str();
}
@ -127,13 +135,13 @@ bool CanRender( void )
SCENEGRAPH* Load( char const* aFileName )
{
if( NULL == aFileName )
return NULL;
if( nullptr == aFileName )
return nullptr;
wxString fname = wxString::FromUTF8Unchecked( aFileName );
if( !wxFileName::FileExists( fname ) )
return NULL;
return nullptr;
return LoadModel( aFileName );
}

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 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
@ -38,7 +39,7 @@
#include "plugins/3dapi/ifsg_all.h"
WRL1BASE::WRL1BASE() : WRL1NODE( NULL )
WRL1BASE::WRL1BASE() : WRL1NODE( nullptr )
{
m_Type = WRL1NODES::WRL1_BASE;
m_dictionary = new NAMEREGISTER;
@ -48,26 +49,22 @@ WRL1BASE::WRL1BASE() : WRL1NODE( NULL )
WRL1BASE::~WRL1BASE()
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
wxLogTrace( MASK_VRML, " * [INFO] Destroying virtual base node\n" );
#endif
wxLogTrace( MASK_VRML, " * [INFO] Destroying virtual base node" );
cancelDict();
return;
}
// functions inherited from WRL1NODE
bool WRL1BASE::SetParent( WRL1NODE* aParent, bool /* doUnlink */ )
{
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] attempting to set parent on WRL1BASE node";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -75,14 +72,14 @@ bool WRL1BASE::SetParent( WRL1NODE* aParent, bool /* doUnlink */ )
std::string WRL1BASE::GetName( void )
{
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] attempting to extract name from virtual base node";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return std::string( "" );
}
@ -90,14 +87,14 @@ std::string WRL1BASE::GetName( void )
bool WRL1BASE::SetName( const std::string& aName )
{
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] attempting to set name on virtual base node";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -107,14 +104,14 @@ bool WRL1BASE::Read( WRLPROC& proc )
{
if( proc.GetVRMLType() != WRLVERSION::VRML_V1 )
{
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] no open file or file is not a VRML1 file";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -129,9 +126,9 @@ bool WRL1BASE::Read( WRLPROC& proc )
size_t line, column;
proc.GetFilePosData( line, column );
if( !ReadNode( proc, this, NULL ) )
if( !ReadNode( proc, this, nullptr ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -139,7 +136,7 @@ bool WRL1BASE::Read( WRLPROC& proc )
ostr << line << ", column " << column;
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -147,14 +144,14 @@ bool WRL1BASE::Read( WRLPROC& proc )
if( !proc.eof() )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -165,19 +162,19 @@ bool WRL1BASE::Read( WRLPROC& proc )
bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
if( !aParent )
{
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invoked with NULL parent";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -186,14 +183,14 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
if( !proc.ReadName( glob ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -201,23 +198,23 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
WRL1NODE* ref = aParent->FindNode( glob );
// return 'true' - the file may be defective but it may still be somewhat OK
if( NULL == ref )
if( nullptr == ref )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] node '" << glob << "' not found";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return true;
}
if( !aParent->AddRefNode( ref ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -226,12 +223,12 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = ref;
return true;
@ -240,36 +237,36 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
if( NULL == aParent )
if( nullptr == aParent )
{
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid parent pointer (NULL)";
ostr << " * [BUG] invalid parent pointer (nullptr)";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
std::string glob;
WRL1NODE* lnode = NULL;
WRL1NODE* lnode = nullptr;
if( !proc.ReadName( glob ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -279,12 +276,12 @@ bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
if( ReadNode( proc, aParent, &lnode ) )
{
if( NULL != aNode )
if( nullptr != aNode )
*aNode = lnode;
if( lnode && !lnode->SetName( glob ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
size_t line, column;
@ -294,7 +291,7 @@ bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
ostr << line << ", column " << column;
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -319,19 +316,19 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
// must always check the value of aNode when the function returns
// 'true' since it will be NULL if the node type is not supported.
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
if( NULL == aParent )
if( nullptr == aParent )
{
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid parent pointer (NULL)";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -341,7 +338,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
if( !proc.ReadName( glob ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
if( !proc.eof() )
{
std::ostringstream ostr;
@ -349,7 +346,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
ostr << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
}
#endif
#endif
return false;
}
@ -362,14 +359,14 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( !implementUse( proc, aParent, aNode ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -381,14 +378,14 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( !implementDef( proc, aParent, aNode ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -401,13 +398,13 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
size_t column = 0;
proc.GetFilePosData( line, column );
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
do {
std::ostringstream ostr;
ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype;
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
switch( ntype )
{
@ -486,7 +483,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
if( !proc.DiscardNode() )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << proc.GetError() << "\n";
@ -495,11 +492,11 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
ostr << ", column " << column;
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
else
{
std::ostringstream ostr;
@ -507,7 +504,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
ostr << line << ", col " << column << " (currently unsupported)";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
}
#endif
#endif
break;
}
@ -519,7 +516,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
bool WRL1BASE::Read( WRLPROC& proc, WRL1BASE* aTopNode )
{
// this function makes no sense in the base node
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << proc.GetError() << "\n";
@ -527,7 +524,7 @@ bool WRL1BASE::Read( WRLPROC& proc, WRL1BASE* aTopNode )
ostr << " * [BUG] this method must never be invoked on a WRL1BASE object";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -535,8 +532,8 @@ bool WRL1BASE::Read( WRLPROC& proc, WRL1BASE* aTopNode )
bool WRL1BASE::readGroup( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1GROUP* np = new WRL1GROUP( m_dictionary, aParent );
@ -546,7 +543,7 @@ bool WRL1BASE::readGroup( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -555,8 +552,8 @@ bool WRL1BASE::readGroup( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
bool WRL1BASE::readSeparator( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1SEPARATOR* np = new WRL1SEPARATOR( m_dictionary, aParent );
@ -566,7 +563,7 @@ bool WRL1BASE::readSeparator( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -583,7 +580,7 @@ bool WRL1BASE::readSwitch( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -592,8 +589,8 @@ bool WRL1BASE::readSwitch( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
bool WRL1BASE::readMaterial( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1MATERIAL* np = new WRL1MATERIAL( m_dictionary, aParent );
@ -603,7 +600,7 @@ bool WRL1BASE::readMaterial( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -612,8 +609,8 @@ bool WRL1BASE::readMaterial( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
bool WRL1BASE::readMatBinding( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1MATBINDING* np = new WRL1MATBINDING( m_dictionary, aParent );
@ -623,7 +620,7 @@ bool WRL1BASE::readMatBinding( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -632,8 +629,8 @@ bool WRL1BASE::readMatBinding( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod
bool WRL1BASE::readCoords( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1COORDS* np = new WRL1COORDS( m_dictionary, aParent );
@ -643,7 +640,7 @@ bool WRL1BASE::readCoords( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -652,8 +649,8 @@ bool WRL1BASE::readCoords( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
bool WRL1BASE::readFaceSet( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1FACESET* np = new WRL1FACESET( m_dictionary, aParent );
@ -663,7 +660,7 @@ bool WRL1BASE::readFaceSet( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -672,8 +669,8 @@ bool WRL1BASE::readFaceSet( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
bool WRL1BASE::readTransform( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1TRANSFORM* np = new WRL1TRANSFORM( m_dictionary, aParent );
@ -683,7 +680,7 @@ bool WRL1BASE::readTransform( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -692,8 +689,8 @@ bool WRL1BASE::readTransform( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
bool WRL1BASE::readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
{
if( NULL != aNode )
*aNode = NULL;
if( nullptr != aNode )
*aNode = nullptr;
WRL1SHAPEHINTS* np = new WRL1SHAPEHINTS( m_dictionary, aParent );
@ -703,7 +700,7 @@ bool WRL1BASE::readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod
return false;
}
if( NULL != aNode )
if( nullptr != aNode )
*aNode = (WRL1NODE*) np;
return true;
@ -712,20 +709,20 @@ bool WRL1BASE::readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod
SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
do {
std::ostringstream ostr;
ostr << " * [INFO] Translating VRML1 Base with " << m_Items.size();
ostr << " items";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
if( m_Items.empty() )
return NULL;
return nullptr;
if( m_Items.size() == 1 )
return (*m_Items.begin())->TranslateToSG( NULL, NULL );
return (*m_Items.begin())->TranslateToSG( nullptr, nullptr );
// Note: according to the VRML1 specification, a file may contain
// only one grouping node at the top level. The following code
@ -743,7 +740,7 @@ SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ )
while( sI != eI )
{
if( NULL != (*sI)->TranslateToSG( node, &m_current ) )
if( nullptr != (*sI)->TranslateToSG( node, &m_current ) )
hasContent = true;
++sI;
@ -752,7 +749,7 @@ SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ )
if( !hasContent )
{
txNode.Destroy();
return NULL;
return nullptr;
}
return node;

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 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
@ -33,7 +34,6 @@
WRL1COORDS::WRL1COORDS( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary )
{
m_Type = WRL1NODES::WRL1_COORDINATE3;
return;
}
@ -43,20 +43,16 @@ WRL1COORDS::WRL1COORDS( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
m_Type = WRL1NODES::WRL1_COORDINATE3;
m_Parent = aParent;
if( NULL != m_Parent )
if( nullptr != m_Parent )
m_Parent->AddChildNode( this );
return;
}
WRL1COORDS::~WRL1COORDS()
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate3 node\n" );
#endif
return;
#endif
}
@ -64,14 +60,14 @@ bool WRL1COORDS::AddRefNode( WRL1NODE* aNode )
{
// this node may not own or reference any other node
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] AddRefNode is not applicable";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -81,14 +77,14 @@ bool WRL1COORDS::AddChildNode( WRL1NODE* aNode )
{
// this node may not own or reference any other node
#ifdef DEBUG_VRML1
#ifdef DEBUG_VRML1
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] AddChildNode is not applicable";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -103,7 +99,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
if( proc.eof() )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -111,14 +107,14 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
ostr << line << ", column " << column;
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
if( '{' != tok )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << proc.GetError() << "\n";
@ -127,7 +123,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
ostr << "' at line " << line << ", column " << column << "\n";
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -143,14 +139,14 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
if( !proc.ReadName( glob ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -162,7 +158,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
{
if( !proc.ReadMFVec3f( points ) )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -172,14 +168,14 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
ostr << " * [INFO] message: '" << proc.GetError();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
}
else
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -188,12 +184,12 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
ostr << " * [INFO] file: '" << proc.GetFileName();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
// assuming legacy kicad expectation of 1U = 0.1 inch,
// assuming legacy KiCad expectation of 1U = 0.1 inch,
// convert to mm to meet the expectations of the SG structure
std::vector< WRLVEC3F >::iterator sP = points.begin();
std::vector< WRLVEC3F >::iterator eP = points.end();
@ -214,7 +210,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
proc.GetFilePosData( line, column );
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
@ -223,7 +219,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
ostr << " * [INFO] file: '" << proc.GetFileName();
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
#endif
return false;
}
@ -233,29 +229,26 @@ void WRL1COORDS::GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize )
{
if( points.size() < 3 )
{
aCoordList = NULL;
aCoordList = nullptr;
aListSize = 0;
return;
}
aCoordList = &points[0];
aListSize = points.size();
return;
}
SGNODE* WRL1COORDS::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
{
if( NULL == sp )
if( nullptr == sp )
{
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" );
#endif
return NULL;
return nullptr;
}
sp->coord = this;
return NULL;
return nullptr;
}

Some files were not shown because too many files have changed in this diff Show More