refactoring: removed dependency of libpcbcommon on 3d-viewer.

This commit is contained in:
Tomasz Włostowski 2017-10-27 16:25:20 +02:00
parent 08a9dc01c5
commit 90ab5860dc
25 changed files with 83 additions and 62 deletions

View File

@ -44,7 +44,6 @@ class S3D_CACHE_ENTRY;
class SCENEGRAPH;
class S3D_FILENAME_RESOLVER;
class S3D_PLUGIN_MANAGER;
struct S3D_INFO;
class S3D_CACHE

View File

@ -36,9 +36,13 @@
#include <wx/string.h>
#include <plugins/3dapi/sg_base.h>
class MODULE_3D_SETTINGS;
struct S3D_INFO
{
S3D_INFO();
S3D_INFO( const MODULE_3D_SETTINGS& aModel );
SGPOINT m_Scale; ///< scaling factors for the 3D footprint shape
SGPOINT m_Rotation; ///< an X,Y,Z rotation (unit = degrees) for the 3D shape
SGPOINT m_Offset; ///< an offset (unit = inch) for the 3D shape

View File

@ -36,7 +36,6 @@
class wxWindow;
class KICAD_PLUGIN_LDR_3D;
struct S3D_INFO;
class SCENEGRAPH;
class S3D_PLUGIN_MANAGER

View File

@ -32,7 +32,7 @@
bool S3D::Select3DModel( wxWindow* aParent, S3D_CACHE* aCache,
wxString& prevModelSelectDir, int& prevModelWildcard, S3D_INFO* aModel )
wxString& prevModelSelectDir, int& prevModelWildcard, MODULE_3D_SETTINGS* aModel )
{
if( NULL == aModel )
return false;

View File

@ -28,12 +28,11 @@
class S3D_CACHE;
class S3D_FILENAME_RESOLVER;
struct S3D_INFO;
namespace S3D
{
bool Select3DModel( wxWindow* aParent, S3D_CACHE* aCache,
wxString& prevModelSelectDir, int& prevModelWildcard, S3D_INFO* aModel );
wxString& prevModelSelectDir, int& prevModelWildcard, MODULE_3D_SETTINGS* aModel );
bool Configure3DPaths( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver );
};

View File

@ -31,6 +31,7 @@
#include "3d_cache_dialogs.h"
#include <3d_model_viewer/c3d_model_viewer.h>
#include <common_ogl/cogl_att_list.h>
#include <pcbnew/class_module.h>
#define ID_FILE_TREE ( wxID_LAST + 1 )
#define ID_SET_DIR ( ID_FILE_TREE + 1 )
@ -46,7 +47,7 @@ wxEND_EVENT_TABLE()
DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager,
S3D_INFO* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) :
MODULE_3D_SETTINGS* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) :
wxDialog( aParent, wxID_ANY, _( "Select 3D Model" ), wxDefaultPosition,
wxSize( 500,200 ), wxCAPTION | wxRESIZE_BORDER | wxCLOSE_BOX
| wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU ),

View File

@ -38,7 +38,7 @@
#include <wx/sizer.h>
#include <wx/frame.h>
struct S3D_INFO;
struct MODULE_3D_SETTINGS;
class S3D_CACHE;
class S3D_FILENAME_RESOLVER;
class C3D_MODEL_VIEWER;
@ -47,7 +47,7 @@ class C3D_MODEL_VIEWER;
class DLG_SELECT_3DMODEL : public wxDialog
{
private:
S3D_INFO* m_model; // data for the selected model
MODULE_3D_SETTINGS* m_model; // data for the selected model
S3D_CACHE* m_cache; // cache manager
S3D_FILENAME_RESOLVER* m_resolver; // 3D filename resolver
@ -61,7 +61,7 @@ private:
void updateDirChoiceList( void );
public:
DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, S3D_INFO* aModelItem,
DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, MODULE_3D_SETTINGS* aModelItem,
wxString& prevModelSelectDir, int& prevModelWildcard );
bool TransferDataFromWindow() override;

View File

@ -45,7 +45,7 @@
PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager,
MODULE* aModuleCopy,
COLORS_DESIGN_SETTINGS *aColors,
std::vector<S3D_INFO> *aParentInfoList ):
std::vector<MODULE_3D_SETTINGS> *aParentInfoList ):
PANEL_PREV_3D_BASE( aParent, wxID_ANY )
{
initPanel();
@ -204,7 +204,7 @@ void PANEL_PREV_3D::SetModelDataIdx( int idx, bool aReloadPreviewModule )
// next updates, it will set first an
// invalid selection
const S3D_INFO *aModel = (const S3D_INFO *)&((*m_parentInfoList)[idx]);
const MODULE_3D_SETTINGS *aModel = (const MODULE_3D_SETTINGS *)&((*m_parentInfoList)[idx]);
xscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.x ) );
yscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.y ) );
@ -360,9 +360,15 @@ void PANEL_PREV_3D::updateOrientation( wxCommandEvent &event )
getOrientationVars( scale, rotation, offset );
m_modelInfo.m_Scale = scale;
m_modelInfo.m_Offset = offset;
m_modelInfo.m_Rotation = rotation;
m_modelInfo.m_Scale.x = scale.x;
m_modelInfo.m_Scale.y = scale.y;
m_modelInfo.m_Scale.z = scale.z;
m_modelInfo.m_Offset.x = offset.x;
m_modelInfo.m_Offset.y = offset.y;
m_modelInfo.m_Offset.z = offset.z;
m_modelInfo.m_Rotation.x = rotation.x;
m_modelInfo.m_Rotation.y = rotation.y;
m_modelInfo.m_Rotation.z = rotation.z;
if( m_currentSelectedIdx >= 0 )
{
@ -590,9 +596,12 @@ bool PANEL_PREV_3D::ValidateWithMessage( wxString& aErrorMessage )
{
wxString msg;
bool addError = false;
S3D_INFO& s3dshape = (*m_parentInfoList)[idx];
MODULE_3D_SETTINGS& s3dshape = (*m_parentInfoList)[idx];
SGPOINT scale = s3dshape.m_Scale;
SGPOINT scale;
scale.x = s3dshape.m_Scale.x;
scale.y = s3dshape.m_Scale.y;
scale.z = s3dshape.m_Scale.z;
if( 1/MAX_SCALE > scale.x || MAX_SCALE < scale.x )
{
@ -646,7 +655,7 @@ bool PANEL_PREV_3D::ValidateWithMessage( wxString& aErrorMessage )
void PANEL_PREV_3D::updateListOnModelCopy()
{
std::list<S3D_INFO>* draw3D = &m_copyModule->Models();
auto draw3D = &m_copyModule->Models();
draw3D->clear();
draw3D->insert( draw3D->end(), m_parentInfoList->begin(), m_parentInfoList->end() );
}

View File

@ -38,7 +38,6 @@
#include "panel_prev_3d_base.h"
#include "../3d_info.h"
#include <vector>
#include <3d_canvas/eda_3d_canvas.h>
@ -76,7 +75,7 @@ public:
PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager,
MODULE* aModuleCopy,
COLORS_DESIGN_SETTINGS *aColors,
std::vector<S3D_INFO> *aParentInfoList = NULL );
std::vector<MODULE_3D_SETTINGS> *aParentInfoList = NULL );
~PANEL_PREV_3D();
@ -96,14 +95,14 @@ private:
/// A pointer to a new copy of the original module
MODULE *m_copyModule;
/// A pointer to the parent S3D_INFO list that we will use to copy to the preview module
std::vector<S3D_INFO> *m_parentInfoList;
/// A pointer to the parent MODULE_3D_SETTINGS list that we will use to copy to the preview module
std::vector<MODULE_3D_SETTINGS> *m_parentInfoList;
/// The current selected index of the S3D_INFO list
/// The current selected index of the MODULE_3D_SETTINGS list
int m_currentSelectedIdx;
/// Current S3D_INFO that is being edited
S3D_INFO m_modelInfo;
/// Current MODULE_3D_SETTINGS that is being edited
MODULE_3D_SETTINGS m_modelInfo;
// Methods of the class
private:

View File

@ -934,8 +934,8 @@ void C3D_RENDER_OGL_LEGACY::load_3D_models()
if( !module->Models().empty() )
{
// Get the list of model files for this model
std::list<S3D_INFO>::const_iterator sM = module->Models().begin();
std::list<S3D_INFO>::const_iterator eM = module->Models().end();
auto sM = module->Models().begin();
auto eM = module->Models().end();
while( sM != eM )
{

View File

@ -1026,8 +1026,8 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
modelunit_to_3d_units_factor );
// Get the list of model files for this model
std::list<S3D_INFO>::const_iterator sM = module->Models().begin();
std::list<S3D_INFO>::const_iterator eM = module->Models().end();
auto sM = module->Models().begin();
auto eM = module->Models().end();
while( sM != eM )
{

View File

@ -1248,8 +1248,8 @@ void C3D_RENDER_RAYTRACING::load_3D_models()
// Get the list of model files for this model
std::list<S3D_INFO>::const_iterator sM = module->Models().begin();
std::list<S3D_INFO>::const_iterator eM = module->Models().end();
auto sM = module->Models().begin();
auto eM = module->Models().end();
while( sM != eM )
{

View File

@ -35,7 +35,6 @@
class SGNODE;
class SCENEGRAPH;
struct S3D_INFO;
struct S3D_POINT;
namespace S3D

View File

@ -740,7 +740,7 @@ unsigned MODULE::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
}
void MODULE::Add3DModel( S3D_INFO* a3DModel )
void MODULE::Add3DModel( MODULE_3D_SETTINGS* a3DModel )
{
if( NULL == a3DModel )
return;

View File

@ -42,7 +42,6 @@
#include <class_text_mod.h>
#include <PolyLine.h>
#include "zones.h"
#include <3d_cache/3d_info.h>
#include <core/iterators.h>
@ -80,6 +79,19 @@ enum MODULE_ATTR_T
///< board (Like edge card connectors, mounting hole...)
};
class MODULE_3D_SETTINGS
{
public:
struct VECTOR3D
{
double x, y, z;
};
VECTOR3D m_Scale;
VECTOR3D m_Rotation;
VECTOR3D m_Offset;
wxString m_Filename; ///< The 3D shape filename in 3D library
};
class MODULE : public BOARD_ITEM_CONTAINER
{
@ -147,8 +159,8 @@ public:
return DLIST_ITERATOR_WRAPPER<BOARD_ITEM>( m_Drawings );
}
std::list<S3D_INFO>& Models() { return m_3D_Drawings; }
const std::list<S3D_INFO>& Models() const { return m_3D_Drawings; }
std::list<MODULE_3D_SETTINGS>& Models() { return m_3D_Drawings; }
const std::list<MODULE_3D_SETTINGS>& Models() const { return m_3D_Drawings; }
void SetPosition( const wxPoint& aPos ) override;
@ -546,9 +558,9 @@ public:
* Function Add3DModel
* adds \a a3DModel definition to the end of the 3D model list.
*
* @param a3DModel A pointer to a #S3D_INFO to add to the list.
* @param a3DModel A pointer to a #MODULE_3D_SETTINGS to add to the list.
*/
void Add3DModel( S3D_INFO* a3DModel );
void Add3DModel( MODULE_3D_SETTINGS* a3DModel );
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
@ -669,7 +681,7 @@ public:
private:
DLIST<D_PAD> m_Pads; ///< Linked list of pads.
DLIST<BOARD_ITEM> m_Drawings; ///< Linked list of graphical items.
std::list<S3D_INFO> m_3D_Drawings; ///< Linked list of 3D models.
std::list<MODULE_3D_SETTINGS> m_3D_Drawings; ///< Linked list of 3D models.
double m_Orient; ///< Orientation in tenths of a degree, 900=90.0 degrees.
wxPoint m_Pos; ///< Position of module on the board in internal units.
TEXTE_MODULE* m_Reference; ///< Component reference designator value (U34, R18..)

View File

@ -289,8 +289,8 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
// Init 3D shape list
m_3D_ShapeNameListBox->Clear();
std::list<S3D_INFO>::iterator sM = m_CurrentModule->Models().begin();
std::list<S3D_INFO>::iterator eM = m_CurrentModule->Models().end();
auto sM = m_CurrentModule->Models().begin();
auto eM = m_CurrentModule->Models().end();
m_shapes3D_list.clear();
wxString origPath;
@ -525,7 +525,7 @@ void DIALOG_MODULE_BOARD_EDITOR::Edit3DShapeFileName()
void DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile()
{
PROJECT& prj = Prj();
S3D_INFO model;
MODULE_3D_SETTINGS model;
wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
@ -733,7 +733,7 @@ bool DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow()
return false;
}
std::list<S3D_INFO>* draw3D = &m_CurrentModule->Models();
std::list<MODULE_3D_SETTINGS>* draw3D = &m_CurrentModule->Models();
draw3D->clear();
draw3D->insert( draw3D->end(), m_shapes3D_list.begin(), m_shapes3D_list.end() );

View File

@ -40,7 +40,7 @@ private:
MODULE* m_CurrentModule;
TEXTE_MODULE* m_ReferenceCopy;
TEXTE_MODULE* m_ValueCopy;
std::vector <S3D_INFO> m_shapes3D_list;
std::vector <MODULE_3D_SETTINGS> m_shapes3D_list;
int m_LastSelected3DShapeIndex;
static size_t m_page; // remember the last open page during session
PANEL_PREV_3D* m_PreviewPane;

View File

@ -139,8 +139,8 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
// Init 3D shape list
m_3D_ShapeNameListBox->Clear();
std::list<S3D_INFO>::iterator sM = m_currentModule->Models().begin();
std::list<S3D_INFO>::iterator eM = m_currentModule->Models().end();
auto sM = m_currentModule->Models().begin();
auto eM = m_currentModule->Models().end();
m_shapes3D_list.clear();
@ -383,7 +383,7 @@ void DIALOG_MODULE_MODULE_EDITOR::Edit3DShapeFileName()
void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile()
{
PROJECT& prj = Prj();
S3D_INFO model;
MODULE_3D_SETTINGS model;
wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
@ -520,7 +520,7 @@ bool DIALOG_MODULE_MODULE_EDITOR::TransferDataFromWindow()
m_currentModule->SetLocalSolderPasteMarginRatio( dtmp / 100 );
std::list<S3D_INFO>* draw3D = &m_currentModule->Models();
std::list<MODULE_3D_SETTINGS>* draw3D = &m_currentModule->Models();
draw3D->clear();
draw3D->insert( draw3D->end(), m_shapes3D_list.begin(), m_shapes3D_list.end() );

View File

@ -40,7 +40,7 @@ private:
MODULE* m_currentModule;
TEXTE_MODULE* m_referenceCopy;
TEXTE_MODULE* m_valueCopy;
std::vector<S3D_INFO> m_shapes3D_list;
std::vector<MODULE_3D_SETTINGS> m_shapes3D_list;
int m_lastSelected3DShapeIndex;
static size_t m_page; // remember the last open page during session
PANEL_PREV_3D* m_PreviewPane;

View File

@ -379,8 +379,8 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule,
IDF3_COMPONENT* comp = NULL;
std::list<S3D_INFO>::const_iterator sM = aModule->Models().begin();
std::list<S3D_INFO>::const_iterator eM = aModule->Models().end();
auto sM = aModule->Models().begin();
auto eM = aModule->Models().end();
wxFileName idfFile;
wxString idfExt;

View File

@ -1304,8 +1304,8 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb,
bool isFlipped = aModule->GetLayer() == B_Cu;
// Export the object VRML model(s)
std::list<S3D_INFO>::iterator sM = aModule->Models().begin();
std::list<S3D_INFO>::iterator eM = aModule->Models().end();
auto sM = aModule->Models().begin();
auto eM = aModule->Models().end();
wxFileName subdir( SUBDIR_3D, "" );

View File

@ -1131,8 +1131,8 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
format( pad, aNestLevel+1 );
// Save 3D info.
std::list<S3D_INFO>::const_iterator bs3D = aModule->Models().begin();
std::list<S3D_INFO>::const_iterator es3D = aModule->Models().end();
auto bs3D = aModule->Models().begin();
auto es3D = aModule->Models().end();
while( bs3D != es3D )
{

View File

@ -1867,7 +1867,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText )
void LEGACY_PLUGIN::load3D( MODULE* aModule )
{
S3D_INFO t3D;
MODULE_3D_SETTINGS t3D;
char* line;
while( ( line = READLINE( m_reader ) ) != NULL )
@ -3071,8 +3071,8 @@ void LEGACY_PLUGIN::init( const PROPERTIES* aProperties )
void LEGACY_PLUGIN::SaveModule3D( const MODULE* me ) const
{
std::list<S3D_INFO>::const_iterator sM = me->Models().begin();
std::list<S3D_INFO>::const_iterator eM = me->Models().end();
auto sM = me->Models().begin();
auto eM = me->Models().end();
while( sM != eM )
{

View File

@ -332,14 +332,14 @@ void PCB_PARSER::parseEDA_TEXT( EDA_TEXT* aText )
}
S3D_INFO* PCB_PARSER::parse3DModel()
MODULE_3D_SETTINGS* PCB_PARSER::parse3DModel()
{
wxCHECK_MSG( CurTok() == T_model, NULL,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as S3D_INFO." ) );
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as MODULE_3D_SETTINGS." ) );
T token;
S3D_INFO* n3D = new S3D_INFO;
MODULE_3D_SETTINGS* n3D = new MODULE_3D_SETTINGS;
NeedSYMBOLorNUMBER();
n3D->m_Filename = FromUTF8();

View File

@ -35,7 +35,6 @@
#include <layers_id_colors_and_visibility.h> // PCB_LAYER_ID
#include <common.h> // KiROUND
#include <convert_to_biu.h> // IU_PER_MM
#include <3d_cache/3d_info.h>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
@ -55,6 +54,7 @@ class MODULE;
class PCB_TARGET;
class VIA;
class ZONE_CONTAINER;
class MODULE_3D_SETTINGS;
struct LAYER;
@ -198,7 +198,7 @@ class PCB_PARSER : public PCB_LEXER
*/
void parseEDA_TEXT( EDA_TEXT* aText );
S3D_INFO* parse3DModel();
MODULE_3D_SETTINGS* parse3DModel();
/**
* Function parseDouble