Include folder and 3D viewer code housekeeping.

This commit is contained in:
Wayne Stambaugh 2025-01-10 20:30:25 -05:00
parent 30d43c30b7
commit 42a1d1cf0b
54 changed files with 767 additions and 593 deletions

View File

@ -211,7 +211,8 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePa
} }
SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath, const EMBEDDED_FILES* aEmbeddedFiles ) SCENEGRAPH* S3D_CACHE::Load( const wxString& aModelFile, const wxString& aBasePath,
const EMBEDDED_FILES* aEmbeddedFiles )
{ {
return load( aModelFile, aBasePath, nullptr, aEmbeddedFiles ); return load( aModelFile, aBasePath, nullptr, aEmbeddedFiles );
} }
@ -612,4 +613,4 @@ void S3D_CACHE::CleanCacheDir( int aNumDaysOld )
} }
} }
} }
} }

View File

@ -63,7 +63,7 @@ public:
} }
/** /**
* Sets the configuration directory to be used by the model manager for storing 3D * Set the configuration directory to be used by the model manager for storing 3D
* model manager configuration data and the model cache. * model manager configuration data and the model cache.
* *
* The config directory may only be set once in the lifetime of the object. * The config directory may only be set once in the lifetime of the object.
@ -98,7 +98,8 @@ public:
* @param aEmbeddedFiles is a pointer to the embedded files list. * @param aEmbeddedFiles is a pointer to the embedded files list.
* @return true if the model was successfully loaded, otherwise false. * @return true if the model was successfully loaded, otherwise false.
*/ */
SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath, const EMBEDDED_FILES* aEmbeddedFiles ); SCENEGRAPH* Load( const wxString& aModelFile, const wxString& aBasePath,
const EMBEDDED_FILES* aEmbeddedFiles );
FILENAME_RESOLVER* GetResolver() noexcept; FILENAME_RESOLVER* GetResolver() noexcept;
@ -130,7 +131,8 @@ public:
* @param aEmbeddedFiles is a pointer to the embedded files list. * @param aEmbeddedFiles is a pointer to the embedded files list.
* @return is a pointer to the render data or NULL if not available. * @return is a pointer to the render data or NULL if not available.
*/ */
S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath, const EMBEDDED_FILES* aEmbeddedFiles ); S3DMODEL* GetModel( const wxString& aModelFileName, const wxString& aBasePath,
const EMBEDDED_FILES* aEmbeddedFiles );
/** /**
* Delete up old cache files in cache directory. * Delete up old cache files in cache directory.
@ -172,12 +174,12 @@ private:
// the real load function (can supply a cache entry pointer to member functions) // the real load function (can supply a cache entry pointer to member functions)
SCENEGRAPH* load( const wxString& aModelFile, const wxString& aBasePath, SCENEGRAPH* load( const wxString& aModelFile, const wxString& aBasePath,
S3D_CACHE_ENTRY** aCachePtr = nullptr, S3D_CACHE_ENTRY** aCachePtr = nullptr,
const EMBEDDED_FILES* aEmbeddedFiles = nullptr ); const EMBEDDED_FILES* aEmbeddedFiles = nullptr );
/// cache entries /// Cache entries.
std::list< S3D_CACHE_ENTRY* > m_CacheList; std::list< S3D_CACHE_ENTRY* > m_CacheList;
/// mapping of file names to cache names and data /// Mapping of file names to cache names and data.
std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString > m_CacheMap; std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString > m_CacheMap;
FILENAME_RESOLVER* m_FNResolver; FILENAME_RESOLVER* m_FNResolver;
@ -186,7 +188,7 @@ private:
PROJECT* m_project; PROJECT* m_project;
wxString m_CacheDir; wxString m_CacheDir;
wxString m_ConfigDir; /// base configuration path for 3D items wxString m_ConfigDir; ///< base configuration path for 3D items.
}; };
#endif // CACHE_3D_H #endif // CACHE_3D_H

View File

@ -444,7 +444,8 @@ SCENEGRAPH* S3D_PLUGIN_MANAGER::Load3DModel( const wxString& aFileName, std::str
ext_to_find.MakeLower(); ext_to_find.MakeLower();
#endif #endif
// .gz files are compressed versions that may have additional information in the previous extension // .gz files are compressed versions that may have additional information in the previous
// extension.
if( ext_to_find == wxT( "gz" ) ) if( ext_to_find == wxT( "gz" ) )
{ {
wxFileName second( raw.GetName() ); wxFileName second( raw.GetName() );
@ -518,8 +519,7 @@ bool S3D_PLUGIN_MANAGER::CheckTag( const char* aTag )
ptag.clear(); ptag.clear();
(*pS)->GetPluginInfo( ptag ); (*pS)->GetPluginInfo( ptag );
// if the plugin name matches then the version // if the plugin name matches then the version must also match
// must also match
if( !ptag.compare( 0, pname.size(), pname ) ) if( !ptag.compare( 0, pname.size(), pname ) )
{ {
if( ptag.compare( tname ) ) if( ptag.compare( tname ) )

View File

@ -374,7 +374,8 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
m_nonCopperLayerThickness3DU = DEFAULT_TECH_LAYER_THICKNESS * m_biuTo3Dunits; m_nonCopperLayerThickness3DU = DEFAULT_TECH_LAYER_THICKNESS * m_biuTo3Dunits;
m_solderPasteLayerThickness3DU = SOLDERPASTE_LAYER_THICKNESS * m_biuTo3Dunits; m_solderPasteLayerThickness3DU = SOLDERPASTE_LAYER_THICKNESS * m_biuTo3Dunits;
g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 ) * m_biuTo3Dunits; g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 )
* m_biuTo3Dunits;
if( m_board ) if( m_board )
{ {
@ -395,9 +396,10 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
case BS_ITEM_TYPE_COPPER: case BS_ITEM_TYPE_COPPER:
{ {
// The copper thickness must be > 0 to avoid draw issues (divide by 0 for instance) // The copper thickness must be > 0 to avoid draw issues (divide by 0 for
// We use a minimal arbitrary value = 1 micrometer here: // instance). We use a minimal arbitrary value = 1 micrometer here:
int copper_thickness = std::max( item->GetThickness(), pcbIUScale.mmToIU( 0.001 ) ); int copper_thickness = std::max( item->GetThickness(),
pcbIUScale.mmToIU( 0.001 ) );
if( item->GetBrdLayerId() == F_Cu ) if( item->GetBrdLayerId() == F_Cu )
m_frontCopperThickness3DU = copper_thickness * m_biuTo3Dunits; m_frontCopperThickness3DU = copper_thickness * m_biuTo3Dunits;
@ -419,8 +421,10 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
// Init Z position of each layer // Init Z position of each layer
// calculate z position for each copper layer // calculate z position for each copper layer
// Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = B_Cu) // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer)
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = F_Cu) // (layer id = B_Cu)
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer)
// (layer id = F_Cu)
// ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0, // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
// | | Top = Bottom + m_copperThickness // | | Top = Bottom + m_copperThickness
@ -470,12 +474,14 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR
continue; continue;
m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] = zpos_copperTop_back - 2.0f * zpos_offset; m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] = zpos_copperTop_back - 2.0f * zpos_offset;
m_layerZcoordTop[(PCB_LAYER_ID)layer_id] = m_layerZcoordBottom[(PCB_LAYER_ID)layer_id] - m_backCopperThickness3DU; m_layerZcoordTop[(PCB_LAYER_ID) layer_id] =
m_layerZcoordBottom[(PCB_LAYER_ID) layer_id] - m_backCopperThickness3DU;
} }
// calculate z position for each technical layer // calculate z position for each technical layer
// Solder mask and Solder paste have the same Z position // Solder mask and Solder paste have the same Z position
for( PCB_LAYER_ID layer_id : { B_Adhes, B_Mask, B_Paste, F_Adhes, F_Mask, F_Paste, B_SilkS, F_SilkS } ) for( PCB_LAYER_ID layer_id :
{ B_Adhes, B_Mask, B_Paste, F_Adhes, F_Mask, F_Paste, B_SilkS, F_SilkS } )
{ {
float zposTop = 0.0; float zposTop = 0.0;
float zposBottom = 0.0; float zposBottom = 0.0;
@ -641,7 +647,8 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
// Can't do a const KIGFX::COLOR4D& return type here because there are temporary variables // Can't do a const KIGFX::COLOR4D& return type here because there are temporary variables
auto findColor = auto findColor =
[]( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D []( const wxString& aColorName,
const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D
{ {
if( aColorName.StartsWith( wxT( "#" ) ) ) if( aColorName.StartsWith( wxT( "#" ) ) )
{ {

View File

@ -140,7 +140,7 @@ public:
double BiuTo3dUnits() const noexcept { return m_biuTo3Dunits; } double BiuTo3dUnits() const noexcept { return m_biuTo3Dunits; }
/** /**
* Get the board outling bounding box. * Get the board outline bounding box.
* *
* @return the board bounding box in 3D units. * @return the board bounding box in 3D units.
*/ */
@ -352,8 +352,16 @@ public:
*/ */
const MAP_POLY& GetPolyMap() const noexcept { return m_layers_poly; } const MAP_POLY& GetPolyMap() const noexcept { return m_layers_poly; }
const SHAPE_POLY_SET* GetFrontPlatedPadAndGraphicPolys() { return m_frontPlatedPadAndGraphicPolys; } const SHAPE_POLY_SET* GetFrontPlatedPadAndGraphicPolys()
const SHAPE_POLY_SET* GetBackPlatedPadAndGraphicPolys() { return m_backPlatedPadAndGraphicPolys; } {
return m_frontPlatedPadAndGraphicPolys;
}
const SHAPE_POLY_SET* GetBackPlatedPadAndGraphicPolys()
{
return m_backPlatedPadAndGraphicPolys;
}
const MAP_POLY& GetHoleIdPolysMap() const noexcept { return m_layerHoleIdPolys; } const MAP_POLY& GetHoleIdPolysMap() const noexcept { return m_layerHoleIdPolys; }
const MAP_POLY& GetHoleOdPolysMap() const noexcept { return m_layerHoleOdPolys; } const MAP_POLY& GetHoleOdPolysMap() const noexcept { return m_layerHoleOdPolys; }
@ -403,8 +411,8 @@ private:
PCB_LAYER_ID aLayerId ); PCB_LAYER_ID aLayerId );
void createArcSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart, void createArcSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount, int aWidth, const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount, int aWidth,
CONTAINER_2D_BASE* aContainer, const BOARD_ITEM& aOwner ); CONTAINER_2D_BASE* aContainer, const BOARD_ITEM& aOwner );
void buildPadOutlineAsSegments( const PAD* aPad, PCB_LAYER_ID aLayer, void buildPadOutlineAsSegments( const PAD* aPad, PCB_LAYER_ID aLayer,
CONTAINER_2D_BASE* aDstContainer, int aWidth ); CONTAINER_2D_BASE* aDstContainer, int aWidth );

View File

@ -219,9 +219,11 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2
{ {
if( !aVisibilityFlags.test( LAYER_FP_TEXT ) ) if( !aVisibilityFlags.test( LAYER_FP_TEXT ) )
continue; continue;
else if( text->GetText() == wxT( "${REFERENCE}" ) && !aVisibilityFlags.test( LAYER_FP_REFERENCES ) ) else if( text->GetText() == wxT( "${REFERENCE}" )
&& !aVisibilityFlags.test( LAYER_FP_REFERENCES ) )
continue; continue;
else if( text->GetText() == wxT( "${VALUE}" ) && !aVisibilityFlags.test( LAYER_FP_VALUES ) ) else if( text->GetText() == wxT( "${VALUE}" )
&& !aVisibilityFlags.test( LAYER_FP_VALUES ) )
continue; continue;
addText( text, aContainer, text ); addText( text, aContainer, text );
@ -396,7 +398,8 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
} }
else else
{ {
auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( aLayer ) ); auto padShapes =
std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( aLayer ) );
for( const SHAPE* shape : padShapes->Shapes() ) for( const SHAPE* shape : padShapes->Shapes() )
{ {
@ -483,7 +486,7 @@ void BOARD_ADAPTER::createPadWithMargin( const PAD* aPad, CONTAINER_2D_BASE* aCo
void BOARD_ADAPTER::createPadWithHole( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer, void BOARD_ADAPTER::createPadWithHole( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
int aInflateValue ) int aInflateValue )
{ {
if( !aPad->HasHole() ) if( !aPad->HasHole() )
{ {
@ -706,7 +709,7 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta
ERROR_INSIDE ); ERROR_INSIDE );
// Some polygons can be a bit complex (especially when coming from a // Some polygons can be a bit complex (especially when coming from a
// picture ot a text converted to a polygon // picture of a text converted to a polygon
// So call Simplify before calling ConvertPolygonToTriangles, just in case. // So call Simplify before calling ConvertPolygonToTriangles, just in case.
polyList.Simplify(); polyList.Simplify();

View File

@ -348,7 +348,8 @@ void EDA_3D_CANVAS::DisplayStatus()
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::Y_POS ) ); m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::Y_POS ) );
msg.Printf( wxT( "zoom %3.2f" ), 1 / m_camera.GetZoom() ); msg.Printf( wxT( "zoom %3.2f" ), 1 / m_camera.GetZoom() );
m_parentStatusBar->SetStatusText( msg, static_cast<int>( EDA_3D_VIEWER_STATUSBAR::ZOOM_LEVEL ) ); m_parentStatusBar->SetStatusText( msg,
static_cast<int>( EDA_3D_VIEWER_STATUSBAR::ZOOM_LEVEL ) );
} }
} }
@ -479,7 +480,7 @@ void EDA_3D_CANVAS::DoRePaint()
if( m_camera_is_moving ) if( m_camera_is_moving )
{ {
const int64_t curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement; const int64_t curtime_delta = GetRunningMicroSecs() - m_strtime_camera_movement;
curtime_delta_s = (curtime_delta / 1e6) * m_camera_moving_speed; curtime_delta_s = ( curtime_delta / 1e6 ) * m_camera_moving_speed;
m_camera.Interpolate( curtime_delta_s ); m_camera.Interpolate( curtime_delta_s );
if( curtime_delta_s > 1.0f ) if( curtime_delta_s > 1.0f )

View File

@ -109,16 +109,16 @@ public:
void RenderRaytracingRequest(); void RenderRaytracingRequest();
/** /**
* Request a screenshot and output it to the \a aDstImage * Request a screenshot and output it to the \a aDstImage.
* *
* @param aDstImage - Screenshot destination image * @param aDstImage - Screenshot destination image.
*/ */
void GetScreenshot( wxImage& aDstImage ); void GetScreenshot( wxImage& aDstImage );
/** /**
* Select a specific 3D view or operation * Select a specific 3D view or operation.
* *
* @param aRequestedView the view to move to * @param aRequestedView the view to move to.
* @return true if the view request was handled, false if no command found for this view. * @return true if the view request was handled, false if no command found for this view.
*/ */
bool SetView3D( VIEW3D_TYPE aRequestedView ); bool SetView3D( VIEW3D_TYPE aRequestedView );
@ -331,7 +331,7 @@ private:
bool m_render3dmousePivot = false; // Render the 3dmouse pivot bool m_render3dmousePivot = false; // Render the 3dmouse pivot
SFVEC3F m_3dmousePivotPos; // The position of the 3dmouse pivot SFVEC3F m_3dmousePivotPos; // The position of the 3dmouse pivot
///< Used to track gesture events. /// Used to track gesture events.
double m_gestureLastZoomFactor = 1.0; double m_gestureLastZoomFactor = 1.0;
double m_gestureLastAngle = 0.0; double m_gestureLastAngle = 0.0;

View File

@ -44,8 +44,8 @@
#include <macros.h> #include <macros.h>
/** /**
* Scale conversion from 3d model units to pcb units * Scale conversion from 3d model units to pcb units
*/ */
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM ) #define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
/** /**

View File

@ -24,7 +24,7 @@
#include <3d-viewer/3d_rendering/track_ball.h> #include <3d-viewer/3d_rendering/track_ball.h>
#include <3d-viewer/3d_canvas/eda_3d_canvas.h> #include <3d-viewer/3d_canvas/eda_3d_canvas.h>
// KiCAD includes // KiCad includes
#include <tool/action_manager.h> #include <tool/action_manager.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/tools_holder.h> #include <tool/tools_holder.h>
@ -73,7 +73,8 @@ bool equals( glm::mat<L, C, T, Q> const& aFirst, glm::mat<L, C, T, Q> const& aSe
} }
NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas, const std::string& aProfileHint ) : NL_3D_VIEWER_PLUGIN_IMPL::NL_3D_VIEWER_PLUGIN_IMPL( EDA_3D_CANVAS* aCanvas,
const std::string& aProfileHint ) :
NAV_3D( false, false ), NAV_3D( false, false ),
m_canvas( aCanvas ), m_canvas( aCanvas ),
m_capIsMoving( false ), m_capIsMoving( false ),
@ -111,15 +112,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::Connect()
exportCommandsAndImages(); exportCommandsAndImages();
} }
/**
* Add a category to the store.
*
* The function adds category paths of the format "A.B" where B is a sub-category of A.
*
* @param aCategoryPath is the std::string representation of the category.
* @param aCategoryStore is the CATEGORY_STORE instance to add to.
* @return a CATEGORY_STORE::iterator where the category was added.
*/
CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore ) CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore )
{ {
using TDx::SpaceMouse::CCategory; using TDx::SpaceMouse::CCategory;
@ -192,7 +185,7 @@ void NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages()
std::string name = action->GetName(); std::string name = action->GetName();
// Do no export commands for the pcbnew app. // Do no export commands for the Pcbnew app.
if( name.rfind( "pcbnew.", 0 ) == 0 ) if( name.rfind( "pcbnew.", 0 ) == 0 )
{ {
continue; continue;

View File

@ -29,7 +29,7 @@
// TDxWare SDK. // TDxWare SDK.
#include <SpaceMouse/CNavigation3D.hpp> #include <SpaceMouse/CNavigation3D.hpp>
// KiCAD // KiCad
#include <include/plugins/3dapi/xv3d_types.h> #include <include/plugins/3dapi/xv3d_types.h>
// wx // wx
@ -45,6 +45,15 @@ class TRACK_BALL;
// temporary store for the categories // temporary store for the categories
typedef std::map<std::string, TDx::CCommandTreeNode*> CATEGORY_STORE; typedef std::map<std::string, TDx::CCommandTreeNode*> CATEGORY_STORE;
/**
* Add a category to the store.
*
* The function adds category paths of the format "A.B" where B is a sub-category of A.
*
* @param aCategoryPath is the std::string representation of the category.
* @param aCategoryStore is the CATEGORY_STORE instance to add to.
* @return a CATEGORY_STORE::iterator where the category was added.
*/
CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore ); CATEGORY_STORE::iterator add_category( std::string aCategoryPath, CATEGORY_STORE& aCategoryStore );
// Convenience typedef. // Convenience typedef.

View File

@ -31,13 +31,14 @@
#include <SpaceMouse/CNavigation3D.hpp> #include <SpaceMouse/CNavigation3D.hpp>
/** /**
* The class that adjusts NL_3D_VIEWER_PLUGIN_IMPL implementation for 3D Model preview in footprint properties dialog. * The class that adjusts NL_3D_VIEWER_PLUGIN_IMPL implementation for 3D Model preview in
* footprint properties dialog.
*/ */
class NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL : public NL_3D_VIEWER_PLUGIN_IMPL class NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL : public NL_3D_VIEWER_PLUGIN_IMPL
{ {
public: public:
/** /**
* Initializes a new instance of the NL_FOOTPRINT_PROPERTIES_PLUGIN. * Initialize a new instance of the NL_FOOTPRINT_PROPERTIES_PLUGIN.
* *
* @param aCanvas is the viewport to be navigated. * @param aCanvas is the viewport to be navigated.
*/ */
@ -60,8 +61,8 @@ private:
/** /**
* Trace mask used to enable or disable the trace output of this class. * Trace mask used to enable or disable the trace output of this class.
* The debug output can be turned on by setting the WXTRACE environment variable to * The debug output can be turned on by setting the WXTRACE environment variable to
* "KI_TRACE_NL_FOOTPRINT_PROPERTIES_PLUGIN". See the wxWidgets documentation on wxLogTrace for * "KI_TRACE_NL_FOOTPRINT_PROPERTIES_PLUGIN". See the wxWidgets documentation on
* more information. * wxLogTrace for more information.
*/ */
static const wxChar* m_logTrace; static const wxChar* m_logTrace;
}; };

View File

@ -98,8 +98,8 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
/** /**
* WARNING: Horrible hack here! * WARNING: Horrible hack here!
* Somehow, buffer values are being shared between pcbnew and the 3d viewer, which then frees * Somehow, buffer values are being shared between Pcbnew and the 3d viewer, which then frees
* the buffer, resulting in errors in pcbnew. To resolve this temporarily, we generate * the buffer, resulting in errors in Pcbnew. To resolve this temporarily, we generate
* extra buffers in 3dviewer and use the higher numbers. These are freed on close. * extra buffers in 3dviewer and use the higher numbers. These are freed on close.
* todo: Correctly separate the OpenGL contexts to prevent overlapping buffer vals * todo: Correctly separate the OpenGL contexts to prevent overlapping buffer vals
*/ */
@ -332,7 +332,8 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
// temporary index buffer which will contain either GLushort or GLuint // temporary index buffer which will contain either GLushort or GLuint
// type indices. allocate with a bit of meadow at the end. // type indices. allocate with a bit of meadow at the end.
auto tmp_idx = std::make_unique<GLuint[]>( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) ); auto tmp_idx =
std::make_unique<GLuint[]>( ( idx_size * total_index_count + 8 ) / sizeof( GLuint ) );
unsigned int prev_vtx_count = 0; unsigned int prev_vtx_count = 0;
unsigned int idx_offset = 0; unsigned int idx_offset = 0;
@ -507,9 +508,9 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
{ {
for( const MODEL_3D::MATERIAL& mat : m_materials ) for( const MODEL_3D::MATERIAL& mat : m_materials )
{ {
// There is at least one default material created in case a mesh has no declared materials. // There is at least one default material created in case a mesh has no declared
// Most meshes have a material, so usually the first material will have nothing to render and is skip. // materials. Most meshes have a material, so usually the first material will have
// See S3D::GetModel for more details. // nothing to render and is skip. See S3D::GetModel for more details.
if( mat.m_render_idx_count == 0 ) if( mat.m_render_idx_count == 0 )
{ {
continue; continue;
@ -535,7 +536,8 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
break; break;
case MATERIAL_MODE::DIFFUSE_ONLY: case MATERIAL_MODE::DIFFUSE_ONLY:
OglSetDiffuseMaterial( mat->m_Diffuse, aOpacity, aUseSelectedMaterial, aSelectionColor ); OglSetDiffuseMaterial( mat->m_Diffuse, aOpacity, aUseSelectedMaterial,
aSelectionColor );
break; break;
case MATERIAL_MODE::CAD_MODE: case MATERIAL_MODE::CAD_MODE:

View File

@ -146,7 +146,8 @@ private:
unsigned int m_render_idx_buffer_offset = 0; unsigned int m_render_idx_buffer_offset = 0;
unsigned int m_render_idx_count = 0; unsigned int m_render_idx_count = 0;
BBOX_3D m_bbox; ///< bounding box for this material group, used for transparent material ordering BBOX_3D m_bbox; ///< bounding box for this material group, used for transparent
///< material ordering.
MATERIAL( const SMATERIAL& aOther ) : SMATERIAL( aOther ) { } MATERIAL( const SMATERIAL& aOther ) : SMATERIAL( aOther ) { }
bool IsTransparent() const { return m_Transparency > FLT_EPSILON; } bool IsTransparent() const { return m_Transparency > FLT_EPSILON; }

View File

@ -607,8 +607,10 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( m_boardAdapter.m_Cfg->m_Render.DifferentiatePlatedCopper() ) if( m_boardAdapter.m_Cfg->m_Render.DifferentiatePlatedCopper() )
{ {
const SHAPE_POLY_SET* frontPlatedPadAndGraphicPolys = m_boardAdapter.GetFrontPlatedPadAndGraphicPolys(); const SHAPE_POLY_SET* frontPlatedPadAndGraphicPolys =
const SHAPE_POLY_SET* backPlatedPadAndGraphicPolys = m_boardAdapter.GetBackPlatedPadAndGraphicPolys(); m_boardAdapter.GetFrontPlatedPadAndGraphicPolys();
const SHAPE_POLY_SET* backPlatedPadAndGraphicPolys =
m_boardAdapter.GetBackPlatedPadAndGraphicPolys();
if( frontPlatedPadAndGraphicPolys ) if( frontPlatedPadAndGraphicPolys )
{ {
@ -617,7 +619,8 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
poly.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() ); poly.BooleanSubtract( m_boardAdapter.GetTH_ODPolys() );
poly.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() ); poly.BooleanSubtract( m_boardAdapter.GetNPTH_ODPolys() );
m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(), &poly, F_Cu ); m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(), &poly,
F_Cu );
// An entry for F_Cu must exist in m_layers or we'll never look at m_platedPadsFront // An entry for F_Cu must exist in m_layers or we'll never look at m_platedPadsFront
if( m_layers.count( F_Cu ) == 0 ) if( m_layers.count( F_Cu ) == 0 )
@ -965,7 +968,9 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
{ {
// It is not present, try get it from cache // It is not present, try get it from cache
const S3DMODEL* modelPtr = const S3DMODEL* modelPtr =
m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename, footprintBasePath, footprint ); m_boardAdapter.Get3dCacheManager()->GetModel( fp_model.m_Filename,
footprintBasePath,
footprint );
// only add it if the return is not NULL // only add it if the return is not NULL
if( modelPtr ) if( modelPtr )

View File

@ -129,7 +129,7 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >&
{ {
if( aContournPoints.size() >= 4 ) if( aContournPoints.size() >= 4 )
{ {
// Calculate normals of each segment of the contourn // Calculate normals of each segment of the contour
std::vector< SFVEC2F > contournNormals; std::vector< SFVEC2F > contournNormals;
contournNormals.clear(); contournNormals.clear();
@ -245,7 +245,7 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlin
} }
} }
// Add first position fo the list to close the path // Add first position of the list to close the path.
if( lastV != contournPoints[0] ) if( lastV != contournPoints[0] )
contournPoints.push_back( contournPoints[0] ); contournPoints.push_back( contournPoints[0] );
@ -472,10 +472,10 @@ void OPENGL_RENDER_LIST::DrawAll( bool aDrawMiddle ) const
void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle, void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
const OPENGL_RENDER_LIST* aSubtractList, const OPENGL_RENDER_LIST* aSubtractList,
const OPENGL_RENDER_LIST* bSubtractList, const OPENGL_RENDER_LIST* bSubtractList,
const OPENGL_RENDER_LIST* cSubtractList, const OPENGL_RENDER_LIST* cSubtractList,
const OPENGL_RENDER_LIST* dSubtractList ) const const OPENGL_RENDER_LIST* dSubtractList ) const
{ {
glClearStencil( 0x00 ); glClearStencil( 0x00 );
glClear( GL_STENCIL_BUFFER_BIT ); glClear( GL_STENCIL_BUFFER_BIT );
@ -502,8 +502,8 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
if( dSubtractList ) if( dSubtractList )
dSubtractList->DrawBot(); dSubtractList->DrawBot();
glEnable(GL_DEPTH_TEST); glEnable( GL_DEPTH_TEST );
glDepthMask(GL_TRUE); glDepthMask( GL_TRUE );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
glStencilFunc( GL_EQUAL, 0, 1 ); glStencilFunc( GL_EQUAL, 0, 1 );
@ -529,8 +529,8 @@ void OPENGL_RENDER_LIST::DrawCulled( bool aDrawMiddle,
if( dSubtractList ) if( dSubtractList )
dSubtractList->DrawTop(); dSubtractList->DrawTop();
glEnable(GL_DEPTH_TEST); glEnable( GL_DEPTH_TEST );
glDepthMask(GL_TRUE); glDepthMask( GL_TRUE );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
glStencilFunc( GL_NOTEQUAL, 2, 0x03 ); glStencilFunc( GL_NOTEQUAL, 2, 0x03 );
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
@ -584,11 +584,11 @@ void OPENGL_RENDER_LIST::SetItIsTransparent( bool aSetTransparent )
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends( GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp, GLuint aTextureId ) const const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp, GLuint aTextureId ) const
{ {
wxASSERT( aTriangleContainer != nullptr ); wxCHECK( aTriangleContainer != nullptr, 0 );
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ); wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
// Top and Bot dont have normals array stored in container // Top and Bot don't have normals array stored in container
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 ); wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
if( ( aTriangleContainer->GetVertexSize() > 0 ) if( ( aTriangleContainer->GetVertexSize() > 0 )
@ -651,11 +651,11 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer, GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
bool aIsNormalUp ) const bool aIsNormalUp ) const
{ {
wxASSERT( aTriangleContainer != nullptr ); wxCHECK( aTriangleContainer != nullptr, 0 );
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ); wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
// Top and Bot dont have normals array stored in container // Top and Bot dint have normals array stored in container
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 ); wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
if( ( aTriangleContainer->GetVertexSize() > 0 ) if( ( aTriangleContainer->GetVertexSize() > 0 )
@ -695,7 +695,7 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* a
GLuint OPENGL_RENDER_LIST::generate_middle_triangles( GLuint OPENGL_RENDER_LIST::generate_middle_triangles(
const TRIANGLE_LIST* aTriangleContainer ) const const TRIANGLE_LIST* aTriangleContainer ) const
{ {
wxASSERT( aTriangleContainer != nullptr ); wxCHECK( aTriangleContainer != nullptr, 0 );
// We expect that it is a multiple of 3 vertex // We expect that it is a multiple of 3 vertex
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 ); wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
@ -767,3 +767,5 @@ void OPENGL_RENDER_LIST::beginTransformation() const
glScalef( 1.0f, 1.0f, m_zScaleTransformation ); glScalef( 1.0f, 1.0f, m_zScaleTransformation );
} }
} }
// LocalWords: EDA Luzeiro txt MERCHANTABILITY wxASSERT normals fo

View File

@ -605,7 +605,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( layerFlags.test( LAYER_3D_BOARD ) && m_boardAdapter.m_BoardBodyColor.a > opacity_min ) if( layerFlags.test( LAYER_3D_BOARD ) && m_boardAdapter.m_BoardBodyColor.a > opacity_min )
{ {
// generating internal copper layers is time consumming. so skip them // generating internal copper layers is time consuming. so skip them
// if the board body is masking them (i.e. if the opacity is near 1.0) // if the board body is masking them (i.e. if the opacity is near 1.0)
// B_Cu is layer 2 and all inner layers are higher values // B_Cu is layer 2 and all inner layers are higher values
if( layer > B_Cu && IsCopperLayer( layer ) ) if( layer > B_Cu && IsCopperLayer( layer ) )
@ -716,7 +716,8 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
renderBoardBody( skipRenderHoles ); renderBoardBody( skipRenderHoles );
// Display transparent mask layers // Display transparent mask layers
if( layerFlags.test( LAYER_3D_SOLDERMASK_TOP ) || layerFlags.test( LAYER_3D_SOLDERMASK_BOTTOM ) ) if( layerFlags.test( LAYER_3D_SOLDERMASK_TOP )
|| layerFlags.test( LAYER_3D_SOLDERMASK_BOTTOM ) )
{ {
// add a depth buffer offset, it will help to hide some artifacts // add a depth buffer offset, it will help to hide some artifacts
// on silkscreen where the SolderMask is removed // on silkscreen where the SolderMask is removed
@ -766,7 +767,9 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// Enables Texture Env so it can combine model transparency with each footprint opacity // Enables Texture Env so it can combine model transparency with each footprint opacity
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE0 ); glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, m_circleTexture ); // Uses an existent texture so the glTexEnv operations will work
// Uses an existent texture so the glTexEnv operations will work.
glBindTexture( GL_TEXTURE_2D, m_circleTexture );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE ); glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
@ -985,7 +988,8 @@ void RENDER_3D_OPENGL::get3dModelsSelected( std::list<MODELTORENDER> &aDstRender
const bool isFlipped = fp->IsFlipped(); const bool isFlipped = fp->IsFlipped();
if( aGetTop == !isFlipped || aGetBot == isFlipped ) if( aGetTop == !isFlipped || aGetBot == isFlipped )
get3dModelsFromFootprint( aDstRenderList, fp, aRenderTransparentOnly, highlight ); get3dModelsFromFootprint( aDstRenderList, fp, aRenderTransparentOnly,
highlight );
} }
} }
} }
@ -1046,7 +1050,8 @@ void RENDER_3D_OPENGL::get3dModelsFromFootprint( std::list<MODELTORENDER> &aDstR
glm::mat4 modelworldMatrix = fpMatrix; glm::mat4 modelworldMatrix = fpMatrix;
const SFVEC3F offset = SFVEC3F( sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z ); const SFVEC3F offset = SFVEC3F( sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z );
const SFVEC3F rotation = SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y, sM.m_Rotation.z ); const SFVEC3F rotation = SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y,
sM.m_Rotation.z );
const SFVEC3F scale = SFVEC3F( sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z ); const SFVEC3F scale = SFVEC3F( sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z );
std::vector<float> key = { offset.x, offset.y, offset.z, std::vector<float> key = { offset.x, offset.y, offset.z,

View File

@ -848,7 +848,7 @@ BVHBuildNode *BVH_PBRT::emitLBVH( BVHBuildNode* &buildNodes,
while( searchStart + 1 != searchEnd ) while( searchStart + 1 != searchEnd )
{ {
wxASSERT(searchStart != searchEnd); wxASSERT( searchStart != searchEnd );
const int mid = ( searchStart + searchEnd ) / 2; const int mid = ( searchStart + searchEnd ) / 2;

View File

@ -67,18 +67,22 @@ static float TransparencyControl( float aGrayColorValue, float aTransparency )
} }
/** /**
* Scale conversion from 3d model units to pcb units * Scale conversion from 3d model units to pcb units
*/ */
#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM ) #define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
void RENDER_3D_RAYTRACE_BASE::setupMaterials() void RENDER_3D_RAYTRACE_BASE::setupMaterials()
{ {
MATERIAL::SetDefaultRefractionRayCount( m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_refractions ); MATERIAL::SetDefaultRefractionRayCount(
MATERIAL::SetDefaultReflectionRayCount( m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_reflections ); m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_refractions );
MATERIAL::SetDefaultReflectionRayCount(
m_boardAdapter.m_Cfg->m_Render.raytrace_nrsamples_reflections );
MATERIAL::SetDefaultRefractionRecursionCount( m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_refractions ); MATERIAL::SetDefaultRefractionRecursionCount(
MATERIAL::SetDefaultReflectionRecursionCount( m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_reflections ); m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_refractions );
MATERIAL::SetDefaultReflectionRecursionCount(
m_boardAdapter.m_Cfg->m_Render.raytrace_recursivelevel_reflections );
double mmTo3Dunits = pcbIUScale.IU_PER_MM * m_boardAdapter.BiuTo3dUnits(); double mmTo3Dunits = pcbIUScale.IU_PER_MM * m_boardAdapter.BiuTo3dUnits();
@ -177,8 +181,8 @@ void RENDER_3D_RAYTRACE_BASE::setupMaterials()
void RENDER_3D_RAYTRACE_BASE::createObject( CONTAINER_3D& aDstContainer, const OBJECT_2D* aObject2D, void RENDER_3D_RAYTRACE_BASE::createObject( CONTAINER_3D& aDstContainer, const OBJECT_2D* aObject2D,
float aZMin, float aZMax, const MATERIAL* aMaterial, float aZMin, float aZMax, const MATERIAL* aMaterial,
const SFVEC3F& aObjColor ) const SFVEC3F& aObjColor )
{ {
switch( aObject2D->GetObjectType() ) switch( aObject2D->GetObjectType() )
{ {
@ -541,7 +545,8 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
radius ); radius );
objPtr->SetMaterial( &m_materials.m_EpoxyBoard ); objPtr->SetMaterial( &m_materials.m_EpoxyBoard );
objPtr->SetColor( ConvertSRGBToLinear( m_boardAdapter.m_BoardBodyColor ) ); objPtr->SetColor(
ConvertSRGBToLinear( m_boardAdapter.m_BoardBodyColor ) );
m_objectContainer.Add( objPtr ); m_objectContainer.Add( objPtr );
} }
@ -560,7 +565,8 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
aStatusReporter->Report( _( "Load Raytracing: layers" ) ); aStatusReporter->Report( _( "Load Raytracing: layers" ) );
// Add layers maps (except B_Mask and F_Mask) // Add layers maps (except B_Mask and F_Mask)
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() ) for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry :
m_boardAdapter.GetLayerMap() )
{ {
const PCB_LAYER_ID layer_id = entry.first; const PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second; const BVH_CONTAINER_2D* container2d = entry.second;
@ -667,7 +673,8 @@ void RENDER_3D_RAYTRACE_BASE::Reload( REPORTER* aStatusReporter, REPORTER* aWarn
{ {
const MATERIAL* materialLayer = &m_materials.m_SolderMask; const MATERIAL* materialLayer = &m_materials.m_SolderMask;
for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry : m_boardAdapter.GetLayerMap() ) for( const std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& entry :
m_boardAdapter.GetLayerMap() )
{ {
const PCB_LAYER_ID layer_id = entry.first; const PCB_LAYER_ID layer_id = entry.first;
const BVH_CONTAINER_2D* container2d = entry.second; const BVH_CONTAINER_2D* container2d = entry.second;
@ -1193,7 +1200,8 @@ void RENDER_3D_RAYTRACE_BASE::addPadsAndVias()
} }
void RENDER_3D_RAYTRACE_BASE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMaterialInformation ) void RENDER_3D_RAYTRACE_BASE::load3DModels( CONTAINER_3D& aDstContainer,
bool aSkipMaterialInformation )
{ {
if( !m_boardAdapter.GetBoard() ) if( !m_boardAdapter.GetBoard() )
return; return;
@ -1249,6 +1257,7 @@ void RENDER_3D_RAYTRACE_BASE::load3DModels( CONTAINER_3D& aDstContainer, bool aS
wxString libraryName = fp->GetFPID().GetLibNickname(); wxString libraryName = fp->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString; wxString footprintBasePath = wxEmptyString;
if( m_boardAdapter.GetBoard()->GetProject() ) if( m_boardAdapter.GetBoard()->GetProject() )
{ {
try try
@ -1409,8 +1418,8 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE_BASE::getModelMaterial( const S3DMODEL* a3DM
void RENDER_3D_RAYTRACE_BASE::addModels( CONTAINER_3D& aDstContainer, const S3DMODEL* a3DModel, void RENDER_3D_RAYTRACE_BASE::addModels( CONTAINER_3D& aDstContainer, const S3DMODEL* a3DModel,
const glm::mat4& aModelMatrix, float aFPOpacity, const glm::mat4& aModelMatrix, float aFPOpacity,
bool aSkipMaterialInformation, BOARD_ITEM* aBoardItem ) bool aSkipMaterialInformation, BOARD_ITEM* aBoardItem )
{ {
// Validate a3DModel pointers // Validate a3DModel pointers
wxASSERT( a3DModel != nullptr ); wxASSERT( a3DModel != nullptr );

View File

@ -345,22 +345,22 @@ protected:
SFVEC3F m_specularColor; SFVEC3F m_specularColor;
float m_reflectivity; float m_reflectivity;
///< 1.0 is completely transparent, 0.0 completely opaque. /// 1.0 is completely transparent, 0.0 completely opaque.
float m_transparency; float m_transparency;
float m_absorbance; ///< absorbance factor for the transparent material. float m_absorbance; ///< absorbance factor for the transparent material.
float m_reflection; ///< 1.0 completely reflective, 0.0 no reflective. float m_reflection; ///< 1.0 completely reflective, 0.0 no reflective.
bool m_castShadows; ///< true if this object will block the light. bool m_castShadows; ///< true if this object will block the light.
///< Number of rays that will be interpolated for this material if it is transparent. /// Number of rays that will be interpolated for this material if it is transparent.
unsigned int m_refractionRayCount; unsigned int m_refractionRayCount;
///< Number of rays that will be interpolated for this material if it is reflective. /// Number of rays that will be interpolated for this material if it is reflective.
unsigned int m_reflectionRayCount; unsigned int m_reflectionRayCount;
///< Number of levels it allows for refraction recursiveness. /// Number of levels it allows for refraction recursiveness.
unsigned int m_refractionRecursionCount; unsigned int m_refractionRecursionCount;
///< Number of levels it allows for reflection recursiveness. /// Number of levels it allows for reflection recursiveness.
unsigned int m_reflectionRecursionCount; unsigned int m_reflectionRecursionCount;
const MATERIAL_GENERATOR* m_generator; const MATERIAL_GENERATOR* m_generator;

View File

@ -256,6 +256,7 @@ static SFVEC3F convertLinearToSRGB( const SFVEC3F& aRGBcolor )
glm::lessThan( clampedColor, SFVEC3F(0.0031308f) ) ); glm::lessThan( clampedColor, SFVEC3F(0.0031308f) ) );
} }
static SFVEC4F convertLinearToSRGBA( const SFVEC4F& aRGBAcolor ) static SFVEC4F convertLinearToSRGBA( const SFVEC4F& aRGBAcolor )
{ {
return SFVEC4F( convertLinearToSRGB( SFVEC3F( aRGBAcolor ) ), aRGBAcolor.a ); return SFVEC4F( convertLinearToSRGB( SFVEC3F( aRGBAcolor ) ), aRGBAcolor.a );
@ -275,6 +276,7 @@ SFVEC3F ConvertSRGBToLinear( const SFVEC3F& aSRGBcolor )
glm::lessThanEqual( aSRGBcolor, SFVEC3F( 0.04045f ) ) ); glm::lessThanEqual( aSRGBcolor, SFVEC3F( 0.04045f ) ) );
} }
SFVEC4F ConvertSRGBAToLinear( const SFVEC4F& aSRGBAcolor ) SFVEC4F ConvertSRGBAToLinear( const SFVEC4F& aSRGBAcolor )
{ {
return SFVEC4F( ConvertSRGBToLinear( SFVEC3F( aSRGBAcolor ) ), aSRGBAcolor.a ); return SFVEC4F( ConvertSRGBToLinear( SFVEC3F( aSRGBAcolor ) ), aSRGBAcolor.a );
@ -319,8 +321,8 @@ static void HITINFO_PACKET_init( HITINFO_PACKET* aHitPacket )
void RENDER_3D_RAYTRACE_BASE::renderRayPackets( const SFVEC4F* bgColorY, const RAY* aRayPkt, void RENDER_3D_RAYTRACE_BASE::renderRayPackets( const SFVEC4F* bgColorY, const RAY* aRayPkt,
HITINFO_PACKET* aHitPacket, bool is_testShadow, HITINFO_PACKET* aHitPacket, bool is_testShadow,
SFVEC4F* aOutHitColor ) SFVEC4F* aOutHitColor )
{ {
for( unsigned int y = 0, i = 0; y < RAYPACKET_DIM; ++y ) for( unsigned int y = 0, i = 0; y < RAYPACKET_DIM; ++y )
{ {
@ -341,9 +343,9 @@ void RENDER_3D_RAYTRACE_BASE::renderRayPackets( const SFVEC4F* bgColorY, const R
void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY, void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY,
const HITINFO_PACKET* aHitPck_X0Y0, const HITINFO_PACKET* aHitPck_X0Y0,
const HITINFO_PACKET* aHitPck_AA_X1Y1, const HITINFO_PACKET* aHitPck_AA_X1Y1,
const RAY* aRayPck, SFVEC4F* aOutHitColor ) const RAY* aRayPck, SFVEC4F* aOutHitColor )
{ {
const bool is_testShadow = m_boardAdapter.m_Cfg->m_Render.raytrace_shadows; const bool is_testShadow = m_boardAdapter.m_Cfg->m_Render.raytrace_shadows;
@ -368,8 +370,8 @@ void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY,
unsigned int nodex1y0 = 0; unsigned int nodex1y0 = 0;
if( x < (RAYPACKET_DIM - 1) ) if( x < ( RAYPACKET_DIM - 1 ) )
nodex1y0 = aHitPck_X0Y0[ i + 1 ].m_HitInfo.m_acc_node_info; nodex1y0 = aHitPck_X0Y0[i + 1].m_HitInfo.m_acc_node_info;
unsigned int nodex0y1 = 0; unsigned int nodex0y1 = 0;
@ -503,9 +505,9 @@ void RENDER_3D_RAYTRACE_BASE::renderBlockTracing( uint8_t* ptrPBO, signed int iB
for( unsigned int x = 0; x < RAYPACKET_DIM; ++x ) for( unsigned int x = 0; x < RAYPACKET_DIM; ++x )
{ {
m_postShaderSsao.SetPixelData( blockPos.x + x, yBlockPos, m_postShaderSsao.SetPixelData( blockPos.x + x, yBlockPos,
SFVEC3F( 0.0f ), outColor, SFVEC3F( 0.0f ), outColor,
SFVEC3F( 0.0f ), 0, 1.0f ); SFVEC3F( 0.0f ), 0, 1.0f );
} }
} }
} }
@ -727,7 +729,8 @@ void RENDER_3D_RAYTRACE_BASE::postProcessShading( uint8_t* /* ptrPBO */, REPORTE
} }
void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( uint8_t* ptrPBO, REPORTER* /* aStatusReporter */ ) void RENDER_3D_RAYTRACE_BASE::postProcessBlurFinish( uint8_t* ptrPBO,
REPORTER* /* aStatusReporter */ )
{ {
if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing ) if( m_boardAdapter.m_Cfg->m_Render.raytrace_post_processing )
{ {
@ -854,9 +857,9 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitColorShading[i] = bhColorY; hitColorShading[i] = bhColorY;
} }
COLOR_RGBA cLRB_old[(RAYPACKET_DIM - 1)]; COLOR_RGBA cLRB_old[( RAYPACKET_DIM - 1 )];
for( unsigned int y = 0; y < (RAYPACKET_DIM - 1); ++y ) for( unsigned int y = 0; y < ( RAYPACKET_DIM - 1 ); ++y )
{ {
const SFVEC4F bgColorY = bgColor[y]; const SFVEC4F bgColorY = bgColor[y];
const COLOR_RGBA bgColorYRGB = COLOR_RGBA( bgColorY ); const COLOR_RGBA bgColorYRGB = COLOR_RGBA( bgColorY );
@ -981,11 +984,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitInfoLRT.m_tHit = ( hitPacket[ iLT ].m_HitInfo.m_tHit + hitInfoLRT.m_tHit = ( hitPacket[ iLT ].m_HitInfo.m_tHit +
hitPacket[ iRT ].m_HitInfo.m_tHit ) * 0.5f; hitPacket[ iRT ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoLRT.m_HitNormal = hitInfoLRT.m_HitNormal =
glm::normalize( ( hitPacket[ iLT ].m_HitInfo.m_HitNormal + glm::normalize( ( hitPacket[iLT].m_HitInfo.m_HitNormal
hitPacket[ iRT ].m_HitInfo.m_HitNormal ) * 0.5f ); + hitPacket[iRT].m_HitInfo.m_HitNormal )
* 0.5f );
cLRT = COLOR_RGBA( shadeHit( bgColorY, rayLRT, hitInfoLRT, false, cLRT = COLOR_RGBA( shadeHit( bgColorY, rayLRT, hitInfoLRT, false,
0, false ) ); 0, false ) );
cLRT = BlendColor( cLRT, BlendColor( cLT, cRT ) ); cLRT = BlendColor( cLRT, BlendColor( cLT, cRT ) );
} }
else else
@ -1017,8 +1021,8 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( m_accelerator->Intersect( rayLRT,hitInfoLRT ) ) if( m_accelerator->Intersect( rayLRT,hitInfoLRT ) )
cLRT = COLOR_RGBA( shadeHit( bgColorY, rayLRT, cLRT = COLOR_RGBA( shadeHit( bgColorY, rayLRT,
hitInfoLRT, false, hitInfoLRT, false,
0, false ) ); 0, false ) );
} }
} }
} }
@ -1039,7 +1043,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
// Trace the center ray // Trace the center ray
RAY rayLTB; RAY rayLTB;
rayLTB.Init( ( oriLT + oriLB ) * 0.5f, rayLTB.Init( ( oriLT + oriLB ) * 0.5f,
glm::normalize( ( dirLT + dirLB ) * 0.5f ) ); glm::normalize( ( dirLT + dirLB ) * 0.5f ) );
HITINFO hitInfoLTB; HITINFO hitInfoLTB;
hitInfoLTB.m_tHit = std::numeric_limits<float>::infinity(); hitInfoLTB.m_tHit = std::numeric_limits<float>::infinity();
@ -1052,10 +1056,11 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitInfoLTB.m_tHit = ( hitPacket[ iLT ].m_HitInfo.m_tHit + hitInfoLTB.m_tHit = ( hitPacket[ iLT ].m_HitInfo.m_tHit +
hitPacket[ iLB ].m_HitInfo.m_tHit ) * 0.5f; hitPacket[ iLB ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoLTB.m_HitNormal = hitInfoLTB.m_HitNormal =
glm::normalize( ( hitPacket[ iLT ].m_HitInfo.m_HitNormal + glm::normalize( ( hitPacket[iLT].m_HitInfo.m_HitNormal
hitPacket[ iLB ].m_HitInfo.m_HitNormal ) * 0.5f ); + hitPacket[iLB].m_HitInfo.m_HitNormal )
cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB, hitInfoLTB, false, * 0.5f );
0, false ) ); cLTB = COLOR_RGBA(
shadeHit( bgColorY, rayLTB, hitInfoLTB, false, 0, false ) );
cLTB = BlendColor( cLTB, BlendColor( cLT, cLB) ); cLTB = BlendColor( cLTB, BlendColor( cLT, cLB) );
} }
else else
@ -1080,15 +1085,15 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedLTB ) if( hittedLTB )
cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB, hitInfoLTB, cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB, hitInfoLTB,
false, 0, false ) ); false, 0, false ) );
else else
{ {
hitInfoLTB.m_tHit = std::numeric_limits<float>::infinity(); hitInfoLTB.m_tHit = std::numeric_limits<float>::infinity();
if( m_accelerator->Intersect( rayLTB, hitInfoLTB ) ) if( m_accelerator->Intersect( rayLTB, hitInfoLTB ) )
cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB, cLTB = COLOR_RGBA( shadeHit( bgColorY, rayLTB,
hitInfoLTB, false, hitInfoLTB, false,
0, false ) ); 0, false ) );
} }
} }
} }
@ -1119,11 +1124,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitPacket[ iRB ].m_HitInfo.m_tHit ) * 0.5f; hitPacket[ iRB ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoRTB.m_HitNormal = hitInfoRTB.m_HitNormal =
glm::normalize( ( hitPacket[ iRT ].m_HitInfo.m_HitNormal + glm::normalize( ( hitPacket[iRT].m_HitInfo.m_HitNormal
hitPacket[ iRB ].m_HitInfo.m_HitNormal ) * 0.5f ); + hitPacket[iRB].m_HitInfo.m_HitNormal )
* 0.5f );
cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB, false, 0, cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB, false, 0,
false ) ); false ) );
cRTB = BlendColor( cRTB, BlendColor( cRT, cRB ) ); cRTB = BlendColor( cRTB, BlendColor( cRT, cRB ) );
} }
else else
@ -1149,7 +1155,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedRTB ) if( hittedRTB )
{ {
cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB, cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB,
false, 0, false) ); false, 0, false) );
} }
else else
{ {
@ -1157,7 +1163,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( m_accelerator->Intersect( rayRTB, hitInfoRTB ) ) if( m_accelerator->Intersect( rayRTB, hitInfoRTB ) )
cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB, cRTB = COLOR_RGBA( shadeHit( bgColorY, rayRTB, hitInfoRTB,
false, 0, false ) ); false, 0, false ) );
} }
} }
} }
@ -1188,11 +1194,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
hitPacket[ iRB ].m_HitInfo.m_tHit ) * 0.5f; hitPacket[ iRB ].m_HitInfo.m_tHit ) * 0.5f;
hitInfoLRB.m_HitNormal = hitInfoLRB.m_HitNormal =
glm::normalize( ( hitPacket[ iLB ].m_HitInfo.m_HitNormal + glm::normalize( ( hitPacket[iLB].m_HitInfo.m_HitNormal
hitPacket[ iRB ].m_HitInfo.m_HitNormal ) * 0.5f ); + hitPacket[iRB].m_HitInfo.m_HitNormal )
* 0.5f );
cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB, false, 0, cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB, false, 0,
false ) ); false ) );
cLRB = BlendColor( cLRB, BlendColor( cLB, cRB ) ); cLRB = BlendColor( cLRB, BlendColor( cLB, cRB ) );
} }
else else
@ -1218,7 +1225,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedLRB ) if( hittedLRB )
{ {
cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB, cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB,
false, 0, false ) ); false, 0, false ) );
} }
else else
{ {
@ -1226,7 +1233,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( m_accelerator->Intersect( rayLRB, hitInfoLRB ) ) if( m_accelerator->Intersect( rayLRB, hitInfoLRB ) )
cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB, cLRB = COLOR_RGBA( shadeHit( bgColorY, rayLRB, hitInfoLRB,
false, 0, false ) ); false, 0, false ) );
} }
} }
} }
@ -1257,7 +1264,7 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hitted ) if( hitted )
cLTC = COLOR_RGBA( shadeHit( bgColorY, rayLTC, hitInfoLTC, false, cLTC = COLOR_RGBA( shadeHit( bgColorY, rayLTC, hitInfoLTC, false,
0, false ) ); 0, false ) );
} }
// Trace and shade cRTC // Trace and shade cRTC
@ -1278,12 +1285,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedC ) if( hittedC )
hitted = centerHitInfo.pHitObject->Intersect( rayRTC, hitInfoRTC ); hitted = centerHitInfo.pHitObject->Intersect( rayRTC, hitInfoRTC );
else if( hitPacket[ iRT ].m_hitresult ) else if( hitPacket[ iRT ].m_hitresult )
hitted = hitPacket[ iRT ].m_HitInfo.pHitObject->Intersect( rayRTC, hitted = hitPacket[iRT].m_HitInfo.pHitObject->Intersect(
hitInfoRTC ); rayRTC, hitInfoRTC );
if( hitted ) if( hitted )
cRTC = COLOR_RGBA( shadeHit( bgColorY, rayRTC, hitInfoRTC, false, cRTC = COLOR_RGBA( shadeHit( bgColorY, rayRTC, hitInfoRTC, false,
0, false ) ); 0, false ) );
} }
// Trace and shade cLBC // Trace and shade cLBC
@ -1304,12 +1311,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedC ) if( hittedC )
hitted = centerHitInfo.pHitObject->Intersect( rayLBC, hitInfoLBC ); hitted = centerHitInfo.pHitObject->Intersect( rayLBC, hitInfoLBC );
else if( hitPacket[ iLB ].m_hitresult ) else if( hitPacket[ iLB ].m_hitresult )
hitted = hitPacket[ iLB ].m_HitInfo.pHitObject->Intersect( rayLBC, hitted = hitPacket[iLB].m_HitInfo.pHitObject->Intersect(
hitInfoLBC ); rayLBC, hitInfoLBC );
if( hitted ) if( hitted )
cLBC = COLOR_RGBA( shadeHit( bgColorY, rayLBC, hitInfoLBC, false, cLBC = COLOR_RGBA( shadeHit( bgColorY, rayLBC, hitInfoLBC, false,
0, false ) ); 0, false ) );
} }
// Trace and shade cRBC // Trace and shade cRBC
@ -1330,12 +1337,12 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
if( hittedC ) if( hittedC )
hitted = centerHitInfo.pHitObject->Intersect( rayRBC, hitInfoRBC ); hitted = centerHitInfo.pHitObject->Intersect( rayRBC, hitInfoRBC );
else if( hitPacket[ iRB ].m_hitresult ) else if( hitPacket[ iRB ].m_hitresult )
hitted = hitPacket[ iRB ].m_HitInfo.pHitObject->Intersect( rayRBC, hitted = hitPacket[iRB].m_HitInfo.pHitObject->Intersect(
hitInfoRBC ); rayRBC, hitInfoRBC );
if( hitted ) if( hitted )
cRBC = COLOR_RGBA( shadeHit( bgColorY, rayRBC, hitInfoRBC, false, cRBC = COLOR_RGBA( shadeHit( bgColorY, rayRBC, hitInfoRBC, false,
0, false ) ); 0, false ) );
} }
// Set pixel colors // Set pixel colors
@ -1382,9 +1389,9 @@ void RENDER_3D_RAYTRACE_BASE::renderPreview( uint8_t* ptrPBO )
#define USE_EXPERIMENTAL_SOFT_SHADOWS 1 #define USE_EXPERIMENTAL_SOFT_SHADOWS 1
SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& aRay, HITINFO& aHitInfo, SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& aRay,
bool aIsInsideObject, unsigned int aRecursiveLevel, HITINFO& aHitInfo, bool aIsInsideObject,
bool is_testShadow ) const unsigned int aRecursiveLevel, bool is_testShadow ) const
{ {
const MATERIAL* objMaterial = aHitInfo.pHitObject->GetMaterial(); const MATERIAL* objMaterial = aHitInfo.pHitObject->GetMaterial();
wxASSERT( objMaterial != nullptr ); wxASSERT( objMaterial != nullptr );
@ -1536,9 +1543,10 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a
{ {
// Apply some randomize to the reflected vector // Apply some randomize to the reflected vector
const SFVEC3F random_reflectVector = const SFVEC3F random_reflectVector =
glm::normalize( reflectVector + glm::normalize( reflectVector
UniformRandomHemisphereDirection() * + UniformRandomHemisphereDirection()
m_boardAdapter.m_Cfg->m_Render.raytrace_spread_reflections ); * m_boardAdapter.m_Cfg->m_Render
.raytrace_spread_reflections );
reflectedRay.Init( hitPoint, random_reflectVector ); reflectedRay.Init( hitPoint, random_reflectVector );
} }
@ -1548,13 +1556,14 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a
if( m_accelerator->Intersect( reflectedRay, reflectedHit ) ) if( m_accelerator->Intersect( reflectedRay, reflectedHit ) )
{ {
SFVEC4F add = ( diffuseColorObj + SFVEC4F( objMaterial->GetSpecularColor(), 1.0f ) ) * SFVEC4F add = ( diffuseColorObj + SFVEC4F( objMaterial->GetSpecularColor(),
shadeHit( aBgColor, reflectedRay, reflectedHit, false, 1.0f ) ) *
aRecursiveLevel + 1, is_testShadow ) * shadeHit( aBgColor, reflectedRay, reflectedHit, false,
SFVEC4F( objMaterial->GetReflection() * aRecursiveLevel + 1, is_testShadow ) *
// Falloff factor SFVEC4F( objMaterial->GetReflection() *
(1.0f / ( 1.0f + 0.75f * reflectedHit.m_tHit * // Falloff factor
reflectedHit.m_tHit) ) ); (1.0f / ( 1.0f + 0.75f * reflectedHit.m_tHit *
reflectedHit.m_tHit) ) );
sum_color += add; sum_color += add;
} }

View File

@ -35,10 +35,10 @@
#include <map> #include <map>
/// Vector of materials /// Vector of materials.
typedef std::vector< BLINN_PHONG_MATERIAL > MODEL_MATERIALS; typedef std::vector< BLINN_PHONG_MATERIAL > MODEL_MATERIALS;
/// Maps a S3DMODEL pointer with a created BLINN_PHONG_MATERIAL vector /// Maps a #S3DMODEL pointer with a created BLINN_PHONG_MATERIAL vector.
typedef std::map< const S3DMODEL* , MODEL_MATERIALS > MAP_MODEL_MATERIALS; typedef std::map< const S3DMODEL* , MODEL_MATERIALS > MAP_MODEL_MATERIALS;
typedef enum typedef enum
@ -167,7 +167,7 @@ protected:
CONTAINER_3D m_objectContainer; CONTAINER_3D m_objectContainer;
///< Store the list of created objects special for RT that will be clear in the end. /// Store the list of created objects special for RT that will be clear in the end.
CONTAINER_2D m_containerWithObjectsToDelete; CONTAINER_2D m_containerWithObjectsToDelete;
CONTAINER_2D* m_outlineBoard2dObjects; CONTAINER_2D* m_outlineBoard2dObjects;
@ -178,16 +178,16 @@ protected:
SFVEC4F m_backgroundColorTop; SFVEC4F m_backgroundColorTop;
SFVEC4F m_backgroundColorBottom; SFVEC4F m_backgroundColorBottom;
///< Used to see if the windows size changed. /// Used to see if the windows size changed.
wxSize m_oldWindowsSize; wxSize m_oldWindowsSize;
///< Encode Morton code positions. /// Encode Morton code positions.
std::vector< SFVEC2UI > m_blockPositions; std::vector< SFVEC2UI > m_blockPositions;
///< Flag if a position was already processed (cleared each new render). /// Flag if a position was already processed (cleared each new render).
std::vector< int > m_blockPositionsWasProcessed; std::vector< int > m_blockPositionsWasProcessed;
///< Encode the Morton code positions (on fast preview mode). /// Encode the Morton code positions (on fast preview mode).
std::vector< SFVEC2UI > m_blockPositionsFast; std::vector< SFVEC2UI > m_blockPositionsFast;
SFVEC2UI m_realBufferSize; SFVEC2UI m_realBufferSize;

View File

@ -36,7 +36,8 @@
#include <wx/log.h> #include <wx/log.h>
RENDER_3D_RAYTRACE_GL::RENDER_3D_RAYTRACE_GL( EDA_3D_CANVAS* aCanvas, BOARD_ADAPTER& aAdapter, CAMERA& aCamera ) : RENDER_3D_RAYTRACE_GL::RENDER_3D_RAYTRACE_GL( EDA_3D_CANVAS* aCanvas, BOARD_ADAPTER& aAdapter,
CAMERA& aCamera ) :
RENDER_3D_RAYTRACE_BASE( aAdapter, aCamera ) RENDER_3D_RAYTRACE_BASE( aAdapter, aCamera )
{ {
wxLogTrace( m_logTrace, wxT( "RENDER_3D_RAYTRACE_GL::RENDER_3D_RAYTRACE_GL" ) ); wxLogTrace( m_logTrace, wxT( "RENDER_3D_RAYTRACE_GL::RENDER_3D_RAYTRACE_GL" ) );
@ -79,7 +80,7 @@ void RENDER_3D_RAYTRACE_GL::SetCurWindowSize( const wxSize& aSize )
bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
REPORTER* aWarningReporter ) REPORTER* aWarningReporter )
{ {
bool requestRedraw = false; bool requestRedraw = false;

View File

@ -268,20 +268,20 @@ bool BBOX_2D::Intersect( const RAY2D& aRay, float* t ) const
else else
*t = tmax; *t = tmax;
return (tmax >= 0.0f) && (tmax >= tmin); return ( tmax >= 0.0f ) && ( tmax >= tmin );
} }
bool BBOX_2D::Intersect( const RAYSEG2D& aRaySeg ) const bool BBOX_2D::Intersect( const RAYSEG2D& aRaySeg ) const
{ {
const float tx1 = (m_min.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x; const float tx1 = ( m_min.x - aRaySeg.m_Start.x ) * aRaySeg.m_InvDir.x;
const float tx2 = (m_max.x - aRaySeg.m_Start.x) * aRaySeg.m_InvDir.x; const float tx2 = ( m_max.x - aRaySeg.m_Start.x ) * aRaySeg.m_InvDir.x;
float tmin = glm::min( tx1, tx2 ); float tmin = glm::min( tx1, tx2 );
float tmax = glm::max( tx1, tx2 ); float tmax = glm::max( tx1, tx2 );
const float ty1 = (m_min.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y; const float ty1 = ( m_min.y - aRaySeg.m_Start.y ) * aRaySeg.m_InvDir.y;
const float ty2 = (m_max.y - aRaySeg.m_Start.y) * aRaySeg.m_InvDir.y; const float ty2 = ( m_max.y - aRaySeg.m_Start.y ) * aRaySeg.m_InvDir.y;
tmin = glm::max( tmin, glm::min( ty1, ty2 ) ); tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
tmax = glm::min( tmax, glm::max( ty1, ty2 ) ); tmax = glm::min( tmax, glm::max( ty1, ty2 ) );

View File

@ -291,10 +291,10 @@ bool BBOX_3D::Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) c
if( ( tmin > tzmax ) || ( tzmin > tmax ) ) if( ( tmin > tzmax ) || ( tzmin > tmax ) )
return false; return false;
tmin = (tzmin > tmin)? tzmin : tmin; tmin = ( tzmin > tmin ) ? tzmin : tmin;
tmin = ( tmin < 0.0f)? 0.0f : tmin; tmin = ( tmin < 0.0f ) ? 0.0f : tmin;
tmax = (tzmax < tmax)? tzmax : tmax; tmax = ( tzmax < tmax ) ? tzmax : tmax;
*aOutHitt0 = tmin; *aOutHitt0 = tmin;
*aOutHitt1 = tmax; *aOutHitt1 = tmax;

View File

@ -255,12 +255,15 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
} }
// For items that are > than g_BevelThickness3DU // For items that are > than g_BevelThickness3DU
// (eg on board vias / plated holeS) use a factor based on m_bbox.GetExtent().z // (eg on board vias / plated holeS) use a factor based on
const float bevelThickness = glm::max( g_BevelThickness3DU, // m_bbox.GetExtent().z
m_bbox.GetExtent().z * const float bevelThickness = glm::max(
(float)ADVANCED_CFG::GetCfg().m_3DRT_BevelExtentFactor ); g_BevelThickness3DU,
m_bbox.GetExtent().z
* (float) ADVANCED_CFG::GetCfg().m_3DRT_BevelExtentFactor );
if( ( zDistanceToTopOrBot > 0.0f ) && ( zDistanceToTopOrBot < bevelThickness ) ) if( ( zDistanceToTopOrBot > 0.0f )
&& ( zDistanceToTopOrBot < bevelThickness ) )
{ {
// Invert and Normalize the distance 0..1 // Invert and Normalize the distance 0..1
zBend = ( bevelThickness - zDistanceToTopOrBot ) / bevelThickness; zBend = ( bevelThickness - zDistanceToTopOrBot ) / bevelThickness;
@ -304,8 +307,8 @@ bool LAYER_ITEM::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
SFVEC2F outNormal; SFVEC2F outNormal;
RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D ); RAYSEG2D raySeg( boxHitPointStart2D, boxHitPointEnd2D );
if( ( m_object2d->IsPointInside( boxHitPointStart2D ) && if( ( m_object2d->IsPointInside( boxHitPointStart2D )
m_object2d->IsPointInside( boxHitPointEnd2D ) ) ) && m_object2d->IsPointInside( boxHitPointEnd2D ) ) )
{ {
if( tBBoxEnd < aHitInfo.m_tHit ) if( tBBoxEnd < aHitInfo.m_tHit )
{ {

View File

@ -358,12 +358,12 @@ bool ROUND_SEGMENT::IntersectP( const RAY& aRay, float aMaxDistance ) const
double c_Start = p_dot_p_Start - m_radius_squared; double c_Start = p_dot_p_Start - m_radius_squared;
float delta_Start = (float)(b_Start * b_Start - a * c_Start); float delta_Start = (float)( b_Start * b_Start - a * c_Start );
if( delta_Start > FLT_EPSILON ) if( delta_Start > FLT_EPSILON )
{ {
float sdelta = sqrtf( delta_Start ); float sdelta = sqrtf( delta_Start );
float t = (-b_Start - sdelta) / a; float t = ( -b_Start - sdelta ) / a;
float z = aRay.m_Origin.z + t * aRay.m_Dir.z; float z = aRay.m_Origin.z + t * aRay.m_Dir.z;
if( ( z >= m_bbox.Min().z ) && ( z <= m_bbox.Max().z ) ) if( ( z >= m_bbox.Min().z ) && ( z <= m_bbox.Max().z ) )

View File

@ -74,7 +74,7 @@ void TRIANGLE::pre_calc_const()
m_nd = glm::dot( m_n, A ) * krec; m_nd = glm::dot( m_n, A ) * krec;
// first line equation // first line equation
float reci = 1.0f / (b[u] * c[v] - b[v] * c[u]); float reci = 1.0f / ( b[u] * c[v] - b[v] * c[u] );
m_bnu = b[u] * reci; m_bnu = b[u] * reci;
m_bnv = -b[v] * reci; m_bnv = -b[v] * reci;
@ -209,7 +209,7 @@ bool TRIANGLE::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
const SFVEC3F& D = aRay.m_Dir; const SFVEC3F& D = aRay.m_Dir;
const SFVEC3F& A = m_vertex[0]; const SFVEC3F& A = m_vertex[0];
const float lnd = 1.0f / (D[m_k] + m_nu * D[ku] + m_nv * D[kv]); const float lnd = 1.0f / ( D[m_k] + m_nu * D[ku] + m_nv * D[kv] );
const float t = ( m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv] ) * lnd; const float t = ( m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv] ) * lnd;
if( !( ( aHitInfo.m_tHit > t ) && ( t > 0.0f ) ) ) if( !( ( aHitInfo.m_tHit > t ) && ( t > 0.0f ) ) )
@ -230,7 +230,7 @@ bool TRIANGLE::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
const float v = gamma; const float v = gamma;
const float u = beta; const float u = beta;
if( (u + v) > 1.0f ) if( ( u + v ) > 1.0f )
return false; return false;
if( glm::dot( D, m_n ) > 0.0f ) if( glm::dot( D, m_n ) > 0.0f )
@ -263,7 +263,7 @@ bool TRIANGLE::IntersectP( const RAY& aRay, float aMaxDistance ) const
const SFVEC3F D = aRay.m_Dir; const SFVEC3F D = aRay.m_Dir;
const SFVEC3F A = m_vertex[0]; const SFVEC3F A = m_vertex[0];
const float lnd = 1.0f / (D[m_k] + m_nu * D[ku] + m_nv * D[kv]); const float lnd = 1.0f / ( D[m_k] + m_nu * D[ku] + m_nv * D[kv] );
const float t = ( m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv] ) * lnd; const float t = ( m_nd - O[m_k] - m_nu * O[ku] - m_nv * O[kv] ) * lnd;
if( !( ( aMaxDistance > t ) && ( t > 0.0f ) ) ) if( !( ( aMaxDistance > t ) && ( t > 0.0f ) ) )
@ -284,7 +284,7 @@ bool TRIANGLE::IntersectP( const RAY& aRay, float aMaxDistance ) const
const float v = gamma; const float v = gamma;
const float u = beta; const float u = beta;
if( (u + v) > 1.0f ) if( ( u + v ) > 1.0f )
return false; return false;
if( glm::dot( D, m_n ) > 0.0f ) if( glm::dot( D, m_n ) > 0.0f )

View File

@ -98,18 +98,18 @@ protected:
*/ */
std::unique_ptr<BUSY_INDICATOR> CreateBusyIndicator() const; std::unique_ptr<BUSY_INDICATOR> CreateBusyIndicator() const;
///< Settings reference in use for this render. /// Settings reference in use for this render.
BOARD_ADAPTER& m_boardAdapter; BOARD_ADAPTER& m_boardAdapter;
CAMERA& m_camera; CAMERA& m_camera;
///< Flag if the canvas specific for this render was already initialized. /// Flag if the canvas specific for this render was already initialized.
bool m_canvasInitialized; bool m_canvasInitialized;
///< @todo This must be reviewed in order to flag change types. /// @todo This must be reviewed in order to flag change types.
bool m_reloadRequested; bool m_reloadRequested;
///< The window size that this camera is working. /// The window size that this camera is working.
wxSize m_windowSize; wxSize m_windowSize;
/** /**
@ -121,7 +121,7 @@ protected:
static const wxChar* m_logTrace; static const wxChar* m_logTrace;
private: private:
///< Factory that returns a suitable busy indicator for the context. /// Factory that returns a suitable busy indicator for the context.
BUSY_INDICATOR::FACTORY m_busyIndicatorFactory; BUSY_INDICATOR::FACTORY m_busyIndicatorFactory;
}; };

View File

@ -72,6 +72,7 @@
static double tb_project_to_sphere( double, double, double ); static double tb_project_to_sphere( double, double, double );
static void normalize_quat( double [4] ); static void normalize_quat( double [4] );
void vzero( double *v ) void vzero( double *v )
{ {
v[0] = 0.0; v[0] = 0.0;
@ -79,6 +80,7 @@ void vzero( double *v )
v[2] = 0.0; v[2] = 0.0;
} }
void vset( double *v, double x, double y, double z ) void vset( double *v, double x, double y, double z )
{ {
v[0] = x; v[0] = x;
@ -86,6 +88,7 @@ void vset( double *v, double x, double y, double z )
v[2] = z; v[2] = z;
} }
void vsub( const double *src1, const double *src2, double *dst ) void vsub( const double *src1, const double *src2, double *dst )
{ {
dst[0] = src1[0] - src2[0]; dst[0] = src1[0] - src2[0];
@ -93,6 +96,7 @@ void vsub( const double *src1, const double *src2, double *dst )
dst[2] = src1[2] - src2[2]; dst[2] = src1[2] - src2[2];
} }
void vcopy( const double *v1, double *v2 ) void vcopy( const double *v1, double *v2 )
{ {
int i; int i;
@ -101,6 +105,7 @@ void vcopy( const double *v1, double *v2 )
v2[i] = v1[i]; v2[i] = v1[i];
} }
void vcross( const double *v1, const double *v2, double *cross ) void vcross( const double *v1, const double *v2, double *cross )
{ {
double temp[3]; double temp[3];
@ -111,11 +116,13 @@ void vcross( const double *v1, const double *v2, double *cross )
vcopy(temp, cross); vcopy(temp, cross);
} }
double vlength( const double *v ) double vlength( const double *v )
{ {
return (double) sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] ); return (double) sqrt( v[0] * v[0] + v[1] * v[1] + v[2] * v[2] );
} }
void vscale( double *v, double div ) void vscale( double *v, double div )
{ {
v[0] *= div; v[0] *= div;
@ -123,16 +130,19 @@ void vscale( double *v, double div )
v[2] *= div; v[2] *= div;
} }
void vnormal( double *v ) void vnormal( double *v )
{ {
vscale( v, 1.0f / vlength( v ) ); vscale( v, 1.0f / vlength( v ) );
} }
double vdot( const double *v1, const double *v2 ) double vdot( const double *v1, const double *v2 )
{ {
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
} }
void vadd( const double *src1, const double *src2, double *dst ) void vadd( const double *src1, const double *src2, double *dst )
{ {
dst[0] = src1[0] + src2[0]; dst[0] = src1[0] + src2[0];
@ -140,6 +150,7 @@ void vadd( const double *src1, const double *src2, double *dst )
dst[2] = src1[2] + src2[2]; dst[2] = src1[2] + src2[2];
} }
/* /*
* Ok, simulate a track-ball. Project the points onto the virtual * Ok, simulate a track-ball. Project the points onto the virtual
* trackball, then figure out the axis of rotation, which is the cross * trackball, then figure out the axis of rotation, which is the cross
@ -177,13 +188,13 @@ void trackball( double q[4], double p1x, double p1y, double p2x, double p2y )
/* /*
* Now, we want the cross product of P1 and P2 * Now, we want the cross product of P1 and P2
*/ */
vcross(p2,p1,a); vcross( p2, p1, a );
/* /*
* Figure out how much to rotate around that axis. * Figure out how much to rotate around that axis.
*/ */
vsub( p1, p2, d ); vsub( p1, p2, d );
t = vlength( d ) / (2.0f * TRACKBALLSIZE); t = vlength( d ) / ( 2.0f * TRACKBALLSIZE );
/* /*
* Avoid problems with out-of-control values... * Avoid problems with out-of-control values...
@ -199,6 +210,7 @@ void trackball( double q[4], double p1x, double p1y, double p2x, double p2y )
axis_to_quat( a, phi, q ); axis_to_quat( a, phi, q );
} }
/* /*
* Given an axis and angle, compute quaternion. * Given an axis and angle, compute quaternion.
*/ */
@ -210,6 +222,7 @@ void axis_to_quat( double a[3], double phi, double q[4] )
q[3] = (double) cos( phi / 2.0 ); q[3] = (double) cos( phi / 2.0 );
} }
/* /*
* Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet * Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet
* if we are away from the center of the sphere. * if we are away from the center of the sphere.
@ -233,6 +246,7 @@ static double tb_project_to_sphere( double r, double x, double y )
return z; return z;
} }
/* /*
* Given two rotations, e1 and e2, expressed as quaternion rotations, * Given two rotations, e1 and e2, expressed as quaternion rotations,
* figure out the equivalent single rotation and stuff it into dest. * figure out the equivalent single rotation and stuff it into dest.
@ -248,7 +262,7 @@ static double tb_project_to_sphere( double r, double x, double y )
void add_quats( double q1[4], double q2[4], double dest[4] ) void add_quats( double q1[4], double q2[4], double dest[4] )
{ {
static int count=0; static int count = 0;
double t1[4], t2[4], t3[4]; double t1[4], t2[4], t3[4];
double tf[4]; double tf[4];
@ -276,6 +290,7 @@ void add_quats( double q1[4], double q2[4], double dest[4] )
} }
} }
/* /*
* Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0 * Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0
* If they don't add up to 1.0, dividing by their magnitued will * If they don't add up to 1.0, dividing by their magnitued will
@ -293,31 +308,31 @@ static void normalize_quat( double q[4] )
int i; int i;
double mag; double mag;
mag = (q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]); mag = ( q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3] );
for( i = 0; i < 4; i++ ) for( i = 0; i < 4; i++ )
q[i] /= mag; q[i] /= mag;
} }
/* /*
* Build a rotation matrix, given a quaternion rotation. * Build a rotation matrix, given a quaternion rotation.
*
*/ */
void build_rotmatrix( float m[4][4], double q[4] ) void build_rotmatrix( float m[4][4], double q[4] )
{ {
m[0][0] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2])); m[0][0] = (float) ( 1.0 - 2.0 * ( q[1] * q[1] + q[2] * q[2] ) );
m[0][1] = (float)(2.0 * (q[0] * q[1] - q[2] * q[3])); m[0][1] = (float) ( 2.0 * ( q[0] * q[1] - q[2] * q[3] ) );
m[0][2] = (float)(2.0 * (q[2] * q[0] + q[1] * q[3])); m[0][2] = (float) ( 2.0 * ( q[2] * q[0] + q[1] * q[3] ) );
m[0][3] = 0.0f; m[0][3] = 0.0f;
m[1][0] = (float)(2.0 * (q[0] * q[1] + q[2] * q[3])); m[1][0] = (float) ( 2.0 * ( q[0] * q[1] + q[2] * q[3] ) );
m[1][1] = (float)(1.0 - 2.0f * (q[2] * q[2] + q[0] * q[0])); m[1][1] = (float) ( 1.0 - 2.0f * ( q[2] * q[2] + q[0] * q[0] ) );
m[1][2] = (float)(2.0 * (q[1] * q[2] - q[0] * q[3])); m[1][2] = (float) ( 2.0 * ( q[1] * q[2] - q[0] * q[3] ) );
m[1][3] = 0.0f; m[1][3] = 0.0f;
m[2][0] = (float)(2.0 * (q[2] * q[0] - q[1] * q[3])); m[2][0] = (float) ( 2.0 * ( q[2] * q[0] - q[1] * q[3] ) );
m[2][1] = (float)(2.0 * (q[1] * q[2] + q[0] * q[3])); m[2][1] = (float) ( 2.0 * ( q[1] * q[2] + q[0] * q[3] ) );
m[2][2] = (float)(1.0 - 2.0 * (q[1] * q[1] + q[0] * q[0])); m[2][2] = (float) ( 1.0 - 2.0 * ( q[1] * q[1] + q[0] * q[0] ) );
m[2][3] = 0.0f; m[2][3] = 0.0f;
m[3][0] = 0.0f; m[3][0] = 0.0f;

View File

@ -48,7 +48,8 @@ void EDA_3D_VIEWER_FRAME::ReCreateMainToolbar()
else else
{ {
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize, m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL ); KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT |
wxAUI_TB_HORIZONTAL );
m_mainToolBar->SetAuiManager( &m_auimgr ); m_mainToolBar->SetAuiManager( &m_auimgr );
} }

View File

@ -272,25 +272,27 @@ void EDA_3D_VIEWER_FRAME::setupUIConditions()
return m_boardAdapter.m_Cfg->m_AuiPanels.show_layer_manager; return m_boardAdapter.m_Cfg->m_AuiPanels.show_layer_manager;
}; };
RegisterUIUpdateHandler( ID_RENDER_CURRENT_VIEW, ACTION_CONDITIONS().Check( raytracing ) ); RegisterUIUpdateHandler( ID_RENDER_CURRENT_VIEW, ACTION_CONDITIONS().Check( raytracing ) );
mgr->SetConditions( EDA_3D_ACTIONS::showTHT, ACTION_CONDITIONS().Check( showTH ) ); mgr->SetConditions( EDA_3D_ACTIONS::showTHT, ACTION_CONDITIONS().Check( showTH ) );
mgr->SetConditions( EDA_3D_ACTIONS::showSMD, ACTION_CONDITIONS().Check( showSMD ) ); mgr->SetConditions( EDA_3D_ACTIONS::showSMD, ACTION_CONDITIONS().Check( showSMD ) );
mgr->SetConditions( EDA_3D_ACTIONS::showVirtual, ACTION_CONDITIONS().Check( showVirtual ) ); mgr->SetConditions( EDA_3D_ACTIONS::showVirtual, ACTION_CONDITIONS().Check( showVirtual ) );
mgr->SetConditions( EDA_3D_ACTIONS::showNotInPosFile, ACTION_CONDITIONS().Check( show_NotInPosfile ) ); mgr->SetConditions( EDA_3D_ACTIONS::showNotInPosFile,
mgr->SetConditions( EDA_3D_ACTIONS::showDNP, ACTION_CONDITIONS().Check( show_DNP ) ); ACTION_CONDITIONS().Check( show_NotInPosfile ) );
mgr->SetConditions( EDA_3D_ACTIONS::showDNP, ACTION_CONDITIONS().Check( show_DNP ) );
mgr->SetConditions( EDA_3D_ACTIONS::showBBoxes, ACTION_CONDITIONS().Check( showBBoxes ) ); mgr->SetConditions( EDA_3D_ACTIONS::showBBoxes, ACTION_CONDITIONS().Check( showBBoxes ) );
mgr->SetConditions( EDA_3D_ACTIONS::showAxis, ACTION_CONDITIONS().Check( showAxes ) ); mgr->SetConditions( EDA_3D_ACTIONS::showAxis, ACTION_CONDITIONS().Check( showAxes ) );
mgr->SetConditions( EDA_3D_ACTIONS::noGrid, GridSizeCheck( GRID3D_TYPE::NONE ) ); mgr->SetConditions( EDA_3D_ACTIONS::noGrid, GridSizeCheck( GRID3D_TYPE::NONE ) );
mgr->SetConditions( EDA_3D_ACTIONS::show10mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_10MM ) ); mgr->SetConditions( EDA_3D_ACTIONS::show10mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_10MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::show5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_5MM ) ); mgr->SetConditions( EDA_3D_ACTIONS::show5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_5MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::show2_5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_2P5MM ) ); mgr->SetConditions( EDA_3D_ACTIONS::show2_5mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_2P5MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::show1mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_1MM ) ); mgr->SetConditions( EDA_3D_ACTIONS::show1mmGrid, GridSizeCheck( GRID3D_TYPE::GRID_1MM ) );
mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( ortho ) ); mgr->SetConditions( EDA_3D_ACTIONS::toggleOrtho, ACTION_CONDITIONS().Check( ortho ) );
mgr->SetConditions( EDA_3D_ACTIONS::showLayersManager, ACTION_CONDITIONS().Check( appearances ) ); mgr->SetConditions( EDA_3D_ACTIONS::showLayersManager,
ACTION_CONDITIONS().Check( appearances ) );
#undef GridSizeCheck #undef GridSizeCheck
} }
@ -643,7 +645,8 @@ void EDA_3D_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTex
ReCreateMainToolbar(); ReCreateMainToolbar();
loadCommonSettings(); loadCommonSettings();
applySettings( Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) ); applySettings(
Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>( "3d_viewer" ) );
m_appearancePanel->CommonSettingsChanged(); m_appearancePanel->CommonSettingsChanged();
@ -710,7 +713,8 @@ void EDA_3D_VIEWER_FRAME::takeScreenshot( wxCommandEvent& event )
if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD ) if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{ {
// Remember path between saves during this session only. // Remember path between saves during this session only.
const wxString wildcard = fmt_is_jpeg ? FILEEXT::JpegFileWildcard() : FILEEXT::PngFileWildcard(); const wxString wildcard =
fmt_is_jpeg ? FILEEXT::JpegFileWildcard() : FILEEXT::PngFileWildcard();
const wxString ext = fmt_is_jpeg ? FILEEXT::JpegFileExtension : FILEEXT::PngFileExtension; const wxString ext = fmt_is_jpeg ? FILEEXT::JpegFileExtension : FILEEXT::PngFileExtension;
// First time path is set to the project path. // First time path is set to the project path.

View File

@ -469,12 +469,15 @@ bool EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
ret &= fromLegacy<int>( aCfg, "RenderEngine", "render.engine" ); ret &= fromLegacy<int>( aCfg, "RenderEngine", "render.engine" );
ret &= fromLegacy<int>( aCfg, "ShowGrid3D", "render.grid_type" ); ret &= fromLegacy<int>( aCfg, "ShowGrid3D", "render.grid_type" );
ret &= fromLegacy<int>( aCfg, "Render_Material", "render.material_mode" ); ret &= fromLegacy<int>( aCfg, "Render_Material", "render.material_mode" );
ret &= fromLegacy<bool>( aCfg, "Render_OGL_ShowCopperThickness", "render.opengl_copper_thickness" ); ret &= fromLegacy<bool>( aCfg, "Render_OGL_ShowCopperThickness",
ret &= fromLegacy<bool>( aCfg, "Render_OGL_ShowModelBoudingBoxes", "render.opengl_show_model_bbox" ); "render.opengl_copper_thickness" );
ret &= fromLegacy<bool>( aCfg, "Render_OGL_ShowModelBoudingBoxes",
"render.opengl_show_model_bbox" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_AntiAliasing", "render.raytrace_anti_aliasing" ); ret &= fromLegacy<bool>( aCfg, "Render_RAY_AntiAliasing", "render.raytrace_anti_aliasing" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Backfloor", "render.raytrace_backfloor" ); ret &= fromLegacy<bool>( aCfg, "Render_RAY_Backfloor", "render.raytrace_backfloor" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_PostProcess", "render.raytrace_post_processing" ); ret &= fromLegacy<bool>( aCfg, "Render_RAY_PostProcess", "render.raytrace_post_processing" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_ProceduralTextures", "render.raytrace_procedural_textures" ); ret &= fromLegacy<bool>( aCfg, "Render_RAY_ProceduralTextures",
"render.raytrace_procedural_textures" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Reflections", "render.raytrace_reflections" ); ret &= fromLegacy<bool>( aCfg, "Render_RAY_Reflections", "render.raytrace_reflections" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Refractions", "render.raytrace_refractions" ); ret &= fromLegacy<bool>( aCfg, "Render_RAY_Refractions", "render.raytrace_refractions" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Shadows", "render.raytrace_shadows" ); ret &= fromLegacy<bool>( aCfg, "Render_RAY_Shadows", "render.raytrace_shadows" );

View File

@ -54,11 +54,11 @@ public:
SELECTION_CONDITION GridSize( GRID3D_TYPE aGridSize ); SELECTION_CONDITION GridSize( GRID3D_TYPE aGridSize );
private: private:
///< Helper function used by GridDize() /// Helper function used by GridDize().
static bool gridSizeFunction( const SELECTION& aSelection, BOARD_ADAPTER* aAdapter, static bool gridSizeFunction( const SELECTION& aSelection, BOARD_ADAPTER* aAdapter,
GRID3D_TYPE aGridSize ); GRID3D_TYPE aGridSize );
///< The board adapter to read the 3D viewer state from /// The board adapter to read the 3D viewer state from.
BOARD_ADAPTER* m_adapter; BOARD_ADAPTER* m_adapter;
}; };

View File

@ -182,6 +182,7 @@ int EDA_3D_CONTROLLER::RotateView( const TOOL_EVENT& aEvent )
{ {
case ROTATION_DIR::X_CW: m_camera->RotateX( -rotIncrement ); break; case ROTATION_DIR::X_CW: m_camera->RotateX( -rotIncrement ); break;
case ROTATION_DIR::X_CCW: m_camera->RotateX( rotIncrement ); break; case ROTATION_DIR::X_CCW: m_camera->RotateX( rotIncrement ); break;
/// Y rotations are backward b/c the RHR has Y pointing into the screen /// Y rotations are backward b/c the RHR has Y pointing into the screen
case ROTATION_DIR::Y_CW: m_camera->RotateY( rotIncrement ); break; case ROTATION_DIR::Y_CW: m_camera->RotateY( rotIncrement ); break;
case ROTATION_DIR::Y_CCW: m_camera->RotateY( -rotIncrement ); break; case ROTATION_DIR::Y_CCW: m_camera->RotateY( -rotIncrement ); break;
@ -234,7 +235,8 @@ int EDA_3D_CONTROLLER::ToggleVisibility( const TOOL_EVENT& aEvent )
auto flipLayer = auto flipLayer =
[&]( int layer ) [&]( int layer )
{ {
appearanceManager->OnLayerVisibilityChanged( layer, !visibilityFlags.test( layer ) ); appearanceManager->OnLayerVisibilityChanged( layer,
!visibilityFlags.test( layer ) );
}; };
EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( m_toolMgr->GetToolHolder() ); EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
@ -311,7 +313,8 @@ int EDA_3D_CONTROLLER::doZoomInOut( bool aDirection, bool aCenterOnCursor )
{ {
if( m_canvas ) if( m_canvas )
{ {
m_canvas->SetView3D( aDirection ? VIEW3D_TYPE::VIEW3D_ZOOM_IN : VIEW3D_TYPE::VIEW3D_ZOOM_OUT ); m_canvas->SetView3D( aDirection ? VIEW3D_TYPE::VIEW3D_ZOOM_IN
: VIEW3D_TYPE::VIEW3D_ZOOM_OUT );
m_canvas->DisplayStatus(); m_canvas->DisplayStatus();
} }

View File

@ -32,9 +32,7 @@ class BOARD_ADAPTER;
/** /**
* EDA_3D_CONTROLLER * Handle view actions for various 3D canvases.
*
* Handles view actions for various 3D canvases.
*/ */
class EDA_3D_CONTROLLER : public TOOL_INTERACTIVE class EDA_3D_CONTROLLER : public TOOL_INTERACTIVE
@ -99,7 +97,7 @@ public:
int ToggleLayersManager( const TOOL_EVENT& aEvent ); int ToggleLayersManager( const TOOL_EVENT& aEvent );
private: private:
///< Sets up handlers for various events. /// Set up handlers for various events.
void setTransitions() override; void setTransitions() override;
int doZoomInOut( bool aDirection, bool aCenterOnCursor ); int doZoomInOut( bool aDirection, bool aCenterOnCursor );

View File

@ -45,42 +45,46 @@
#include <../3d_rendering/opengl/render_3d_opengl.h> #include <../3d_rendering/opengl/render_3d_opengl.h>
/// Render Row abbreviation to reduce source width.
#define RR APPEARANCE_CONTROLS_3D::APPEARANCE_SETTING_3D // Render Row abbreviation to reduce source width #define RR APPEARANCE_CONTROLS_3D::APPEARANCE_SETTING_3D
/// Template for object appearance settings /// Template for object appearance settings
const APPEARANCE_CONTROLS_3D::APPEARANCE_SETTING_3D APPEARANCE_CONTROLS_3D::s_layerSettings[] = { const APPEARANCE_CONTROLS_3D::APPEARANCE_SETTING_3D APPEARANCE_CONTROLS_3D::s_layerSettings[] = {
// text id tooltip // text id tooltip
RR( _HKI( "Board Body" ), LAYER_3D_BOARD, _HKI( "Show board body" ) ), RR( _HKI( "Board Body" ), LAYER_3D_BOARD, _HKI( "Show board body" ) ),
RR( _HKI( "F.Cu" ), LAYER_3D_COPPER_TOP, _HKI( "Show front copper / surface finish color" ) ), RR( _HKI( "F.Cu" ), LAYER_3D_COPPER_TOP, _HKI( "Show front copper / surface finish color" ) ),
RR( _HKI( "B.Cu" ), LAYER_3D_COPPER_BOTTOM, _HKI( "Show back copper / surface finish color" ) ), RR( _HKI( "B.Cu" ), LAYER_3D_COPPER_BOTTOM, _HKI( "Show back copper / surface finish color" ) ),
RR( _HKI( "Adhesive" ), LAYER_3D_ADHESIVE, _HKI( "Show adhesive" ) ), RR( _HKI( "Adhesive" ), LAYER_3D_ADHESIVE, _HKI( "Show adhesive" ) ),
RR( _HKI( "Solder Paste" ), LAYER_3D_SOLDERPASTE, _HKI( "Show solder paste" ) ), RR( _HKI( "Solder Paste" ), LAYER_3D_SOLDERPASTE, _HKI( "Show solder paste" ) ),
RR( _HKI( "F.Silkscreen" ), LAYER_3D_SILKSCREEN_TOP, _HKI( "Show front silkscreen" ) ), RR( _HKI( "F.Silkscreen" ), LAYER_3D_SILKSCREEN_TOP, _HKI( "Show front silkscreen" ) ),
RR( _HKI( "B.Silkscreen" ), LAYER_3D_SILKSCREEN_BOTTOM, _HKI( "Show back silkscreen" ) ), RR( _HKI( "B.Silkscreen" ), LAYER_3D_SILKSCREEN_BOTTOM, _HKI( "Show back silkscreen" ) ),
RR( _HKI( "F.Mask" ), LAYER_3D_SOLDERMASK_TOP, _HKI( "Show front solder mask" ) ), RR( _HKI( "F.Mask" ), LAYER_3D_SOLDERMASK_TOP, _HKI( "Show front solder mask" ) ),
RR( _HKI( "B.Mask" ), LAYER_3D_SOLDERMASK_BOTTOM, _HKI( "Show back solder mask" ) ), RR( _HKI( "B.Mask" ), LAYER_3D_SOLDERMASK_BOTTOM, _HKI( "Show back solder mask" ) ),
RR( _HKI( "User.Drawings" ), LAYER_3D_USER_DRAWINGS, _HKI( "Show user drawings layer" ) ), RR( _HKI( "User.Drawings" ), LAYER_3D_USER_DRAWINGS, _HKI( "Show user drawings layer" ) ),
RR( _HKI( "User.Comments" ), LAYER_3D_USER_COMMENTS, _HKI( "Show user comments layer" ) ), RR( _HKI( "User.Comments" ), LAYER_3D_USER_COMMENTS, _HKI( "Show user comments layer" ) ),
RR( _HKI( "User.Eco1" ), LAYER_3D_USER_ECO1, _HKI( "Show user ECO1 layer" ) ), RR( _HKI( "User.Eco1" ), LAYER_3D_USER_ECO1, _HKI( "Show user ECO1 layer" ) ),
RR( _HKI( "User.Eco2" ), LAYER_3D_USER_ECO2, _HKI( "Show user ECO2 layer" ) ), RR( _HKI( "User.Eco2" ), LAYER_3D_USER_ECO2, _HKI( "Show user ECO2 layer" ) ),
RR(), RR(),
RR( _HKI( "Through-hole Models" ), LAYER_3D_TH_MODELS, EDA_3D_ACTIONS::showTHT ), RR( _HKI( "Through-hole Models" ), LAYER_3D_TH_MODELS, EDA_3D_ACTIONS::showTHT ),
RR( _HKI( "SMD Models" ), LAYER_3D_SMD_MODELS, EDA_3D_ACTIONS::showSMD ), RR( _HKI( "SMD Models" ), LAYER_3D_SMD_MODELS, EDA_3D_ACTIONS::showSMD ),
RR( _HKI( "Virtual Models" ), LAYER_3D_VIRTUAL_MODELS, EDA_3D_ACTIONS::showVirtual ), RR( _HKI( "Virtual Models" ), LAYER_3D_VIRTUAL_MODELS, EDA_3D_ACTIONS::showVirtual ),
RR( _HKI( "Models not in POS File" ), LAYER_3D_MODELS_NOT_IN_POS, EDA_3D_ACTIONS::showNotInPosFile ), RR( _HKI( "Models not in POS File" ), LAYER_3D_MODELS_NOT_IN_POS,
RR( _HKI( "Models marked DNP" ), LAYER_3D_MODELS_MARKED_DNP, EDA_3D_ACTIONS::showDNP ), EDA_3D_ACTIONS::showNotInPosFile ),
RR( _HKI( "Model Bounding Boxes" ), LAYER_3D_BOUNDING_BOXES, EDA_3D_ACTIONS::showBBoxes ), RR( _HKI( "Models marked DNP" ), LAYER_3D_MODELS_MARKED_DNP, EDA_3D_ACTIONS::showDNP ),
RR( _HKI( "Model Bounding Boxes" ), LAYER_3D_BOUNDING_BOXES, EDA_3D_ACTIONS::showBBoxes ),
RR(), RR(),
RR( _HKI( "Values" ), LAYER_FP_VALUES, _HKI( "Show footprint values" ) ), RR( _HKI( "Values" ), LAYER_FP_VALUES, _HKI( "Show footprint values" ) ),
RR( _HKI( "References" ), LAYER_FP_REFERENCES, _HKI( "Show footprint references" ) ), RR( _HKI( "References" ), LAYER_FP_REFERENCES, _HKI( "Show footprint references" ) ),
RR( _HKI( "Footprint Text" ), LAYER_FP_TEXT, _HKI( "Show all footprint text" ) ), RR( _HKI( "Footprint Text" ), LAYER_FP_TEXT, _HKI( "Show all footprint text" ) ),
RR( _HKI( "Off-board Silkscreen" ), LAYER_3D_OFF_BOARD_SILK, _HKI( "Do not clip silk layers to board outline" ) ), RR( _HKI( "Off-board Silkscreen" ), LAYER_3D_OFF_BOARD_SILK,
_HKI( "Do not clip silk layers to board outline" ) ),
RR(), RR(),
RR( _HKI( "3D Axis" ), LAYER_3D_AXES, EDA_3D_ACTIONS::showAxis ), RR( _HKI( "3D Axis" ), LAYER_3D_AXES, EDA_3D_ACTIONS::showAxis ),
RR( _HKI( "Background Start" ), LAYER_3D_BACKGROUND_TOP, _HKI( "Background gradient start color" ) ), RR( _HKI( "Background Start" ), LAYER_3D_BACKGROUND_TOP,
RR( _HKI( "Background End" ), LAYER_3D_BACKGROUND_BOTTOM, _HKI( "Background gradient end color" ) ), _HKI( "Background gradient start color" ) ),
RR( _HKI( "Background End" ), LAYER_3D_BACKGROUND_BOTTOM,
_HKI( "Background gradient end color" ) ),
}; };
// The list of IDs that can have colors coming from the board stackup, and cannot be // The list of IDs that can have colors coming from the board stackup, and cannot be
@ -136,7 +140,7 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
} ); } );
m_cbUseBoardEditorCopperColors = new wxCheckBox( m_panelLayers, wxID_ANY, m_cbUseBoardEditorCopperColors = new wxCheckBox( m_panelLayers, wxID_ANY,
_( "Use board editor copper colors" ) ); _( "Use board editor copper colors" ) );
m_cbUseBoardEditorCopperColors->SetFont( infoFont ); m_cbUseBoardEditorCopperColors->SetFont( infoFont );
m_cbUseBoardEditorCopperColors->SetToolTip( m_cbUseBoardEditorCopperColors->SetToolTip(
_( "Use the board editor copper colors (openGL only)" ) ); _( "Use the board editor copper colors (openGL only)" ) );
@ -154,7 +158,8 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
m_panelLayersSizer->Add( m_cbUseBoardStackupColors, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 ); m_panelLayersSizer->Add( m_cbUseBoardStackupColors, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 );
m_panelLayersSizer->Add( m_cbUseBoardEditorCopperColors, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 ); m_panelLayersSizer->Add( m_cbUseBoardEditorCopperColors, 0,
wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 7 );
m_cbLayerPresets->SetToolTip( wxString::Format( _( "Save and restore color and visibility " m_cbLayerPresets->SetToolTip( wxString::Format( _( "Save and restore color and visibility "
"combinations.\n" "combinations.\n"
@ -529,7 +534,8 @@ void APPEARANCE_CONTROLS_3D::rebuildLayers()
sizer->AddSpacer( 5 ); sizer->AddSpacer( 5 );
wxStaticText* label = new wxStaticText( m_windowLayers, layer, aSetting->GetLabel() ); wxStaticText* label = new wxStaticText( m_windowLayers, layer,
aSetting->GetLabel() );
label->Wrap( -1 ); label->Wrap( -1 );
label->SetToolTip( aSetting->GetTooltip() ); label->SetToolTip( aSetting->GetTooltip() );
@ -916,7 +922,8 @@ void APPEARANCE_CONTROLS_3D::onViewportChanged( wxCommandEvent& aEvent )
{ {
m_viewports[name] = VIEWPORT3D( name, m_frame->GetCurrentCamera().GetViewMatrix() ); m_viewports[name] = VIEWPORT3D( name, m_frame->GetCurrentCamera().GetViewMatrix() );
index = m_cbViewports->Insert( name, index-1, static_cast<void*>( &m_viewports[name] ) ); index = m_cbViewports->Insert( name, index-1,
static_cast<void*>( &m_viewports[name] ) );
} }
else else
{ {

View File

@ -125,10 +125,10 @@ public:
const wxArrayString& GetLayerPresetsMRU() { return m_presetMRU; } const wxArrayString& GetLayerPresetsMRU() { return m_presetMRU; }
///< Return a list of viewports created by the user. /// Return a list of viewports created by the user.
std::vector<VIEWPORT3D> GetUserViewports() const; std::vector<VIEWPORT3D> GetUserViewports() const;
///< Update the current viewports from those saved in the project file. /// Update the current viewports from those saved in the project file.
void SetUserViewports( std::vector<VIEWPORT3D>& aPresetList ); void SetUserViewports( std::vector<VIEWPORT3D>& aPresetList );
void ApplyViewport( const wxString& aPresetName ); void ApplyViewport( const wxString& aPresetName );

View File

@ -51,9 +51,8 @@ DIALOG_SELECT_3DMODEL::DIALOG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCac
m_previousDir( prevModelSelectDir ), m_previousDir( prevModelSelectDir ),
m_modelViewer( nullptr ) m_modelViewer( nullptr )
{ {
m_modelViewer = new EDA_3D_MODEL_VIEWER( m_pane3Dviewer, m_modelViewer = new EDA_3D_MODEL_VIEWER(
OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ), m_pane3Dviewer, OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE::AA_8X ), m_cache );
m_cache );
m_modelViewer->SetMinSize( wxSize( 400, -1 ) ); m_modelViewer->SetMinSize( wxSize( 400, -1 ) );
m_Sizer3Dviewer->Add( m_modelViewer, 1, wxEXPAND|wxRIGHT, 5 ); m_Sizer3Dviewer->Add( m_modelViewer, 1, wxEXPAND|wxRIGHT, 5 );

View File

@ -74,7 +74,8 @@ bool PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow()
cfg->m_Render.show_model_bbox = m_checkBoxBoundingBoxes->GetValue(); cfg->m_Render.show_model_bbox = m_checkBoxBoundingBoxes->GetValue();
cfg->m_Render.highlight_on_rollover = m_checkBoxHighlightOnRollOver->GetValue(); cfg->m_Render.highlight_on_rollover = m_checkBoxHighlightOnRollOver->GetValue();
cfg->m_Render.opengl_AA_mode = static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() ); cfg->m_Render.opengl_AA_mode =
static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() );
cfg->m_Render.opengl_selection_color = m_selectionColorSwatch->GetSwatchColor(); cfg->m_Render.opengl_selection_color = m_selectionColorSwatch->GetSwatchColor();
cfg->m_Render.opengl_AA_disableOnMove = m_checkBoxDisableAAMove->GetValue(); cfg->m_Render.opengl_AA_disableOnMove = m_checkBoxDisableAAMove->GetValue();

View File

@ -142,7 +142,9 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_boardAdapter.SetBoard( m_dummyBoard ); m_boardAdapter.SetBoard( m_dummyBoard );
m_boardAdapter.m_IsBoardView = false; m_boardAdapter.m_IsBoardView = false;
m_boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless the 3D viewer options
// Force display 3D models, regardless the 3D viewer options.
m_boardAdapter.m_IsPreviewer = true;
loadSettings(); loadSettings();
@ -244,7 +246,8 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
*/ */
static double rotationFromString( const wxString& aValue ) static double rotationFromString( const wxString& aValue )
{ {
double rotation = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES, aValue ); double rotation = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
aValue );
if( rotation > MAX_ROTATION ) if( rotation > MAX_ROTATION )
{ {
@ -307,7 +310,7 @@ void PANEL_PREVIEW_3D_MODEL::SetSelectedModel( int idx )
yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) ); yscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.y ) );
zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) ); zscale->ChangeValue( formatScaleValue( modelInfo.m_Scale.z ) );
// Rotation is stored in the file as postive-is-CW, but we use postive-is-CCW in the GUI // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
// to match the rest of KiCad // to match the rest of KiCad
xrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.x ) ); xrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.x ) );
yrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.y ) ); yrot->ChangeValue( formatRotationValue( -modelInfo.m_Rotation.y ) );
@ -354,7 +357,7 @@ void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event )
modelInfo->m_Scale.z = EDA_UNIT_UTILS::UI::DoubleValueFromString( modelInfo->m_Scale.z = EDA_UNIT_UTILS::UI::DoubleValueFromString(
pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() ); pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() );
// Rotation is stored in the file as postive-is-CW, but we use postive-is-CCW in the GUI // Rotation is stored in the file as positive-is-CW, but we use positive-is-CCW in the GUI
// to match the rest of KiCad // to match the rest of KiCad
modelInfo->m_Rotation.x = -rotationFromString( xrot->GetValue() ); modelInfo->m_Rotation.x = -rotationFromString( xrot->GetValue() );
modelInfo->m_Rotation.y = -rotationFromString( yrot->GetValue() ); modelInfo->m_Rotation.y = -rotationFromString( yrot->GetValue() );
@ -395,7 +398,7 @@ void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event ) void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
{ {
// turn ON or OFF options to show the board body if OFF, soder paste, soldermask // turn ON or OFF options to show the board body if OFF, solder paste, soldermask
// and board body are hidden, to allows a good view of the 3D model and its pads. // and board body are hidden, to allows a good view of the 3D model and its pads.
EDA_3D_VIEWER_SETTINGS* cfg = m_boardAdapter.m_Cfg; EDA_3D_VIEWER_SETTINGS* cfg = m_boardAdapter.m_Cfg;
@ -663,4 +666,4 @@ void PANEL_PREVIEW_3D_MODEL::onModify()
if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::DIALOG ) if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::DIALOG )
static_cast<DIALOG_SHIM*>( kiwayHolder )->OnModify(); static_cast<DIALOG_SHIM*>( kiwayHolder )->OnModify();
} }

View File

@ -40,11 +40,11 @@ class wxCloseEvent;
struct KICOMMON_API NOTIFICATION struct KICOMMON_API NOTIFICATION
{ {
public: public:
wxString title; ///< Title of the notification wxString title; ///< Title of the notification.
wxString description; ///< Additional message displayed under title wxString description; ///< Additional message displayed under title.
wxString href; ///< URL if any to link to for details wxString href; ///< URL if any to link to for details.
wxString key; ///< Unique key to find a notification wxString key; ///< Unique key to find a notification.
wxString date; ///< Date notification will display wxString date; ///< Date notification will display.
}; };
@ -56,66 +56,67 @@ public:
NOTIFICATIONS_MANAGER(); NOTIFICATIONS_MANAGER();
/** /**
* Creates a notification with the given parameters or updates an existing one with the same key * Create a notification with the given parameters or updates an existing one with the same key.
* *
* @param aKey is a unique key for the notification, this allows removing or updating the same notification * @param aKey is a unique key for the notification, this allows removing or updating the same
* @param aTitle is the displayed title for the event * notification.
* @param aTitle is the displayed title for the event.
* @param aDescription is the text that displays underneath the title and has slightly more info * @param aDescription is the text that displays underneath the title and has slightly more info
* them later programtically in case a notificaiton is no logner required * them later programatically in case a notification is no longer required.
* @param aHref is link to external or internal content * @param aHref is link to external or internal content.
*/ */
void CreateOrUpdate( const wxString& aKey, const wxString& aTitle, const wxString& aDescription, void CreateOrUpdate( const wxString& aKey, const wxString& aTitle, const wxString& aDescription,
const wxString& aHref = wxEmptyString ); const wxString& aHref = wxEmptyString );
/** /**
* Remove a notification by key * Remove a notification by key.
* *
* @param aKey is the unique key to locate * @param aKey is the unique key to locate.
*/ */
void Remove( const wxString& aKey ); void Remove( const wxString& aKey );
/** /**
* Loads notifications stored from disk * Load notifications stored from disk.
*/ */
void Load(); void Load();
/** /**
* Saves notifications to disk * Save notifications to disk.
*/ */
void Save(); void Save();
/** /**
* Shows the notification list * Show the notification list.
*/ */
void ShowList( wxWindow* aParent, wxPoint aPos ); void ShowList( wxWindow* aParent, wxPoint aPos );
/** /**
* Add a status bar for handling * Add a status bar for handling.
*/ */
void RegisterStatusBar( KISTATUSBAR* aStatusBar ); void RegisterStatusBar( KISTATUSBAR* aStatusBar );
/** /**
* Removes status bar from handling * Remove status bar from handling.
*/ */
void UnregisterStatusBar( KISTATUSBAR* aStatusBar ); void UnregisterStatusBar( KISTATUSBAR* aStatusBar );
private: private:
/** /**
* Handles removing the shown list window from our list of shown windows * Handle removing the shown list window from our list of shown windows.
*/ */
void onListWindowClosed( wxCloseEvent& aEvent ); void onListWindowClosed( wxCloseEvent& aEvent );
///< Current stack of notifications /// Current stack of notifications.
std::vector<NOTIFICATION> m_notifications; std::vector<NOTIFICATION> m_notifications;
///< Currently shown notification lists /// Currently shown notification lists.
std::vector<NOTIFICATIONS_LIST*> m_shownDialogs; std::vector<NOTIFICATIONS_LIST*> m_shownDialogs;
///< Status bars registered for updates /// Status bars registered for updates.
std::vector<KISTATUSBAR*> m_statusBars; std::vector<KISTATUSBAR*> m_statusBars;
///< The cached file path to read/write notifications on disk /// The cached file path to read/write notifications on disk.
wxFileName m_destFileName; wxFileName m_destFileName;
}; };
#endif #endif

View File

@ -41,7 +41,7 @@ namespace KIGFX {
class ORIGIN_VIEWITEM : public EDA_ITEM class ORIGIN_VIEWITEM : public EDA_ITEM
{ {
public: public:
///< Marker symbol styles /// Marker symbol styles.
enum MARKER_STYLE enum MARKER_STYLE
{ {
NO_GRAPHIC, CROSS, X, DOT, CIRCLE_CROSS, CIRCLE_X, CIRCLE_DOT, DASH_LINE NO_GRAPHIC, CROSS, X, DOT, CIRCLE_CROSS, CIRCLE_X, CIRCLE_DOT, DASH_LINE
@ -144,22 +144,22 @@ public:
} }
protected: protected:
///< Marker coordinates. /// Marker coordinates.
VECTOR2D m_position; VECTOR2D m_position;
///< Marker end position for markers that stretch between points /// Marker end position for markers that stretch between points.
VECTOR2D m_end; VECTOR2D m_end;
///< Marker size (in pixels). /// Marker size (in pixels).
int m_size; int m_size;
///< Marker color. /// Marker color.
COLOR4D m_color; COLOR4D m_color;
///< Marker symbol. /// Marker symbol.
MARKER_STYLE m_style; MARKER_STYLE m_style;
///< If set, the marker will be drawn even if its position is 0,0 /// If set, the marker will be drawn even if its position is 0,0.
bool m_drawAtZero; bool m_drawAtZero;
}; };

View File

@ -137,7 +137,7 @@ public:
const VECTOR2I GetUserOrigin() const; const VECTOR2I GetUserOrigin() const;
/** /**
* Return a reference to the default ORIGIN_TRANSFORMS object * Return a reference to the default #ORIGIN_TRANSFORMS object.
*/ */
ORIGIN_TRANSFORMS& GetOriginTransforms() override; ORIGIN_TRANSFORMS& GetOriginTransforms() override;
@ -150,7 +150,7 @@ public:
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
/** /**
* Returns the BOARD_DESIGN_SETTINGS for the open project. * Return the BOARD_DESIGN_SETTINGS for the open project.
*/ */
virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const; virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
@ -159,7 +159,8 @@ public:
*/ */
virtual COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override virtual COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override
{ {
wxFAIL_MSG( wxT( "Color settings requested for a PCB_BASE_FRAME that does not override!" ) ); wxFAIL_MSG( wxT( "Color settings requested for a PCB_BASE_FRAME that does not "
"override!" ) );
return nullptr; return nullptr;
} }
@ -172,9 +173,10 @@ public:
const PCB_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_displayOptions; } const PCB_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_displayOptions; }
/** /**
* Updates the current display options from the given options struct * Update the current display options.
* @param aOptions is the options struct to apply *
* @param aRefresh will refresh the view after updating * @param aOptions is the options struct to apply.
* @param aRefresh will refresh the view after updating.
*/ */
void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh = true ); void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh = true );
@ -186,11 +188,13 @@ public:
/** /**
* Reload the footprint from the library. * Reload the footprint from the library.
*
* @param aFootprint is the footprint to reload. * @param aFootprint is the footprint to reload.
*/ */
virtual void ReloadFootprint( FOOTPRINT* aFootprint ) virtual void ReloadFootprint( FOOTPRINT* aFootprint )
{ {
wxFAIL_MSG( wxT( "Attempted to reload a footprint for PCB_BASE_FRAME that does not override!" ) ); wxFAIL_MSG( wxT( "Attempted to reload a footprint for PCB_BASE_FRAME that does not "
"override!" ) );
} }
/** /**
@ -224,7 +228,7 @@ public:
PCB_SCREEN* GetScreen() const override { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); } PCB_SCREEN* GetScreen() const override { return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); }
/** /**
* Shows the 3D view frame. * Show the 3D view frame.
* *
* If it does not exist, it is created. If it exists, it is brought to the foreground. * If it does not exist, it is created. If it exists, it is brought to the foreground.
*/ */
@ -250,13 +254,13 @@ public:
void OnModify() override; void OnModify() override;
/** /**
* Creates a new footprint, at position 0,0. * Create a new footprint at position 0,0.
* *
* The new footprint contains only 2 texts: a reference and a value: * The new footprint contains only 2 texts: a reference and a value:
* Reference = REF** * Reference = REF**
* Value = "VAL**" or Footprint name in lib * Value = "VAL**" or Footprint name in lib
* *
* @note They are dummy texts, which will be replaced by the actual texts when the * @note They are dummy texts which will be replaced by the actual texts when the
* footprint is placed on a board and a netlist is read. * footprint is placed on a board and a netlist is read.
* *
* @param aFootprintName is the name of the new footprint in library. * @param aFootprintName is the name of the new footprint in library.
@ -265,7 +269,7 @@ public:
FOOTPRINT* CreateNewFootprint( wxString aFootprintName, const wxString& aLibName ); FOOTPRINT* CreateNewFootprint( wxString aFootprintName, const wxString& aLibName );
/** /**
* Places \a aFootprint at the current cursor position and updates footprint coordinates * Place \a aFootprint at the current cursor position and updates footprint coordinates
* with the new position. * with the new position.
* *
* @param aRecreateRatsnest A bool true redraws the footprint ratsnest. * @param aRecreateRatsnest A bool true redraws the footprint ratsnest.
@ -307,7 +311,7 @@ public:
virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) {}; virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) {};
/** /**
* Creates a new entry in undo list of commands. * Create a new entry in undo list of commands.
* *
* @param aItemsList is the list of items modified by the command to undo. * @param aItemsList is the list of items modified by the command to undo.
* @param aTypeCommand is the command type (see enum #UNDO_REDO) * @param aTypeCommand is the command type (see enum #UNDO_REDO)
@ -336,9 +340,9 @@ public:
wxPoint aDlgPosition = wxDefaultPosition ); wxPoint aDlgPosition = wxDefaultPosition );
/** /**
* Change the active layer in the frame * Change the active layer in the frame.
* *
* @param aLayer New layer to make active * @param aLayer New layer to make active.
*/ */
virtual void SwitchLayer( PCB_LAYER_ID aLayer ); virtual void SwitchLayer( PCB_LAYER_ID aLayer );
@ -369,7 +373,7 @@ public:
/** /**
* Add \a aListener to post #EDA_EVT_BOARD_CHANGED command events to. * Add \a aListener to post #EDA_EVT_BOARD_CHANGED command events to.
* *
* @warning The caller is reponsible for removing any listeners that are no long valid. * @warning The caller is responsible for removing any listeners that are no long valid.
* *
* @note This only gets called when the board editor is in stand alone mode. Changing * @note This only gets called when the board editor is in stand alone mode. Changing
* projects in the project manager closes the board editor when a new project is * projects in the project manager closes the board editor when a new project is
@ -402,7 +406,7 @@ protected:
virtual void doReCreateMenuBar() override; virtual void doReCreateMenuBar() override;
/** /**
* Attempts to load \a aFootprintId from the footprint library table. * Attempt to load \a aFootprintId from the footprint library table.
* *
* @param aFootprintId is the #LIB_ID of component footprint to load. * @param aFootprintId is the #LIB_ID of component footprint to load.
* @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the * @return the #FOOTPRINT if found or NULL if \a aFootprintId not found in any of the
@ -417,7 +421,8 @@ protected:
void rebuildConnectivity(); void rebuildConnectivity();
/** /**
* Creates (or removes) a watcher on the specified footprint * Create or removes a watcher on the specified footprint.
*
* @param aFootprint If nullptr, the watcher is removed. Otherwise, set a change watcher * @param aFootprint If nullptr, the watcher is removed. Otherwise, set a change watcher
*/ */
void setFPWatcher( FOOTPRINT* aFootprint ); void setFPWatcher( FOOTPRINT* aFootprint );

View File

@ -126,9 +126,15 @@ public:
virtual COMMON_SETTINGS* GetCommonSettings() const; virtual COMMON_SETTINGS* GetCommonSettings() const;
virtual BACKGROUND_JOBS_MONITOR& GetBackgroundJobMonitor() const { return *m_background_jobs_monitor; } virtual BACKGROUND_JOBS_MONITOR& GetBackgroundJobMonitor() const
{
return *m_background_jobs_monitor;
}
virtual NOTIFICATIONS_MANAGER& GetNotificationsManager() const { return *m_notifications_manager; } virtual NOTIFICATIONS_MANAGER& GetNotificationsManager() const
{
return *m_notifications_manager;
}
#ifdef KICAD_IPC_API #ifdef KICAD_IPC_API
virtual API_PLUGIN_MANAGER& GetPluginManager() const { return *m_plugin_manager; } virtual API_PLUGIN_MANAGER& GetPluginManager() const { return *m_plugin_manager; }
@ -150,11 +156,11 @@ public:
virtual const wxString& GetTextEditor( bool aCanShowFileChooser = true ); virtual const wxString& GetTextEditor( bool aCanShowFileChooser = true );
/** /**
* Shows a dialog that instructs the user to select a new preferred editor. * Show a dialog that instructs the user to select a new preferred editor.
*
* @param aDefaultEditor Default full path for the default editor this dialog should * @param aDefaultEditor Default full path for the default editor this dialog should
* show by default. * show by default.
* @return Returns the full path of the editor, or an empty string if no editor was * @return the full path of the editor, or an empty string if no editor was chosen.
* chosen.
*/ */
virtual const wxString AskUserForPreferredEditor( virtual const wxString AskUserForPreferredEditor(
const wxString& aDefaultEditor = wxEmptyString ); const wxString& aDefaultEditor = wxEmptyString );
@ -199,10 +205,12 @@ public:
virtual bool SetLanguage( wxString& aErrMsg, bool first_time = false ); virtual bool SetLanguage( wxString& aErrMsg, bool first_time = false );
/** /**
* Set the default language without reference to any preferences. Can be used to set * Set the default language without reference to any preferences.
* the language for dialogs that show before preferences are loaded *
* @param aErrMsg String to return the error message(s) in * Can be used to set the language for dialogs that show before preferences are loaded.
* @return false if the language could not be set *
* @param aErrMsg String to return the error message(s) in.
* @return false if the language could not be set.
*/ */
bool SetDefaultLanguage( wxString& aErrMsg ); bool SetDefaultLanguage( wxString& aErrMsg );
@ -238,7 +246,7 @@ public:
virtual void WritePdfBrowserInfos(); virtual void WritePdfBrowserInfos();
/** /**
* Sets the environment variable \a aName to \a aValue. * Set the environment variable \a aName to \a aValue.
* *
* This function first checks to see if the environment variable \a aName is already * This function first checks to see if the environment variable \a aName is already
* defined. If it is not defined, then the environment variable \a aName is set to * defined. If it is not defined, then the environment variable \a aName is set to
@ -252,8 +260,9 @@ public:
virtual bool SetLocalEnvVariable( const wxString& aName, const wxString& aValue ); virtual bool SetLocalEnvVariable( const wxString& aName, const wxString& aValue );
/** /**
* Updates the local environment with the contents of the current ENV_VAR_MAP stored in the * Update the local environment with the contents of the current #ENV_VAR_MAP stored in the
* COMMON_SETTINGS * #COMMON_SETTINGS.
*
* @see GetLocalEnvVariables() * @see GetLocalEnvVariables()
*/ */
virtual void SetLocalEnvVariables(); virtual void SetLocalEnvVariables();
@ -261,7 +270,7 @@ public:
virtual ENV_VAR_MAP& GetLocalEnvVariables() const; virtual ENV_VAR_MAP& GetLocalEnvVariables() const;
/** /**
* Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe. * Return a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
* *
* This should return what wxGetApp() returns. * This should return what wxGetApp() returns.
*/ */
@ -303,51 +312,51 @@ public:
bool IsSentryOptedIn(); bool IsSentryOptedIn();
/** /**
* Sets the Sentry opt in state, this will also terminate sentry * Set the Sentry opt in state, this will also terminate sentry
* immediately if needed, however it will not init sentry if opted in * immediately if needed, however it will not init sentry if opted in.
* *
* @param aOptIn True/false to agreeing to the use of sentry * @param aOptIn True/false to agreeing to the use of sentry.
*/ */
void SetSentryOptIn( bool aOptIn ); void SetSentryOptIn( bool aOptIn );
/** /**
* Generates and stores a new sentry id at random using the boost uuid generator * Generate and stores a new sentry id at random using the boost uuid generator.
*/ */
void ResetSentryId(); void ResetSentryId();
/** /**
* Gets the current id string being used as "user id" in sentry reports * Get the current id string being used as "user id" in sentry reports.
*/ */
const wxString& GetSentryId(); const wxString& GetSentryId();
#endif #endif
/** /**
* A exception handler to be used at the top level if exceptions bubble up that for * A exception handler to be used at the top level if exceptions bubble up that for.
* *
* The purpose is to have a central place to log a wxWidgets error message and/or sentry report * The purpose is to have a central place to log a wxWidgets error message and/or sentry report.
* *
* @param aPtr Pass the std::current_exception() from within the catch block * @param aPtr Pass the std::current_exception() from within the catch block.
*/ */
void HandleException( std::exception_ptr aPtr ); void HandleException( std::exception_ptr aPtr );
/** /**
* A common assert handler to be used between single_top and kicad * A common assert handler to be used between single_top and kicad.
* *
* This lets us have a common set of assert handling, including triggering sentry reports * This lets us have a common set of assert handling, including triggering sentry reports.
* *
* @param aFile the file path of the assert * @param aFile the file path of the assert.
* @param aLine the line number of the assert * @param aLine the line number of the assert.
* @param aFunc the function name the assert is within * @param aFunc the function name the assert is within.
* @param aCond the condition of the assert * @param aCond the condition of the assert.
* @param aMsg the attached assert message (can be empty) * @param aMsg the attached assert message (can be empty).
*/ */
void HandleAssert( const wxString& aFile, int aLine, const wxString& aFunc, void HandleAssert( const wxString& aFile, int aLine, const wxString& aFunc,
const wxString& aCond, const wxString& aMsg ); const wxString& aCond, const wxString& aMsg );
/** /**
* Determine if the application is running with a GUI * Determine if the application is running with a GUI.
* *
* @return true if there is a GUI and false otherwise * @return true if there is a GUI and false otherwise.
*/ */
bool IsGUI(); bool IsGUI();
@ -356,8 +365,8 @@ public:
void HideSplash(); void HideSplash();
/** /**
* Allows access to the wxSingleInstanceChecker to test for other running KiCads * Allow access to the wxSingleInstanceChecker to test for other running KiCads.
*/ */
std::unique_ptr<wxSingleInstanceChecker>& SingleInstance() std::unique_ptr<wxSingleInstanceChecker>& SingleInstance()
{ {
return m_pgm_checker; return m_pgm_checker;
@ -375,10 +384,10 @@ public:
bool m_PropertyGridInitialized; bool m_PropertyGridInitialized;
protected: protected:
/// Loads internal settings from COMMON_SETTINGS /// Load internal settings from #COMMON_SETTINGS.
void loadCommonSettings(); void loadCommonSettings();
/// Trap all changes in here, simplifies debugging /// Trap all changes in here, simplifies debugging.
void setLanguageId( int aId ) { m_language_id = aId; } void setLanguageId( int aId ) { m_language_id = aId; }
#ifdef KICAD_USE_SENTRY #ifdef KICAD_USE_SENTRY
@ -394,7 +403,7 @@ protected:
std::unique_ptr<SCRIPTING> m_python_scripting; std::unique_ptr<SCRIPTING> m_python_scripting;
/// Checks if there is another copy of Kicad running at the same time /// Check if there is another copy of Kicad running at the same time.
std::unique_ptr<wxSingleInstanceChecker> m_pgm_checker; std::unique_ptr<wxSingleInstanceChecker> m_pgm_checker;
#ifdef KICAD_IPC_API #ifdef KICAD_IPC_API
@ -402,13 +411,13 @@ protected:
std::unique_ptr<KICAD_API_SERVER> m_api_server; std::unique_ptr<KICAD_API_SERVER> m_api_server;
#endif #endif
wxString m_kicad_env; /// The KICAD system environment variable. wxString m_kicad_env; ///< The KICAD system environment variable.
wxLocale* m_locale; wxLocale* m_locale;
int m_language_id; int m_language_id;
bool m_use_system_pdf_browser; bool m_use_system_pdf_browser;
wxString m_pdf_browser; /// Filename of the app selected for browsing PDFs wxString m_pdf_browser; ///< Filename of the app selected for browsing PDFs.
wxString m_text_editor; wxString m_text_editor;
@ -420,8 +429,12 @@ protected:
wxString m_sentryUid; wxString m_sentryUid;
#endif #endif
char** m_argvUtf8; /// argv parameters converted to utf8 form, because wxwidgets has opinions /**
/// and will return argv as either force converted to ascii in char* or wchar_t only * argv parameters converted to utf8 form because wxWidgets has opinions.
*
* This will return argv as either force converted to ASCII in char* or wchar_t only.
*/
char** m_argvUtf8;
int m_argcUtf8; int m_argcUtf8;
@ -429,12 +442,18 @@ protected:
}; };
/// The global Program "get" accessor. /**
/// Implemented in: 1) common/single_top.cpp, 2) kicad/kicad.cpp, and 3) scripting/kiway.i * The global program "get" accessor.
*
* Implemented in:
* 1. common/single_top.cpp
* 2. kicad/kicad.cpp
* 3. scripting/kiway.i
*/
KICOMMON_API extern PGM_BASE& Pgm(); KICOMMON_API extern PGM_BASE& Pgm();
/// similar to PGM_BASE& Pgm(), but return a reference that can be nullptr /// Return a reference that can be nullptr when running a shared lib from a script, not from
/// when running a shared lib from a script, not from a kicad appl /// a kicad app.
KICOMMON_API extern PGM_BASE* PgmOrNull(); KICOMMON_API extern PGM_BASE* PgmOrNull();
KICOMMON_API extern void SetPgm( PGM_BASE* pgm ); KICOMMON_API extern void SetPgm( PGM_BASE* pgm );

View File

@ -148,7 +148,8 @@ public:
* @return None * @return None
*/ */
virtual void GetJsonViolation( RC_JSON::VIOLATION& aViolation, UNITS_PROVIDER* aUnitsProvider, virtual void GetJsonViolation( RC_JSON::VIOLATION& aViolation, UNITS_PROVIDER* aUnitsProvider,
SEVERITY aSeverity, const std::map<KIID, EDA_ITEM*>& aItemMap ) const; SEVERITY aSeverity,
const std::map<KIID, EDA_ITEM*>& aItemMap ) const;
int GetErrorCode() const { return m_errorCode; } int GetErrorCode() const { return m_errorCode; }
void SetErrorCode( int aCode ) { m_errorCode = aCode; } void SetErrorCode( int aCode ) { m_errorCode = aCode; }
@ -205,7 +206,8 @@ public:
COMMENT COMMENT
}; };
RC_TREE_NODE( RC_TREE_NODE* aParent, const std::shared_ptr<RC_ITEM>& aRcItem, NODE_TYPE aType ) : RC_TREE_NODE( RC_TREE_NODE* aParent, const std::shared_ptr<RC_ITEM>& aRcItem,
NODE_TYPE aType ) :
m_Type( aType ), m_Type( aType ),
m_RcItem( aRcItem ), m_RcItem( aRcItem ),
m_Parent( aParent ) m_Parent( aParent )
@ -293,8 +295,9 @@ public:
void DeleteCurrentItem( bool aDeep ); void DeleteCurrentItem( bool aDeep );
/** /**
* Deletes the current item or all items. If all, \a aIncludeExclusions determines * Delete the current item or all items.
* whether or not exclusions are also deleted. *
* If all, \a aIncludeExclusions determines whether or not exclusions are also deleted.
*/ */
void DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, bool aDeep ); void DeleteItems( bool aCurrentOnly, bool aIncludeExclusions, bool aDeep );

View File

@ -140,9 +140,10 @@ private:
const EDA_IU_SCALE& m_iuScale; const EDA_IU_SCALE& m_iuScale;
VECTOR2I m_pos; // XY coordinates of center of the bitmap VECTOR2I m_pos; ///< XY coordinates of center of the bitmap.
///< Center of scaling, etc, relative to the image center
/// Center of scaling, etc, relative to the image center.
VECTOR2I m_transformOriginOffset; VECTOR2I m_transformOriginOffset;
std::unique_ptr<BITMAP_BASE> m_bitmapBase; std::unique_ptr<BITMAP_BASE> m_bitmapBase;
}; };

View File

@ -72,7 +72,7 @@ KICOMMON_API std::string
/** /**
* Nominally opens a file and reads it into a string. But unlike other facilities, this handles * Nominally opens a file and reads it into a string. But unlike other facilities, this handles
* mis-encded Wine-written files on macOS. * mis-encoded Wine-written files on macOS.
* *
* @param aFilePath * @param aFilePath
* @param aReadType * @param aReadType
@ -297,7 +297,7 @@ public:
char* ReadLine() override; char* ReadLine() override;
protected: protected:
wxInputStream* m_stream; //< The input stream to read. No ownership of this pointer. wxInputStream* m_stream; ///< The input stream to read. No ownership of this pointer.
}; };

View File

@ -35,189 +35,242 @@
#include <string> #include <string>
#include <typeinfo> #include <typeinfo>
#if defined(__ANDROID__) && !defined(RTTI_DUMP_USE_PRINTF) #if defined( __ANDROID__ ) && !defined( RTTI_DUMP_USE_PRINTF )
#include <android/log.h> #include <android/log.h>
#define RTTI_DUMP_LOG(fmt, ...) \ #define RTTI_DUMP_LOG( fmt, ... ) \
__android_log_print(ANDROID_LOG_INFO, "rtti_dump", fmt, ## __VA_ARGS__) __android_log_print( ANDROID_LOG_INFO, "rtti_dump", fmt, ##__VA_ARGS__ )
#else #else
#define RTTI_DUMP_LOG(fmt, ...) printf(fmt "\n", ## __VA_ARGS__) #define RTTI_DUMP_LOG( fmt, ... ) printf( fmt "\n", ##__VA_ARGS__ )
#endif #endif
// Avoid compiler warnings. // Avoid compiler warnings.
#define RTTI_DUMP_UNUSED __attribute__((unused)) #define RTTI_DUMP_UNUSED __attribute__( ( unused ) )
// Use an anonymous namespace so this header file can be included at the top of // Use an anonymous namespace so this header file can be included at the top of
// multiple C++ source files without breaking the One Definition Rule. // multiple C++ source files without breaking the One Definition Rule.
namespace rtti_dump { namespace rtti_dump
namespace { {
namespace
{
// Returns the type of the current exception object or NULL if the thread is // Returns the type of the current exception object or NULL if the thread is
// not currently in a catch block. // not currently in a catch block.
extern "C" const std::type_info *__cxa_current_exception_type(); extern "C" const std::type_info* __cxa_current_exception_type();
// Using run-time type information, returns an std::type_info* corresponding to // Using run-time type information, returns an std::type_info* corresponding to
// the most-derived class of a pointer to an object. The pointed-to type must // the most-derived class of a pointer to an object. The pointed-to type must
// be a polymorphic class. (i.e. The class must have a virtual function or a // be a polymorphic class. (i.e. The class must have a virtual function or a
// base class with a virtual function.) // base class with a virtual function.)
// //
// The function can return NULL if the object's vtable comes from an object // The function can return NULL if the object's vtable comes from an object
// file compiled without -frtti. // file compiled without -frtti.
template <typename T> template <typename T>
RTTI_DUMP_UNUSED const std::type_info *runtime_typeid(const volatile T *dynptr) { RTTI_DUMP_UNUSED const std::type_info* runtime_typeid( const volatile T* dynptr )
T *dynptr_unqual = const_cast<T*>(dynptr); {
T* dynptr_unqual = const_cast<T*>( dynptr );
// Use dynamic_cast<void*> to ensure that T is polymorphic. The result is // Use dynamic_cast<void*> to ensure that T is polymorphic. The result is
// discarded just in case the most-derived object vtable and the subobject // discarded just in case the most-derived object vtable and the subobject
// vtable point to different typeinfo objects. (XXX: I *think* that's // vtable point to different typeinfo objects. (XXX: I *think* that's
// impossible, though.) // impossible, though.)
(void)sizeof(dynamic_cast<void*>(dynptr_unqual)); (void) sizeof( dynamic_cast<void*>( dynptr_unqual ) );
void *vptr = *reinterpret_cast<void**>(dynptr_unqual); void* vptr = *reinterpret_cast<void**>( dynptr_unqual );
void *typeid_void = reinterpret_cast<void**>(vptr)[-1]; void* typeid_void = reinterpret_cast<void**>( vptr )[-1];
return reinterpret_cast<const std::type_info*>(typeid_void); return reinterpret_cast<const std::type_info*>( typeid_void );
}
// Returns the name of the DSO or binary containing the given address.
RTTI_DUMP_UNUSED std::string dladdr_fname(const void *ptr) {
Dl_info info = { 0 };
if (!dladdr(const_cast<void*>(ptr), &info)) {
char buf[64];
snprintf(buf, sizeof(buf), "[error: dladdr failed - %d]", errno);
return buf;
} else {
return std::string(info.dli_fname);
}
}
// Dump the address of the std::type_info object, its name, and the shared
// object where the type_info object is defined.
RTTI_DUMP_UNUSED
void dump_type(const std::type_info *type, const char *label="dump_type", int indent=0) {
const std::string prefix = label + std::string(": ") + std::string(indent, ' ');
if (type == NULL) {
RTTI_DUMP_LOG("%sERROR: dump_type called with type==NULL!", prefix.c_str());
} else {
struct type_info {
virtual ~type_info() {}
const char *type_name;
};
assert(sizeof(type_info) == sizeof(std::type_info));
const char *const name = type->name();
const char *const raw_name = reinterpret_cast<const type_info*>(type)->type_name;
if (name == raw_name) {
RTTI_DUMP_LOG("%stype %s:", prefix.c_str(), name);
} else if (raw_name + 1 == name) {
RTTI_DUMP_LOG("%stype %s (raw name == '%s' @ %p):", prefix.c_str(), name, raw_name, raw_name);
} else {
RTTI_DUMP_LOG("%stype %s (raw name == %p):", prefix.c_str(), name, raw_name);
}
RTTI_DUMP_LOG("%s type_info obj: %p (in %s)",
prefix.c_str(), type, dladdr_fname(type).c_str());
RTTI_DUMP_LOG("%s type_info name: %p (in %s)",
prefix.c_str(), name, dladdr_fname(name).c_str());
}
}
// Call from a catch block to dump the type of the current exception.
RTTI_DUMP_UNUSED
void dump_current_exception(const char *label="dump_current_exception") {
const std::type_info *type = __cxa_current_exception_type();
if (type != NULL) {
dump_type(type, label);
} else {
RTTI_DUMP_LOG("%s: ERROR: dump_current_exception called outside a catch block!", label);
}
}
namespace hierarchy_dumper_internals {
// std::type_info has virtual member functions, so the most-derived type of
// a pointer to a std::type_info object can be determined at run-time by
// looking for the std::type_info's own std::type_info. We rely upon this
// property to walk a class's RTTI graph at run-time.
struct __class_type_info : std::type_info {};
struct __si_class_type_info : __class_type_info {
const __class_type_info *__base_type;
};
struct __base_class_type_info {
const __class_type_info* __base_type;
long __offset_flags;
};
struct __vmi_class_type_info : __class_type_info {
unsigned int __flags;
unsigned int __base_count;
__base_class_type_info __base_info[1];
};
class Dumper {
const char *label_;
std::set<const std::type_info*> seen_;
public:
Dumper(const char *label) : label_(label) {}
void dump_type(const std::type_info *info, int indent);
};
const int kIndent = 4;
void Dumper::dump_type(const std::type_info *info, int indent) {
::rtti_dump::dump_type(info, label_, indent * kIndent);
if (info == NULL) {
return;
} }
const std::type_info *info_type = runtime_typeid(info); // Returns the name of the DSO or binary containing the given address.
__base_class_type_info lone_base = { 0 }; RTTI_DUMP_UNUSED std::string dladdr_fname( const void* ptr )
const __base_class_type_info *base_table = NULL; {
unsigned int base_count = 0; Dl_info info = { 0 };
// Determine type equality using a string comparison, because this dumping if( !dladdr( const_cast<void*>( ptr ), &info ) )
// system doesn't trust std::type_info::operator== to work with multiple {
// shared objects. char buf[64];
snprintf( buf, sizeof( buf ), "[error: dladdr failed - %d]", errno );
const int sub_indent_sp = (indent + 1) * kIndent; return buf;
}
if (info_type == NULL) { else
// I don't think info_type can ever be NULL here. {
RTTI_DUMP_LOG("%s: %*sERROR: runtime_typeid(info) was NULL!", label_, sub_indent_sp, ""); return std::string( info.dli_fname );
} else if (!strcmp(info_type->name(), "N10__cxxabiv120__si_class_type_infoE")) {
const __si_class_type_info &infox =
*reinterpret_cast<const __si_class_type_info*>(info);
lone_base.__base_type = infox.__base_type;
base_count = 1;
base_table = &lone_base;
} else if (!strcmp(info_type->name(), "N10__cxxabiv121__vmi_class_type_infoE")) {
const __vmi_class_type_info &infox =
*reinterpret_cast<const __vmi_class_type_info*>(info);
base_count = infox.__base_count;
base_table = infox.__base_info;
}
if (base_count > 0) {
if (seen_.find(info) != seen_.end()) {
RTTI_DUMP_LOG("%s: %*sbase classes: ...elided...", label_, sub_indent_sp, "");
} else {
RTTI_DUMP_LOG("%s: %*sbase classes:", label_, sub_indent_sp, "");
seen_.insert(info);
for (unsigned int i = 0; i < base_count; ++i) {
dump_type(base_table[i].__base_type, indent + 2);
} }
}
} }
}
} // namespace hierarchy_dumper_internals
// Dump the std::type_info object, and if it represents a class with base // Dump the address of the std::type_info object, its name, and the shared
// classes, then dumps the class hierarchy. // object where the type_info object is defined.
RTTI_DUMP_UNUSED RTTI_DUMP_UNUSED
void dump_class_hierarchy(const std::type_info *info, const char *label="dump_class_hierarchy") { void dump_type( const std::type_info* type, const char* label = "dump_type", int indent = 0 )
hierarchy_dumper_internals::Dumper dumper(label); {
dumper.dump_type(info, 0); const std::string prefix = label + std::string( ": " ) + std::string( indent, ' ' );
}
if( type == NULL )
{
RTTI_DUMP_LOG( "%sERROR: dump_type called with type==NULL!", prefix.c_str() );
}
else
{
struct type_info
{
virtual ~type_info() {}
const char* type_name;
};
assert( sizeof( type_info ) == sizeof( std::type_info ) );
const char* const name = type->name();
const char* const raw_name = reinterpret_cast<const type_info*>( type )->type_name;
if( name == raw_name )
{
RTTI_DUMP_LOG( "%stype %s:", prefix.c_str(), name );
}
else if( raw_name + 1 == name )
{
RTTI_DUMP_LOG( "%stype %s (raw name == '%s' @ %p):", prefix.c_str(), name, raw_name,
raw_name );
}
else
{
RTTI_DUMP_LOG( "%stype %s (raw name == %p):", prefix.c_str(), name, raw_name );
}
RTTI_DUMP_LOG( "%s type_info obj: %p (in %s)", prefix.c_str(), type,
dladdr_fname( type ).c_str() );
RTTI_DUMP_LOG( "%s type_info name: %p (in %s)", prefix.c_str(), name,
dladdr_fname( name ).c_str() );
}
}
// Call from a catch block to dump the type of the current exception.
RTTI_DUMP_UNUSED
void dump_current_exception( const char* label = "dump_current_exception" )
{
const std::type_info* type = __cxa_current_exception_type();
if( type != NULL )
{
dump_type( type, label );
}
else
{
RTTI_DUMP_LOG( "%s: ERROR: dump_current_exception called outside a catch block!",
label );
}
}
namespace hierarchy_dumper_internals
{
// std::type_info has virtual member functions, so the most-derived type of
// a pointer to a std::type_info object can be determined at run-time by
// looking for the std::type_info's own std::type_info. We rely upon this
// property to walk a class's RTTI graph at run-time.
struct __class_type_info : std::type_info
{
};
struct __si_class_type_info : __class_type_info
{
const __class_type_info* __base_type;
};
struct __base_class_type_info
{
const __class_type_info* __base_type;
long __offset_flags;
};
struct __vmi_class_type_info : __class_type_info
{
unsigned int __flags;
unsigned int __base_count;
__base_class_type_info __base_info[1];
};
class Dumper
{
const char* label_;
std::set<const std::type_info*> seen_;
public:
Dumper( const char* label ) : label_( label ) {}
void dump_type( const std::type_info* info, int indent );
};
const int kIndent = 4;
void Dumper::dump_type( const std::type_info* info, int indent )
{
::rtti_dump::dump_type( info, label_, indent * kIndent );
if( info == NULL )
{
return;
}
const std::type_info* info_type = runtime_typeid( info );
__base_class_type_info lone_base = { 0 };
const __base_class_type_info* base_table = NULL;
unsigned int base_count = 0;
// Determine type equality using a string comparison, because this dumping
// system doesn't trust std::type_info::operator== to work with multiple
// shared objects.
const int sub_indent_sp = ( indent + 1 ) * kIndent;
if( info_type == NULL )
{
// I don't think info_type can ever be NULL here.
RTTI_DUMP_LOG( "%s: %*sERROR: runtime_typeid(info) was NULL!", label_,
sub_indent_sp, "" );
}
else if( !strcmp( info_type->name(), "N10__cxxabiv120__si_class_type_infoE" ) )
{
const __si_class_type_info& infox =
*reinterpret_cast<const __si_class_type_info*>( info );
lone_base.__base_type = infox.__base_type;
base_count = 1;
base_table = &lone_base;
}
else if( !strcmp( info_type->name(), "N10__cxxabiv121__vmi_class_type_infoE" ) )
{
const __vmi_class_type_info& infox =
*reinterpret_cast<const __vmi_class_type_info*>( info );
base_count = infox.__base_count;
base_table = infox.__base_info;
}
if( base_count > 0 )
{
if( seen_.find( info ) != seen_.end() )
{
RTTI_DUMP_LOG( "%s: %*sbase classes: ...elided...", label_, sub_indent_sp, "" );
}
else
{
RTTI_DUMP_LOG( "%s: %*sbase classes:", label_, sub_indent_sp, "" );
seen_.insert( info );
for( unsigned int i = 0; i < base_count; ++i )
{
dump_type( base_table[i].__base_type, indent + 2 );
}
}
}
}
} // namespace hierarchy_dumper_internals
// Dump the std::type_info object, and if it represents a class with base
// classes, then dumps the class hierarchy.
RTTI_DUMP_UNUSED
void dump_class_hierarchy( const std::type_info* info,
const char* label = "dump_class_hierarchy" )
{
hierarchy_dumper_internals::Dumper dumper( label );
dumper.dump_type( info, 0 );
}
} // anonymous namespace } // anonymous namespace
} // namespace rtti_dump } // namespace rtti_dump

View File

@ -46,9 +46,7 @@ template <typename VAL_TYPE>
class SCOPED_SET_RESET class SCOPED_SET_RESET
{ {
public: public:
SCOPED_SET_RESET( VAL_TYPE& target, VAL_TYPE value ) : m_target( target )
SCOPED_SET_RESET( VAL_TYPE& target, VAL_TYPE value ):
m_target( target )
{ {
m_original = target; m_original = target;
m_target = value; m_target = value;
@ -57,13 +55,10 @@ public:
/** /**
* Destruct the class, and return the target to its original value. * Destruct the class, and return the target to its original value.
*/ */
~SCOPED_SET_RESET() ~SCOPED_SET_RESET() { m_target = m_original; }
{
m_target = m_original;
}
private: private:
VAL_TYPE m_original; VAL_TYPE m_original;
VAL_TYPE& m_target; VAL_TYPE& m_target;
}; };
@ -72,21 +67,18 @@ private:
* RAII class that executes a function at construction and another at destruction. * RAII class that executes a function at construction and another at destruction.
* *
* Useful to ensure cleanup code is executed even if an exception is thrown. * Useful to ensure cleanup code is executed even if an exception is thrown.
*/ */
template <typename Func> template <typename Func>
class SCOPED_EXECUTION class SCOPED_EXECUTION
{ {
public: public:
SCOPED_EXECUTION(Func initFunc, Func destroyFunc) : SCOPED_EXECUTION( Func initFunc, Func destroyFunc ) :
m_initFunc(initFunc), m_destroyFunc(destroyFunc) m_initFunc( initFunc ), m_destroyFunc( destroyFunc )
{ {
m_initFunc(); m_initFunc();
} }
~SCOPED_EXECUTION() ~SCOPED_EXECUTION() { m_destroyFunc(); }
{
m_destroyFunc();
}
private: private:
Func m_initFunc; Func m_initFunc;

View File

@ -41,7 +41,6 @@ class EDA_DRAW_FRAME;
* A tiny, headerless popup window used to display useful status (e.g. line length * A tiny, headerless popup window used to display useful status (e.g. line length
* tuning info) next to the mouse cursor. * tuning info) next to the mouse cursor.
*/ */
class STATUS_POPUP: public wxPopupWindow class STATUS_POPUP: public wxPopupWindow
{ {
public: public:
@ -67,7 +66,7 @@ protected:
void onCharHook( wxKeyEvent& aEvent ); void onCharHook( wxKeyEvent& aEvent );
///< Expire timer even handler /// Expire timer even handler.
void onExpire( wxTimerEvent& aEvent ); void onExpire( wxTimerEvent& aEvent );
protected: protected:

View File

@ -62,8 +62,8 @@ struct LINE_STYLE_DESC
}; };
/* /**
* Conversion map between LINE_STYLE values and style names displayed * Conversion map between LINE_STYLE values and style names displayed.
*/ */
extern const std::map<LINE_STYLE, struct LINE_STYLE_DESC> lineTypeNames; extern const std::map<LINE_STYLE, struct LINE_STYLE_DESC> lineTypeNames;
@ -113,7 +113,8 @@ public:
static void Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWidth, static void Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWidth,
const KIGFX::RENDER_SETTINGS* aRenderSettings, const KIGFX::RENDER_SETTINGS* aRenderSettings,
const std::function<void( const VECTOR2I& a, const VECTOR2I& b )>& aStroker ); const std::function<void( const VECTOR2I& a,
const VECTOR2I& b )>& aStroker );
private: private:
int m_width; int m_width;

View File

@ -52,7 +52,7 @@ class BASE_SCREEN;
/** /**
* Type of undo/redo operations * Type of undo/redo operations.
* *
* Each type must be redo/undone by a specific operation. * Each type must be redo/undone by a specific operation.
*/ */
@ -122,7 +122,8 @@ private:
* duplicate) m_Item points the duplicate (i.e the old * duplicate) m_Item points the duplicate (i.e the old
* copy of an active item) and m_Link points the active * copy of an active item) and m_Link points the active
* item in schematic */ * item in schematic */
KIID m_groupId; /* Id of the group of items in case this is a group/ungroup command */ KIID m_groupId; /* Id of the group of items in case this is a
* group/ungroup command */
BASE_SCREEN* m_screen; /* For new and deleted items the screen the item should BASE_SCREEN* m_screen; /* For new and deleted items the screen the item should
* be added to/removed from. */ * be added to/removed from. */

View File

@ -51,10 +51,12 @@
/** /**
* This class provides a custom wxValidator object for limiting the allowable characters when * Provide a custom wxValidator object for limiting the allowable characters when
* defining footprint names. Since the introduction of the PRETTY footprint library format, * defining footprint names.
* footprint names cannot have any characters that would prevent file creation on any platform. *
* The characters \/:*?|"<> are illegal and filtered by the validator. * Since the introduction of the PRETTY footprint library format, footprint names cannot have
* any characters that would prevent file creation on any platform. The characters \/:*?|"<>
* are illegal and filtered by the validator.
*/ */
class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator
{ {
@ -64,8 +66,9 @@ public:
/** /**
* This class provides a custom wxValidator object for limiting the allowable characters when * Provide a custom wxValidator object for limiting the allowable characters when
* defining file names with path, for instance in schematic sheet file names. * defining file names with path, for instance in schematic sheet file names.
*
* The characters *?|"<> are illegal and filtered by the validator, * The characters *?|"<> are illegal and filtered by the validator,
* but /\: are valid (\ and : only on Windows.) * but /\: are valid (\ and : only on Windows.)
*/ */
@ -77,10 +80,11 @@ public:
/** /**
* This class provides a custom wxValidator object for limiting the allowable characters * Provide a custom wxValidator object for limiting the allowable characters when defining an
* when defining an environment variable name in a text edit control. Only uppercase, * environment variable name in a text edit control.
* numbers, and underscore (_) characters are valid and the first character of the name *
* cannot start with a number. This is according to IEEE Std 1003.1-2001. Even though * Only uppercase, numbers, and underscore (_) characters are valid and the first character of
* the name cannot start with a number. This is according to IEEE Std 1003.1-2001. Even though
* most systems support other characters, these characters guarantee compatibility for * most systems support other characters, these characters guarantee compatibility for
* all shells. * all shells.
*/ */
@ -106,8 +110,7 @@ public:
/** /**
* Custom validator that checks verifies that a string *exactly* matches a * Custom validator that checks verifies that a string *exactly* matches a regular expression.
* regular expression.
*/ */
class REGEX_VALIDATOR : public wxTextValidator class REGEX_VALIDATOR : public wxTextValidator
{ {
@ -151,16 +154,16 @@ public:
} }
protected: protected:
///< Compiles and stores a regular expression /// Compiles and stores a regular expression.
void compileRegEx( const wxString& aRegEx, int aFlags ); void compileRegEx( const wxString& aRegEx, int aFlags );
///< Original regular expression (for copy constructor) /// Original regular expression (for copy constructor).
wxString m_regExString; wxString m_regExString;
///< Original compilation flags (for copy constructor) /// Original compilation flags (for copy constructor).
int m_regExFlags; int m_regExFlags;
///< Compiled regex /// Compiled regular expression.
wxRegEx m_regEx; wxRegEx m_regEx;
}; };
@ -182,7 +185,7 @@ public:
virtual bool Validate( wxWindow *aParent ) override; virtual bool Validate( wxWindow *aParent ) override;
protected: protected:
// returns the error message if the contents of 'val' are invalid /// @return the error message if the contents of @a aVal are invalid.
wxString IsValid( const wxString& aVal ) const override; wxString IsValid( const wxString& aVal ) const override;
private: private: