TestEgr 1.5d6 :
- aggiunto import di DXF e STL - aggiunto albero per materiali custom.
This commit is contained in:
+91
-34
@@ -32,9 +32,11 @@ static char THIS_FILE[] = __FILE__;
|
||||
|
||||
//--------------------------- Constants --------------------------------------
|
||||
// indici icone per Tree
|
||||
enum { ICO_NOGEO = 0, ICO_GROUP, ICO_VECTOR, ICO_POINT, ICO_FRAME,
|
||||
ICO_LINE, ICO_ARC, ICO_CBEZIER, ICO_CCOMPO, ICO_STRIMESH} ;
|
||||
|
||||
enum { ICO_MATERS = 0, ICO_ONEMATER, ICO_NOGEO, ICO_GROUP, ICO_VECTOR, ICO_POINT,
|
||||
ICO_FRAME, ICO_LINE, ICO_ARC, ICO_CBEZIER, ICO_CCOMPO, ICO_STRIMESH} ;
|
||||
// costanti per materiali custom/ geometrie
|
||||
static const int GEOM = 0x0000000 ;
|
||||
static const int CMAT = 0x1000000 ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
@@ -48,6 +50,8 @@ CTestEGrDlg::PrepareTree( void)
|
||||
if ( m_pImgList == nullptr)
|
||||
return false ;
|
||||
m_pImgList->Create( 16, 16, ILC_COLOR, 10, 4) ;
|
||||
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_MATERS)) ;
|
||||
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_ONEMATER)) ;
|
||||
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_NOGEO)) ;
|
||||
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_GROUP)) ;
|
||||
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_VECTOR)) ;
|
||||
@@ -68,7 +72,7 @@ bool
|
||||
CTestEGrDlg::ClearTree( void)
|
||||
{
|
||||
// ripristino stato eventuale ultimo oggetto selezionato
|
||||
RevertOldIdOnTree() ;
|
||||
RevertOldIdInTree() ;
|
||||
|
||||
// svuoto l'albero
|
||||
m_Tree.SelectItem( NULL) ;
|
||||
@@ -88,8 +92,11 @@ CTestEGrDlg::LoadTree( void)
|
||||
// disabilito aggiornamento
|
||||
m_Tree.SetRedraw( FALSE) ;
|
||||
|
||||
// ciclo sui materiali custom
|
||||
InsertCustomMaterialsInTree() ;
|
||||
|
||||
// ciclo su GeomDB
|
||||
InsertGroupOnTree( GDB_ID_ROOT, TVI_ROOT) ;
|
||||
InsertGroupInTree( GDB_ID_ROOT, TVI_ROOT) ;
|
||||
|
||||
// riabilito aggiornamento
|
||||
m_Tree.SetRedraw( TRUE) ;
|
||||
@@ -100,7 +107,33 @@ CTestEGrDlg::LoadTree( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::InsertGroupOnTree( int nId, HTREEITEM hParent)
|
||||
CTestEGrDlg::InsertCustomMaterialsInTree( void)
|
||||
{
|
||||
// inserisco la radice dei materiali custom
|
||||
HTREEITEM hMaters ;
|
||||
hMaters = m_Tree.InsertItem( L"Custom Materials", ICO_MATERS, ICO_MATERS, TVI_ROOT) ;
|
||||
if ( hMaters == nullptr || m_Tree.SetItemData( hMaters, CMAT | 0) == 0)
|
||||
return false ;
|
||||
|
||||
// inserisco i materiali custom
|
||||
for ( int i = 1 ; i <= m_pGeomDB->GetMaxMaterialId() ; ++i) {
|
||||
bool bCustom ;
|
||||
if ( m_pGeomDB->IsCustomMaterial( i, bCustom) && bCustom) {
|
||||
string sName ;
|
||||
m_pGeomDB->GetMaterialName( i, sName) ;
|
||||
HTREEITEM hOneMater ;
|
||||
hOneMater = m_Tree.InsertItem( stringtoW( sName), ICO_ONEMATER, ICO_ONEMATER, hMaters) ;
|
||||
if ( hOneMater == nullptr || m_Tree.SetItemData( hOneMater, CMAT | i) == 0)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::InsertGroupInTree( int nId, HTREEITEM hParent)
|
||||
{
|
||||
// inserisco il gruppo nell'albero (se non è la radice)
|
||||
string sGroup ;
|
||||
@@ -139,13 +172,13 @@ CTestEGrDlg::InsertGroupOnTree( int nId, HTREEITEM hParent)
|
||||
// se gruppo
|
||||
if ( nGdbType == GDB_TY_GROUP) {
|
||||
// lo inserisco nell'albero
|
||||
if ( ! InsertGroupOnTree( pIter->GetId(), hGroup))
|
||||
if ( ! InsertGroupInTree( pIter->GetId(), hGroup))
|
||||
return false ;
|
||||
}
|
||||
// se oggetto geometrico
|
||||
else if ( nGdbType == GDB_TY_GEO) {
|
||||
// lo inserisco nell'albero
|
||||
if ( ! InsertGeoObjOnTree( pIter->GetId(), pIter->GetGeoObj(), hGroup))
|
||||
if ( ! InsertGeoObjInTree( pIter->GetId(), pIter->GetGeoObj(), hGroup))
|
||||
return false ;
|
||||
}
|
||||
// passo al successivo
|
||||
@@ -157,7 +190,7 @@ CTestEGrDlg::InsertGroupOnTree( int nId, HTREEITEM hParent)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::InsertGeoObjOnTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent)
|
||||
CTestEGrDlg::InsertGeoObjInTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent)
|
||||
{
|
||||
int nImage ;
|
||||
string sName ;
|
||||
@@ -210,30 +243,35 @@ CTestEGrDlg::OnTreeSelChanged( NMHDR* pNMHDR, LRESULT* pResult)
|
||||
if ( hItemNew == nullptr)
|
||||
return ;
|
||||
int nIdNew = int( m_Tree.GetItemData( hItemNew)) ;
|
||||
if ( ! m_pGeomDB->ExistsObj( nIdNew))
|
||||
return ;
|
||||
// ripristino eventuale vecchio oggetto selezionato
|
||||
RevertOldIdOnTree() ;
|
||||
// visualizzo i dati dell'oggetto
|
||||
switch ( m_pGeomDB->GetGdbType( nIdNew)) {
|
||||
case GDB_TY_GROUP :
|
||||
OutGroupData( nIdNew) ;
|
||||
break ;
|
||||
case GDB_TY_GEO :
|
||||
OutGeoObjData( nIdNew) ;
|
||||
break ;
|
||||
RevertOldIdInTree() ;
|
||||
// se colore custom
|
||||
if ( ( nIdNew & CMAT) != 0) {
|
||||
OutMaterialData( nIdNew & ~CMAT) ;
|
||||
}
|
||||
// se oggetto geometrico
|
||||
if ( m_pGeomDB->ExistsObj( nIdNew)) {
|
||||
// visualizzo i dati dell'oggetto
|
||||
switch ( m_pGeomDB->GetGdbType( nIdNew)) {
|
||||
case GDB_TY_GROUP :
|
||||
OutGroupData( nIdNew) ;
|
||||
break ;
|
||||
case GDB_TY_GEO :
|
||||
OutGeoObjData( nIdNew) ;
|
||||
break ;
|
||||
}
|
||||
// permetto in ogni caso la visualizzazione dell'oggetto e lo marco
|
||||
int nOldMode = GDB_MD_STD ;
|
||||
m_pGeomDB->GetMode( nIdNew, nOldMode) ;
|
||||
int nMode = (( nOldMode == GDB_MD_HIDDEN) ? GDB_MD_STD : nOldMode) ;
|
||||
m_pGeomDB->SetMode( nIdNew, nMode) ;
|
||||
int nOldStatus = GDB_ST_ON ;
|
||||
m_pGeomDB->GetStatus( nIdNew, nOldStatus) ;
|
||||
int nStat = (( nOldStatus == GDB_ST_OFF) ? GDB_ST_ON : nOldStatus) ;
|
||||
m_pGeomDB->SetStatus( nIdNew, nStat) ;
|
||||
m_pGeomDB->SetMark( nIdNew) ;
|
||||
m_nOldIdTree = nIdNew ;
|
||||
}
|
||||
// permetto in ogni caso la visualizzazione dell'oggetto e lo marco
|
||||
int nOldMode = GDB_MD_STD ;
|
||||
m_pGeomDB->GetMode( nIdNew, nOldMode) ;
|
||||
int nMode = (( nOldMode == GDB_MD_HIDDEN) ? GDB_MD_STD : nOldMode) ;
|
||||
m_pGeomDB->SetMode( nIdNew, nMode) ;
|
||||
int nOldStatus = GDB_ST_ON ;
|
||||
m_pGeomDB->GetStatus( nIdNew, nOldStatus) ;
|
||||
int nStat = (( nOldStatus == GDB_ST_OFF) ? GDB_ST_ON : nOldStatus) ;
|
||||
m_pGeomDB->SetStatus( nIdNew, nStat) ;
|
||||
m_pGeomDB->SetMark( nIdNew) ;
|
||||
m_nOldIdTree = nIdNew ;
|
||||
// aggiorno la visualizzazione
|
||||
m_View.Redraw() ;
|
||||
}
|
||||
@@ -262,7 +300,7 @@ CTestEGrDlg::OnTreeDoubleClick( NMHDR* pNMHDR, LRESULT* pResult)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::SelectIdOnTree( int nId, HTREEITEM hParent)
|
||||
CTestEGrDlg::SelectIdInTree( int nId, HTREEITEM hParent)
|
||||
{
|
||||
HTREEITEM hItem ;
|
||||
if ( hParent == nullptr)
|
||||
@@ -278,7 +316,7 @@ CTestEGrDlg::SelectIdOnTree( int nId, HTREEITEM hParent)
|
||||
}
|
||||
// se ci sono dei figli, li analizzo
|
||||
if ( m_Tree.ItemHasChildren( hItem)) {
|
||||
if ( SelectIdOnTree( nId, hItem))
|
||||
if ( SelectIdInTree( nId, hItem))
|
||||
return true ;
|
||||
}
|
||||
// passo al successivo fratello
|
||||
@@ -289,7 +327,7 @@ CTestEGrDlg::SelectIdOnTree( int nId, HTREEITEM hParent)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
CTestEGrDlg::RevertOldIdOnTree( void)
|
||||
CTestEGrDlg::RevertOldIdInTree( void)
|
||||
{
|
||||
// verifiche sul DB geometrico
|
||||
if ( m_pGeomDB == nullptr)
|
||||
@@ -308,6 +346,25 @@ CTestEGrDlg::RevertOldIdOnTree( void)
|
||||
return nOldId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CTestEGrDlg::OutMaterialData( int nId)
|
||||
{
|
||||
string sName ;
|
||||
Material matM ;
|
||||
if ( m_pGeomDB->GetMaterialName( nId, sName) &&
|
||||
m_pGeomDB->GetMaterialData( nId, matM)) {
|
||||
string sOut = "Custom material " + sName + "\r\n" ;
|
||||
sOut += " AmbCol = " + ToString( matM.GetAmbient()) + "\r\n" ;
|
||||
sOut += " DiffCol = " + ToString( matM.GetDiffuse()) + "\r\n" ;
|
||||
sOut += " SpecCol = " + ToString( matM.GetSpecular()) + "\r\n" ;
|
||||
sOut += " Shininess = " + ToString( matM.GetShininess()) + "\r\n" ;
|
||||
OutData( sOut) ;
|
||||
}
|
||||
else
|
||||
OutData( "") ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CTestEGrDlg::OutGroupData( int nId)
|
||||
|
||||
BIN
Binary file not shown.
@@ -205,7 +205,9 @@
|
||||
<None Include="res\Group.ico" />
|
||||
<None Include="res\Line.ico" />
|
||||
<None Include="res\Logo.bmp" />
|
||||
<None Include="res\Maters.ico" />
|
||||
<None Include="res\NoGeo.ico" />
|
||||
<None Include="res\OneMater.ico" />
|
||||
<None Include="res\pan.cur" />
|
||||
<None Include="res\Point.ico" />
|
||||
<None Include="res\POINTER.cur" />
|
||||
|
||||
@@ -69,6 +69,12 @@
|
||||
<None Include="res\STriMesh.ico">
|
||||
<Filter>File di risorse</Filter>
|
||||
</None>
|
||||
<None Include="res\Maters.ico">
|
||||
<Filter>File di risorse</Filter>
|
||||
</None>
|
||||
<None Include="res\OneMater.ico">
|
||||
<Filter>File di risorse</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="TestEGr.h">
|
||||
|
||||
+166
-17
@@ -27,6 +27,8 @@
|
||||
#include "/EgtDev/Include/EExExcExecutor.h"
|
||||
#include "/EgtDev/Include/EGrScene.h"
|
||||
#include "/EgtDev/Include/EGrSceExecutor.h"
|
||||
#include "/EgtDev/Include/EExImportStl.h"
|
||||
#include "/EgtDev/Include/EExImportDxf.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -105,7 +107,7 @@ CTestEGrDlg::CTestEGrDlg( const std::string& sFileToOpen, ILogger* pLogGen, ILog
|
||||
CTestEGrDlg::~CTestEGrDlg( void)
|
||||
{
|
||||
// ripristino ultima entità selezionata sull'albero delle entità
|
||||
RevertOldIdOnTree() ;
|
||||
RevertOldIdInTree() ;
|
||||
// cancello esecutori
|
||||
if ( m_pGdbExec != nullptr)
|
||||
delete m_pGdbExec ;
|
||||
@@ -139,6 +141,7 @@ BEGIN_MESSAGE_MAP( CTestEGrDlg, CDialog)
|
||||
ON_BN_CLICKED( IDC_NEW, OnFileNew)
|
||||
ON_BN_CLICKED( IDC_OPEN, OnFileOpen)
|
||||
ON_BN_CLICKED( IDC_SAVE, OnFileSave)
|
||||
ON_BN_CLICKED( IDC_IMPORT, OnFileImport)
|
||||
ON_BN_CLICKED( IDC_EXEC, OnFileExec)
|
||||
ON_CONTROL_RANGE( BN_CLICKED, IDC_WIREFRAME, IDC_SHADING, OnShowMode)
|
||||
ON_CONTROL_RANGE( BN_CLICKED, IDC_ZOOM_ALL, IDC_ZOOM_OUT, OnZoom)
|
||||
@@ -193,17 +196,11 @@ CTestEGrDlg::OnInitDialog( void)
|
||||
|
||||
// creo il DB geometrico
|
||||
m_pGeomDB = CreateGeomDB() ;
|
||||
if ( m_pGeomDB != nullptr)
|
||||
m_pGeomDB->Init() ;
|
||||
else
|
||||
if ( m_pGeomDB == nullptr)
|
||||
LOG_ERROR( m_pLogGen, "Error in CreateGeomDB")
|
||||
|
||||
// imposto il materiale di default tramite colore
|
||||
if ( m_pGeomDB != nullptr) {
|
||||
Color colDef( 0, 0, 0) ;
|
||||
GetIniColor( "GeomDB", "DefaultColor", colDef) ;
|
||||
m_pGeomDB->SetDefaultMaterial( colDef) ;
|
||||
}
|
||||
// inizializzo il DB geometrico
|
||||
PrepareGeomDB() ;
|
||||
|
||||
// creo la vista per la scena
|
||||
if ( ! m_View.Create( this, IDC_SCENE))
|
||||
@@ -465,6 +462,7 @@ CTestEGrDlg::OnSize( UINT nType, int cx, int cy)
|
||||
MoveDlgItem( IDC_NEW, IP_TR, cx, cy) ;
|
||||
MoveDlgItem( IDC_OPEN, IP_TR, cx, cy) ;
|
||||
MoveDlgItem( IDC_SAVE, IP_TR, cx, cy) ;
|
||||
MoveDlgItem( IDC_IMPORT, IP_TR, cx, cy) ;
|
||||
MoveDlgItem( IDC_EXEC, IP_TR, cx, cy) ;
|
||||
MoveDlgItem( IDC_SEPAR, IP_TR, cx, cy) ;
|
||||
MoveDlgItem( IDC_WIREFRAME, IP_TR, cx, cy) ;
|
||||
@@ -666,7 +664,7 @@ CTestEGrDlg::OnFileOpen( void)
|
||||
// visualizzo il dialogo di scelta file
|
||||
CFileDialog dlg( TRUE, L"*.Nge", NULL,
|
||||
OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
|
||||
L"New geometry EgalTech (*.Nge) |*.Nge|", NULL, 0, FALSE) ;
|
||||
L"New geometry EgalTech (*.Nge) |*.Nge||", NULL, 0, FALSE) ;
|
||||
|
||||
// imposto il direttorio iniziale
|
||||
wstring wsDir = stringtoW( GetPrivateProfileStringUtf8( "General", "LastNgeDir", "", AfxGetApp()->m_pszProfileName)) ;
|
||||
@@ -701,7 +699,7 @@ CTestEGrDlg::OnFileSave( void)
|
||||
// visualizzo il dialogo di scelta file
|
||||
CFileDialog dlg( FALSE, L"*.Nge", stringtoW( m_sFileName),
|
||||
OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_NOCHANGEDIR,
|
||||
L"New geometry EgalTech (*.Nge) |*.Nge|", NULL, 0, FALSE) ;
|
||||
L"New geometry EgalTech (*.Nge) |*.Nge||", NULL, 0, FALSE) ;
|
||||
|
||||
// imposto il direttorio iniziale
|
||||
wstring wsDir = stringtoW( GetPrivateProfileStringUtf8( "General", "LastNgeDir", "", AfxGetApp()->m_pszProfileName)) ;
|
||||
@@ -729,6 +727,48 @@ CTestEGrDlg::OnFileSave( void)
|
||||
AfxMessageBox( L"Error saving file (look at Log file)", MB_ICONSTOP|MB_OK) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CTestEGrDlg::OnFileImport( void)
|
||||
{
|
||||
// gestisco eventuale file corrente modificato
|
||||
if ( ! ManageModified())
|
||||
return ;
|
||||
|
||||
// visualizzo il dialogo di scelta file
|
||||
CFileDialog dlg( TRUE, L"*.*", NULL,
|
||||
OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
|
||||
L"All Files (*.*)|*.*|"
|
||||
L"AutoCAD Drawing Exchange (*.dxf) |*.dxf|"
|
||||
L"Stereolithography (*.stl) |*.stl||",
|
||||
NULL, 0, FALSE) ;
|
||||
|
||||
// imposto il direttorio iniziale
|
||||
wstring wsDir = stringtoW( GetPrivateProfileStringUtf8( "General", "LastImpDir", "", AfxGetApp()->m_pszProfileName)) ;
|
||||
if ( ! wsDir.empty())
|
||||
dlg.m_ofn.lpstrInitialDir = wsDir.c_str() ;
|
||||
|
||||
// lancio il dialogo di scelta file
|
||||
if ( dlg.DoModal() != IDOK)
|
||||
return ;
|
||||
|
||||
// recupero la path del file
|
||||
string sFilePath = WtoA( dlg.GetPathName()) ;
|
||||
if ( sFilePath.empty())
|
||||
return ;
|
||||
|
||||
// divido in nome e direttorio e salvo quest'ultimo
|
||||
string sFileDir ;
|
||||
string sFileName ;
|
||||
SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
|
||||
if ( ! sFileDir.empty())
|
||||
WritePrivateProfileStringUtf8( "General", "LastImpDir", sFileDir.c_str(), AfxGetApp()->m_pszProfileName) ;
|
||||
|
||||
// carico il file
|
||||
if ( ! FileImport( sFilePath))
|
||||
AfxMessageBox( L"Error importing file (look at Log file)", MB_ICONSTOP|MB_OK) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CTestEGrDlg::OnFileExec( void)
|
||||
@@ -736,7 +776,7 @@ CTestEGrDlg::OnFileExec( void)
|
||||
// visualizzo il dialogo di scelta file
|
||||
CFileDialog dlg( TRUE, L"*.Tsc", NULL,
|
||||
OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
|
||||
L"Test script EgalTech (*.Tsc) |*.Tsc|", NULL, 0, FALSE) ;
|
||||
L"Test script EgalTech (*.Tsc) |*.Tsc||", NULL, 0, FALSE) ;
|
||||
|
||||
// imposto il direttorio iniziale
|
||||
wstring wsDir = stringtoW( GetPrivateProfileStringUtf8( "General", "LastTscDir", "", AfxGetApp()->m_pszProfileName)) ;
|
||||
@@ -825,6 +865,21 @@ CTestEGrDlg::PreTranslateMessage( MSG* pMsg)
|
||||
return CDialog::PreTranslateMessage( pMsg) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::PrepareGeomDB( void)
|
||||
{
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// pulisco e reinizializzo
|
||||
m_pGeomDB->Init() ;
|
||||
// imposto il materiale di default tramite colore
|
||||
Color colDef( 0, 0, 0) ;
|
||||
GetIniColor( "GeomDB", "DefaultColor", colDef) ;
|
||||
m_pGeomDB->SetDefaultMaterial( colDef) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::PrepareExecutor( void)
|
||||
@@ -925,7 +980,7 @@ CTestEGrDlg::FileNew( void)
|
||||
// pulisco l'albero delle entità
|
||||
ClearTree() ;
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
m_pGeomDB->Init() ;
|
||||
PrepareGeomDB() ;
|
||||
// visualizzo con zoom all
|
||||
m_View.Zoom( IDC_ZOOM_ALL) ;
|
||||
// inserisco il nome del file nel titolo della finestra
|
||||
@@ -964,7 +1019,7 @@ CTestEGrDlg::FileOpen( const string& sFilePath)
|
||||
// pulisco l'albero delle entità
|
||||
ClearTree() ;
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
m_pGeomDB->Init() ;
|
||||
PrepareGeomDB() ;
|
||||
// carico il file
|
||||
if ( ! m_pGeomDB->Load( sFilePath))
|
||||
return false ;
|
||||
@@ -1019,6 +1074,100 @@ CTestEGrDlg::FileSave( const string& sFilePath)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::FileImport( const string& sFilePath)
|
||||
{
|
||||
// verifico validità DB geometrico
|
||||
if ( m_pGeomDB == nullptr) {
|
||||
LOG_ERROR( m_pLogGen, "GeomDB invalid")
|
||||
return false ;
|
||||
}
|
||||
|
||||
// divido in nome e direttorio
|
||||
string sFileDir ;
|
||||
string sFileName ;
|
||||
SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
|
||||
|
||||
// recupero l'estensione
|
||||
string sFileTitle ;
|
||||
string sFileExt ;
|
||||
SplitLast( sFileName, ".", sFileTitle, sFileExt) ;
|
||||
ToUpper( sFileExt) ;
|
||||
|
||||
// verifico che l'estensione sia supportata
|
||||
if ( sFileExt != "DXF" && sFileExt != "STL") {
|
||||
// emetto info
|
||||
string sInfo = "File type (" + sFileExt + ") not recognized" ;
|
||||
LOG_INFO( m_pLogGen, sInfo.c_str())
|
||||
return false ;
|
||||
}
|
||||
|
||||
// inserisco il nome del file nel titolo della finestra
|
||||
m_sFileName = sFileTitle + ".Nge" ;
|
||||
m_bModified = true ;
|
||||
EmitTitle() ;
|
||||
// emetto info
|
||||
string sInfo = "Import File = " + sFilePath ;
|
||||
LOG_INFO( m_pLogGen, sInfo.c_str())
|
||||
|
||||
// pulisco l'albero delle entità
|
||||
ClearTree() ;
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
PrepareGeomDB() ;
|
||||
// importo il file DXF
|
||||
if ( sFileExt == "DXF") {
|
||||
// aggiungo un gruppo pezzo
|
||||
int nPartId = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
||||
// preparo l'importatore
|
||||
PtrOwner<IImportDxf> pImpDxf( CreateImportDxf()) ;
|
||||
if ( ! IsValid( pImpDxf)) {
|
||||
LOG_ERROR( m_pLogGen, "Error : CreateImportDxf")
|
||||
return false ;
|
||||
}
|
||||
// eseguo l'importazione
|
||||
if ( ! pImpDxf->Import( sFilePath, m_pGeomDB, nPartId))
|
||||
return false ;
|
||||
// log dei comandi
|
||||
LOG_INFO( m_pLogCmd, "RESET( $P1)")
|
||||
LOG_INFO( m_pLogCmd, "GR.XY( $P1, $ROOT, ORIG)")
|
||||
LOG_INFO( m_pLogCmd, ( "IMPORTDXF( " + sFilePath + ", $P1)").c_str())
|
||||
}
|
||||
// importo il file STL
|
||||
else if ( sFileExt == "STL") {
|
||||
// aggiungo un gruppo pezzo e un gruppo layer
|
||||
int nPartId = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
||||
int nLayerId = m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ;
|
||||
// preparo l'importatore
|
||||
PtrOwner<IImportStl> pImpStl( CreateImportStl()) ;
|
||||
if ( ! IsValid( pImpStl)) {
|
||||
LOG_ERROR( m_pLogGen, "Error : CreateImportStl")
|
||||
return false ;
|
||||
}
|
||||
// eseguo l'importazione
|
||||
if ( ! pImpStl->Import( sFilePath, m_pGeomDB, nLayerId))
|
||||
return false ;
|
||||
// log dei comandi
|
||||
LOG_INFO( m_pLogCmd, "RESET( ($P1, $L1))")
|
||||
LOG_INFO( m_pLogCmd, "GR.XY( $P1, $ROOT, ORIG)")
|
||||
LOG_INFO( m_pLogCmd, "GR.XY( $L1, $P1, ORIG)")
|
||||
LOG_INFO( m_pLogCmd, ( "IMPORTSTL( " + sFilePath + ", $L1)").c_str())
|
||||
}
|
||||
|
||||
// visualizzo con zoom all
|
||||
PerformanceCounter Counter ;
|
||||
Counter.Start() ;
|
||||
m_View.Zoom( IDC_ZOOM_ALL) ;
|
||||
Counter.Stop() ;
|
||||
string sOut = "First ZoomAll time = " + ToString( Counter.GetTime(), 2) + " ms" ;
|
||||
// emetto info
|
||||
::OutInfo( sOut) ;
|
||||
// aggiorno l'albero delle entità
|
||||
LoadTree() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CTestEGrDlg::FileExec( const string& sFilePath)
|
||||
@@ -1074,7 +1223,7 @@ CTestEGrDlg::LineExec( const string& sLine)
|
||||
}
|
||||
|
||||
// ripristino stato oggetto marcato
|
||||
int nIdOld = RevertOldIdOnTree() ;
|
||||
int nIdOld = RevertOldIdInTree() ;
|
||||
|
||||
// eseguo il comando
|
||||
bool bOk = m_pCmdParser->ExecLine( sLine) ;
|
||||
@@ -1092,7 +1241,7 @@ CTestEGrDlg::LineExec( const string& sLine)
|
||||
// aggiorno l'albero delle entità e tento di riselezionare l'oggetto prima marcato
|
||||
LoadTree() ;
|
||||
if ( ! m_pGeomDB->ExistsObj( nIdOld) ||
|
||||
! SelectIdOnTree( nIdOld))
|
||||
! SelectIdInTree( nIdOld))
|
||||
m_View.Redraw() ;
|
||||
|
||||
// aggiorno stato bottoni
|
||||
|
||||
+9
-4
@@ -49,6 +49,7 @@ class CTestEGrDlg : public CDialog
|
||||
afx_msg void OnFileNew( void) ;
|
||||
afx_msg void OnFileOpen( void) ;
|
||||
afx_msg void OnFileSave( void) ;
|
||||
afx_msg void OnFileImport( void) ;
|
||||
afx_msg void OnFileExec( void) ;
|
||||
afx_msg void OnShowMode( UINT nID) ;
|
||||
afx_msg void OnZoom( UINT nID) ;
|
||||
@@ -73,22 +74,26 @@ class CTestEGrDlg : public CDialog
|
||||
bool GetWindowRect( CWnd* pWnd, CRect& rect) ;
|
||||
void OutData( const std::string& sOut, bool bLog = false) ;
|
||||
// Document
|
||||
bool PrepareGeomDB( void) ;
|
||||
bool PrepareExecutor( void) ;
|
||||
bool ManageModified( void) ;
|
||||
bool FileNew( void) ;
|
||||
bool FileOpen( const std::string& sFilePath) ;
|
||||
bool FileSave( const std::string& sFilePath) ;
|
||||
bool FileImport( const std::string& sFilePath) ;
|
||||
bool FileExec( const std::string& sFilePath) ;
|
||||
void EmitTitle( void) ;
|
||||
// GeomDBTree
|
||||
bool PrepareTree( void) ;
|
||||
bool ClearTree( void) ;
|
||||
bool LoadTree( void) ;
|
||||
bool InsertGroupOnTree( int nId, HTREEITEM hParent) ;
|
||||
bool InsertGeoObjOnTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent) ;
|
||||
bool InsertCustomMaterialsInTree( void) ;
|
||||
bool InsertGroupInTree( int nId, HTREEITEM hParent) ;
|
||||
bool InsertGeoObjInTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent) ;
|
||||
int GetGeoObjImage( int nType) ;
|
||||
bool SelectIdOnTree( int nId, HTREEITEM hParent = nullptr) ;
|
||||
int RevertOldIdOnTree( void) ;
|
||||
bool SelectIdInTree( int nId, HTREEITEM hParent = nullptr) ;
|
||||
int RevertOldIdInTree( void) ;
|
||||
void OutMaterialData( int nId) ;
|
||||
void OutGroupData( int nId) ;
|
||||
void OutGeoObjData( int nId) ;
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
BIN
Binary file not shown.
Reference in New Issue
Block a user