TestEGr 1.5b8 :

- aggiunto albero struttura progetto.
This commit is contained in:
Dario Sassi
2014-02-28 21:42:38 +00:00
parent 58dc80769d
commit f199634089
16 changed files with 395 additions and 10 deletions
+266
View File
@@ -0,0 +1,266 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : GeomDbTree.cpp Data : 29.01.14 Versione : 1.5b8
// Contenuto : Metodi del dialogo principale per albero di GeomDB.
//
//
//
// Modifiche : 27.02.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "TestEGrDlg.h"
#include "resource.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkCurveLine.h"
using namespace std ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//--------------------------- 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} ;
//----------------------------------------------------------------------------
bool
CTestEGrDlg::PrepareTree( void)
{
// collego l'oggetto al control
m_Tree.SubclassDlgItem( IDC_TREE, this) ;
// carico le immagini
m_pImgList = new CImageList ;
if ( m_pImgList == nullptr)
return false ;
m_pImgList->Create( 16, 16, ILC_COLOR, 10, 4) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_NOGEO)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_GROUP)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_VECTOR)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_POINT)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_FRAME)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_LINE)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_ARC)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_CBEZIER)) ;
m_pImgList->Add( AfxGetApp()->LoadIcon( IDI_CCOMPO)) ;
m_Tree.SetImageList( m_pImgList, TVSIL_NORMAL) ;
return true ;
}
//----------------------------------------------------------------------------
bool
CTestEGrDlg::LoadTree( void)
{
// svuoto l'albero
m_Tree.DeleteAllItems() ;
OutData( "") ;
// disabilito aggiornamento
m_Tree.SetRedraw( FALSE) ;
// ciclo su GeomDB
InsertGroupOnTree( GDB_ID_ROOT, TVI_ROOT) ;
// riabilito aggiornamento
m_Tree.SetRedraw( TRUE) ;
m_Tree.Invalidate() ;
return true ;
}
//----------------------------------------------------------------------------
bool
CTestEGrDlg::InsertGroupOnTree( int nId, HTREEITEM hParent)
{
// inserisco il gruppo nell'albero (se non è la radice)
HTREEITEM hGroup ;
if ( nId == GDB_ID_ROOT)
hGroup = hParent ;
else {
string sGroup = "Group " + ToString( nId) ;
hGroup = m_Tree.InsertItem( stringtoW( sGroup), ICO_GROUP, ICO_GROUP, hParent) ;
if ( hGroup == nullptr || m_Tree.SetItemData( hGroup, nId) == 0)
return false ;
}
// creo un iteratore
PtrOwner<IGdbIterator> pIter( CreateGdbIterator()) ;
if ( ! ::IsValid( pIter))
return false ;
// scandisco il gruppo
pIter->SetGDB( m_pGeomDB) ;
bool bNext = pIter->GoToFirstInGroup( nId) ;
while ( bNext) {
// leggo il tipo di nodo
int nGdbType = pIter->GetGdbType() ;
// se gruppo
if ( nGdbType == GDB_GROUP) {
// lo inserisco nell'albero
if ( ! InsertGroupOnTree( pIter->GetId(), hGroup))
return false ;
}
// se oggetto geometrico
else if ( nGdbType == GDB_GEO) {
// lo inserisco nell'albero
if ( ! InsertGeoObjOnTree( pIter->GetId(), pIter->GetGeoObj(), hGroup))
return false ;
}
// passo al successivo
bNext = pIter->GoToNext() ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
CTestEGrDlg::InsertGeoObjOnTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent)
{
int nImage ;
string sName ;
if ( pGeoObj != nullptr) {
sName = pGeoObj->GetTitle() + " " + ToString( nId) ;
nImage = GetGeoObjImage( pGeoObj->GetType()) ;
}
else {
nImage = ICO_NOGEO ;
sName = "Null " + ToString( nId) ;
}
HTREEITEM hItem = m_Tree.InsertItem( stringtoW( sName), nImage, nImage, hParent) ;
return ( hItem != nullptr && m_Tree.SetItemData( hItem, nId) != 0) ;
}
//----------------------------------------------------------------------------
int
CTestEGrDlg::GetGeoObjImage( int nType)
{
switch ( nType) {
case GEO_VECT3D : return ICO_VECTOR ;
case GEO_PNT3D : return ICO_POINT ;
case GEO_FRAME3D : return ICO_FRAME ;
case CRV_LINE : return ICO_LINE ;
case CRV_ARC : return ICO_ARC ;
case CRV_BEZ : return ICO_CBEZIER ;
case CRV_COMPO : return ICO_CCOMPO ;
}
return ICO_NOGEO ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnTreeSelChanged( NMHDR* pNMHDR, LRESULT* pResult)
{
// assegno il risultato
*pResult = 0 ;
// recupero l'Id dell'oggetto selezionato
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>( pNMHDR) ;
HTREEITEM hItem = pNMTreeView->itemNew.hItem ;
int nId = GDB_ID_NULL ;
if ( hItem != nullptr)
nId = int( m_Tree.GetItemData( hItem)) ;
// in base al tipo di nodo
switch ( m_pGeomDB->GetGdbType( nId)) {
case GDB_GROUP :
OutGroupData( nId) ;
break ;
case GDB_GEO :
OutGeoObjData( nId) ;
break ;
}
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OutGroupData( int nId)
{
string sOut = "Group " + ToString( nId) + "\r\n" ;
// numero di nodi (figli)
int nNodes = m_pGeomDB->GetGroupNodes( nId) ;
sOut += "Nodes : " + ToString( nNodes) + "\r\n" ;
// riferimento in globale
Frame3d frGlob ;
if ( m_pGeomDB->GetGroupGlobFrame( nId, frGlob)) {
sOut += "GlobFrame :\r\n" ;
sOut += " O(" + ToString( frGlob.Orig()) + ")\r\n" ;
sOut += " X(" + ToString( frGlob.VersX()) + ")\r\n" ;
sOut += " Y(" + ToString( frGlob.VersY()) + ")\r\n" ;
sOut += " Z(" + ToString( frGlob.VersZ()) + ")\r\n" ;
}
// ingombro in globale
BBox3d b3Glob ;
if ( m_pGeomDB->GetGlobalBBox( nId, b3Glob)) {
sOut += "GlobBBox :\r\n" ;
sOut += " m(" + ToString( b3Glob.GetMin()) + ")\r\n" ;
sOut += " M(" + ToString( b3Glob.GetMax()) + ")\r\n" ;
}
OutData( sOut) ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OutGeoObjData( int nId)
{
// recupero l'oggetto geometrico
const IGeoObj* pGObj ;
if ( ( pGObj = m_pGeomDB->GetGeoObj( nId)) == nullptr)
return ;
string sOut ;
// preparo l'intestazione
sOut += pGObj->GetTitle() + " " + ToString( nId) + "\r\n" ;
//DumpCaptionData( pGObj->GetType(), nId, sOut) ;
// preparo i dati
pGObj->Dump( sOut, "\r\n") ;
// emissione
OutData( sOut) ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::DumpCaptionData( int nType, int nId, string& sOut)
{
// a seconda del tipo
switch ( nType) {
case GEO_VECT3D :
sOut += "Vector " ;
break ;
case GEO_PNT3D :
sOut += "Point " ;
break ;
case GEO_FRAME3D :
sOut += "Frame " ;
break ;
case CRV_LINE :
sOut += "Line " ;
break ;
case CRV_ARC :
sOut += "Arc " ;
break ;
case CRV_BEZ :
sOut += "CBezier " ;
break ;
case CRV_COMPO :
sOut += "CComposite " ;
break ;
default :
sOut += "NULL " ;
break ;
}
sOut += ToString( nId) + "\r\n" ;
}
BIN
View File
Binary file not shown.
+13
View File
@@ -197,18 +197,30 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="res\Arc.ico" />
<None Include="res\CBezier.ico" />
<None Include="res\CCompo.ico" />
<None Include="res\Error.ico" />
<None Include="res\Frame.ico" />
<None Include="res\Group.ico" />
<None Include="res\Line.ico" />
<None Include="res\Logo.bmp" />
<None Include="res\NoGeo.ico" />
<None Include="res\pan.cur" />
<None Include="res\Point.ico" />
<None Include="res\POINTER.cur" />
<None Include="res\Rotate.cur" />
<None Include="res\TestEGr.ico" />
<None Include="res\TestEGr.rc2" />
<None Include="res\Vector.ico" />
<None Include="res\zoomwin.cur" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Include\EGkBBox3d.h" />
<ClInclude Include="..\Include\EGkFrame3d.h" />
<ClInclude Include="..\Include\EGkGeoConst.h" />
<ClInclude Include="..\Include\EGkGeomDB.h" />
<ClInclude Include="..\Include\EGkGeoObj.h" />
<ClInclude Include="..\Include\EGkPoint3d.h" />
<ClInclude Include="..\Include\EGkVector3d.h" />
<ClInclude Include="Resource.h" />
@@ -219,6 +231,7 @@
<ClInclude Include="TestEGrView.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="GeomDBTree.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+39
View File
@@ -36,6 +36,36 @@
<None Include="res\zoomwin.cur">
<Filter>File di risorse</Filter>
</None>
<None Include="res\Group.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\Line.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\Arc.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\CBezier.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\CCompo.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\Point.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\Vector.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\Frame.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\Error.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\NoGeo.ico">
<Filter>File di risorse</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TestEGr.h">
@@ -71,6 +101,12 @@
<ClInclude Include="TestEGrUtils.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkGeomDB.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkGeoObj.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TestEGr.cpp">
@@ -88,6 +124,9 @@
<ClCompile Include="TestEGrUtils.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="GeomDBTree.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="TestEGr.rc">
+60 -7
View File
@@ -21,8 +21,7 @@
#include "/EgtDev/Include/EgtILogger.h"
#include "/EgtDev/Include/EgtPerfCounter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EgnCmdParser.h"
#include "/EgtDev/Include/EGkDllMain.h"
#include "/EgtDev/Include/EGnCmdParser.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkGdbExecutor.h"
#include "/EgtDev/Include/EGrScene.h"
@@ -85,14 +84,22 @@ CTestEGrDlg::CTestEGrDlg( ILogger* pLogger, CWnd* pParent)
m_hIcon = AfxGetApp()->LoadIcon( IDR_MAINFRAME) ;
// memorizzo il puntatore al logger
m_pLogger = pLogger ;
// inizializzazioni varie
m_pGeomDB = nullptr ;
m_pImgList = nullptr ;
}
//----------------------------------------------------------------------------
CTestEGrDlg::~CTestEGrDlg( void)
{
// cancello GeomDB
if ( m_pGeomDB != nullptr)
delete m_pGeomDB ;
m_pGeomDB = nullptr ;
// cancello ImgList
if ( m_pImgList != nullptr)
delete m_pImgList ;
m_pImgList = nullptr ;
}
//----------------------------------------------------------------------------
@@ -108,6 +115,7 @@ BEGIN_MESSAGE_MAP( CTestEGrDlg, CDialog)
ON_CONTROL_RANGE( BN_CLICKED, IDC_ZOOM_ALL, IDC_ZOOM_OUT, OnZoom)
ON_CONTROL_RANGE( BN_CLICKED, IDC_VIEW_TOP, IDC_VIEW_ISO, OnView)
ON_BN_CLICKED( IDC_CLOSE, OnClose)
ON_NOTIFY( TVN_SELCHANGED, IDC_TREE, OnTreeSelChanged)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
@@ -149,7 +157,8 @@ CTestEGrDlg::OnInitDialog( void)
CRect rectView ;
GetDlgItem( IDC_SCENE)->GetWindowRect( rectView) ;
ScreenToClient( &rectView) ;
m_nSideBarW = rectClient.right - rectView.right ;
m_nLeftBarW = rectView.left - rectClient.left ;
m_nRightBarW = rectClient.right - rectView.right ;
m_nBottomBarH = rectClient.bottom - rectView.bottom ;
// creo il DB geometrico
@@ -204,6 +213,9 @@ CTestEGrDlg::OnInitDialog( void)
if ( GetIniWinPlace( "General", "WinPlace", winPlace))
SetWindowPlacement( &winPlace) ;
// preparo il Tree
PrepareTree() ;
return TRUE ; // return TRUE unless you set the focus to a control
}
@@ -358,12 +370,22 @@ CTestEGrDlg::OnSize( UINT nType, int cx, int cy)
MoveDlgItem( IDC_VIEW_LEFT, IP_TR, cx, cy) ;
MoveDlgItem( IDC_VIEW_RIGHT, IP_TR, cx, cy) ;
MoveDlgItem( IDC_VIEW_ISO, IP_TR, cx, cy) ;
MoveDlgItem( IDC_CLOSE, IP_TR, cx, cy) ;
MoveDlgItem( IDC_CLOSE, IP_BR, cx, cy) ;
// spostamento e adattamento tree e associati
MoveDlgItem( IDC_TREE, IP_TL, cx, cy) ;
MoveDlgItem( IDC_DATA, IP_TL, cx, cy) ;
CRect rectData ;
if ( GetWindowRect( GetDlgItem( IDC_DATA), rectData))
ReshapeDlgItem( IDC_DATA, IR_H, 0, cy - rectData.top - m_nBottomBarH) ;
// spostamento e adattamento barre sotto
MoveDlgItem( IDC_INFO, IP_BL, cx, cy) ;
ReshapeDlgItem( IDC_INFO, IR_W, cx - m_nSideBarW, 0) ;
ReshapeDlgItem( IDC_INFO, IR_W, cx - m_nLeftBarW - m_nRightBarW, 0) ;
MoveDlgItem( IDC_COORD, IP_BR, cx, cy) ;
// adattamento finestra
m_View.Reshape( 0, 0, cx - m_nSideBarW, cy - m_nBottomBarH) ;
// adattamento vista della scena
CRect rectView ;
if ( GetWindowRect( &m_View, rectView))
m_View.Reshape( m_nLeftBarW, rectView.top,
cx - m_nLeftBarW - m_nRightBarW, cy - m_nBottomBarH - rectView.top) ;
// salvo la nuova dimensione
m_nPrevCx = cx ;
m_nPrevCy = cy ;
@@ -440,6 +462,18 @@ CTestEGrDlg::ReshapeDlgItem( int nID, int nFlag, int nW, int nH)
return ( pBtn->SetWindowPos( NULL, 0, 0, nWu, nHu, SWP_NOMOVE | SWP_NOZORDER) != 0) ;
}
//----------------------------------------------------------------------------
bool
CTestEGrDlg::GetWindowRect( CWnd* pWnd, CRect& rect)
{
if ( pWnd == nullptr || ! ::IsWindow( pWnd->m_hWnd))
return false ;
pWnd->GetWindowRect( rect) ;
ScreenToClient( &rect) ;
return true ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OutInfo( const string& sOut, bool bLog)
@@ -452,6 +486,18 @@ CTestEGrDlg::OutInfo( const string& sOut, bool bLog)
LOG_INFO( m_pLogger, sOut.c_str())
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OutData( const string& sOut, bool bLog)
{
CWnd* pWnd = GetDlgItem( IDC_DATA) ;
if ( pWnd != nullptr)
pWnd->SetWindowText( stringtoW( sOut)) ;
if ( bLog)
LOG_INFO( m_pLogger, sOut.c_str())
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnClose( void)
@@ -482,6 +528,8 @@ CTestEGrDlg::OnFileNew( void)
m_pGeomDB->Init() ;
// visualizzo con zoom all
m_View.Zoom( IDC_ZOOM_ALL) ;
// aggiorno l'albero delle entità
LoadTree() ;
}
//----------------------------------------------------------------------------
@@ -537,6 +585,8 @@ CTestEGrDlg::OnFileOpen( void)
string sOut = "First ZoomAll time = " + ToString( Counter.GetTime(), 2) + " ms" ;
// emetto info
::OutInfo( sOut) ;
// aggiorno l'albero delle entità
LoadTree() ;
}
//----------------------------------------------------------------------------
@@ -602,6 +652,9 @@ CTestEGrDlg::OnFileExec( void)
AfxMessageBox( L"Error on Parser.Run (look at Log file)", MB_ICONSTOP|MB_OK) ;
return ;
}
// aggiorno l'albero delle entità
LoadTree() ;
}
//----------------------------------------------------------------------------
+17 -3
View File
@@ -16,9 +16,9 @@
#include "TestEgrView.h"
#include "/EgtDev/Include/EGkColor.h"
class ILogger ;
class IGeomDB ;
class IGeoObj ;
//----------------------------------------------------------------------------
class CTestEGrDlg : public CDialog
@@ -43,6 +43,7 @@ class CTestEGrDlg : public CDialog
afx_msg void OnZoom( UINT nID) ;
afx_msg void OnView( UINT nID) ;
afx_msg void OnClose( void) ;
afx_msg void OnTreeSelChanged(NMHDR *pNMHDR, LRESULT *pResult) ;
private :
enum ItemPos { IP_TR = 1, IP_TL, IP_BR, IP_BL} ;
@@ -52,18 +53,31 @@ class CTestEGrDlg : public CDialog
bool GetIniBackColor( const char* szSection, const char* szKey, Color& colBack) ;
bool GetIniZoomWinAttrib( const char* szSection, const char* szKey,
bool& bOutline, Color& colRect) ;
bool GetIniWinPlace( const char* szSection, const char* szKey, WINDOWPLACEMENT& winPlace) ;
bool GetIniWinPlace( const char* szSection, const char* szKey, WINDOWPLACEMENT& winPlace) ;
bool MoveDlgItem( int nID, int nPos, int cx, int cy) ;
bool ReshapeDlgItem( int nID, int nFlag, int nW, int nH) ;
bool GetWindowRect( CWnd* pWnd, CRect& rect) ;
void OutData( const std::string& sOut, bool bLog = false) ;
bool PrepareTree( void) ;
bool LoadTree( void) ;
bool InsertGroupOnTree( int nId, HTREEITEM hParent) ;
bool InsertGeoObjOnTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent) ;
int GetGeoObjImage( int nType) ;
void OutGroupData( int nId) ;
void OutGeoObjData( int nId) ;
void DumpCaptionData( int nType, int nId, std::string& sOut) ;
private :
IGeomDB* m_pGeomDB ;
ILogger* m_pLogger ;
TestEgrView m_View ;
HICON m_hIcon ;
CTreeCtrl m_Tree ;
CImageList* m_pImgList ;
int m_nPrevCx ;
int m_nPrevCy ;
int m_nSideBarW ;
int m_nLeftBarW ;
int m_nRightBarW ;
int m_nBottomBarH ;
DECLARE_MESSAGE_MAP()
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
View File
Binary file not shown.