TestEgr 1.5j1 :

- aggiornamento per selezione con mouse
- aggiornamento per distanza con punti notevoli.
This commit is contained in:
Dario Sassi
2014-10-10 06:43:42 +00:00
parent 61dea6c98e
commit 578cbb2b55
15 changed files with 470 additions and 13 deletions
+177
View File
@@ -0,0 +1,177 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : SelectionDlg.cpp Data : 08.10.14 Versione : 1.5j1
// Contenuto : Implementazione della classe gestione dialogo selezione.
//
//
//
// Modifiche : 08.10.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "TestEGrUtils.h"
#include "SelectDlg.h"
#include "resource.h"
#include "/EgtDev/Include/EgkGdbConst.h"
#include "/EgtDev/Include/EgkGeomDB.h"
#include "/EgtDev/Include/EGrScene.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EgtNumCollection.h"
using namespace std ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//----------------------------------------------------------------------------
CSelectDlg::CSelectDlg( IEGrScene* pScene) : CDialog( IDD_SELECT)
{
m_pScene = pScene ;
m_nCurrId = GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
BOOL
CSelectDlg::OnInitDialog( void)
{
CDialog::OnInitDialog() ;
if ( m_pScene == nullptr) {
EndDialog( IDCANCEL) ;
return true ;
}
IGeomDB* pGDB = m_pScene->GetGeomDB() ;
if ( pGDB == nullptr) {
EndDialog( IDCANCEL) ;
return true ;
}
CListBox* pLB = (CListBox*) GetDlgItem( IDC_LIST) ;
if ( pLB == nullptr) {
EndDialog( IDCANCEL) ;
return true ;
}
// inserisco gli oggetti selezionati
INTVECTOR nIds ;
string sOut ;
m_pScene->GetSelectedObjs( nIds) ;
for ( size_t i = 0 ; i < nIds.size() ; ++ i) {
IGeoObj* pGeo = pGDB->GetGeoObj( nIds[i]) ;
if ( pGeo == nullptr)
continue ;
bool bSel = pGDB->IsSelectedObj( nIds[i]) ;
sOut = pGeo->GetTitle() + ( bSel ? "*" : "") + " (" + ToString( nIds[i]) + ")" ;
int nPos = pLB->AddString( stringtoW( sOut)) ;
if ( nPos != LB_ERR)
pLB->SetItemData( nPos, nIds[i]) ;
}
// imposto la selezione sul primo oggetto
pLB->SetCurSel( 0) ;
OnLBSelChange() ;
return TRUE ;
}
//----------------------------------------------------------------------------
void
CSelectDlg::OnOK( void)
{
// imposto chiusura del dialogo
EndDialog( IDOK) ;
// smarco l'oggetto corrente
IGeomDB* pGDB = m_pScene->GetGeomDB() ;
if ( pGDB != nullptr) {
pGDB->ResetMark( m_nCurrId) ;
m_pScene->Draw() ;
}
}
//----------------------------------------------------------------------------
void
CSelectDlg::OnCancel( void)
{
// imposto chiusura del dialogo
EndDialog( IDCANCEL) ;
// smarco l'oggetto corrente
IGeomDB* pGDB = m_pScene->GetGeomDB() ;
if ( pGDB != nullptr) {
pGDB->ResetMark( m_nCurrId) ;
m_pScene->Draw() ;
}
// reset dell'oggetto corrente
m_nCurrId = GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( CSelectDlg, CDialog)
ON_LBN_SELCHANGE( IDC_LIST, OnLBSelChange)
ON_LBN_DBLCLK( IDC_LIST, OnLBDblClk)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
void
CSelectDlg::OnLBSelChange( void)
{
IGeomDB* pGDB = m_pScene->GetGeomDB() ;
if ( pGDB == nullptr)
return ;
CListBox* pLB = (CListBox*) GetDlgItem( IDC_LIST) ;
if ( pLB == nullptr)
return ;
// smarco l'oggetto corrente
pGDB->ResetMark( m_nCurrId) ;
// recupero l'Id del nuovo oggetto selezionato
int nSel = pLB->GetCurSel() ;
if ( nSel == LB_ERR) {
m_nCurrId = GDB_ID_NULL ;
m_pScene->Draw() ;
return ;
}
m_nCurrId = int( pLB->GetItemData( nSel)) ;
// evidenzio il nuovo oggetto selezionato
pGDB->SetMark( m_nCurrId) ;
m_pScene->Draw() ;
}
//----------------------------------------------------------------------------
void
CSelectDlg::OnLBDblClk( void)
{
// imposto chiusura del dialogo
EndDialog( IDOK) ;
IGeomDB* pGDB = m_pScene->GetGeomDB() ;
if ( pGDB == nullptr) {
m_nCurrId = GDB_ID_NULL ;
return ;
}
CListBox* pLB = (CListBox*) GetDlgItem( IDC_LIST) ;
if ( pLB == nullptr) {
m_nCurrId = GDB_ID_NULL ;
return ;
}
// smarco l'oggetto corrente
pGDB->ResetMark( m_nCurrId) ;
m_pScene->Draw() ;
// recupero l'Id del nuovo oggetto selezionato
int nSel = pLB->GetCurSel() ;
if ( nSel == LB_ERR)
m_nCurrId = GDB_ID_NULL ;
else
m_nCurrId = int( pLB->GetItemData( nSel)) ;
}
+31
View File
@@ -0,0 +1,31 @@
#pragma once
class IEGrScene ;
//----------------------------------------------------------------------------
// CSelectDlg dialog used for Select
//----------------------------------------------------------------------------
class CSelectDlg : public CDialog
{
public :
CSelectDlg( IEGrScene* pScene) ;
int GetCurrId( void)
{ return m_nCurrId ; }
protected :
virtual BOOL OnInitDialog( void) ;
virtual void OnOK( void) ;
virtual void OnCancel( void) ;
afx_msg void OnLBSelChange( void) ;
afx_msg void OnLBDblClk( void) ;
private :
IEGrScene* m_pScene ;
int m_nCurrId ;
DECLARE_MESSAGE_MAP()
} ;
BIN
View File
Binary file not shown.
+6
View File
@@ -205,11 +205,13 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="res\analyze.cur" />
<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\getdist.cur" />
<None Include="res\Group.ico" />
<None Include="res\Line.ico" />
<None Include="res\Logo.bmp" />
@@ -220,6 +222,8 @@
<None Include="res\Point.ico" />
<None Include="res\POINTER.cur" />
<None Include="res\Rotate.cur" />
<None Include="res\select.cur" />
<None Include="res\select1.cur" />
<None Include="res\STriMesh.ico" />
<None Include="res\TestEGr.ico" />
<None Include="res\TestEGr.rc2" />
@@ -236,6 +240,7 @@
<ClInclude Include="..\Include\EGkPoint3d.h" />
<ClInclude Include="..\Include\EGkVector3d.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="SelectDlg.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="TestEGr.h" />
<ClInclude Include="TestEGrCmd.h" />
@@ -245,6 +250,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="GeomDBTree.cpp" />
<ClCompile Include="SelectDlg.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+18
View File
@@ -78,6 +78,18 @@
<None Include="res\text.ico">
<Filter>File di risorse</Filter>
</None>
<None Include="res\select.cur">
<Filter>File di risorse</Filter>
</None>
<None Include="res\select1.cur">
<Filter>File di risorse</Filter>
</None>
<None Include="res\analyze.cur">
<Filter>File di risorse</Filter>
</None>
<None Include="res\getdist.cur">
<Filter>File di risorse</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TestEGr.h">
@@ -122,6 +134,9 @@
<ClInclude Include="TestEGrCmd.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="SelectDlg.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TestEGr.cpp">
@@ -145,6 +160,9 @@
<ClCompile Include="TestEGrView.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="SelectDlg.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="TestEGr.rc">
+22 -1
View File
@@ -137,6 +137,8 @@ BEGIN_MESSAGE_MAP( CTestEGrDlg, CDialog)
ON_BN_CLICKED( IDC_EXEC, OnFileExec)
ON_CONTROL_RANGE( BN_CLICKED, IDC_WIREFRAME, IDC_SHADING, OnShowMode)
ON_BN_CLICKED( IDC_SHOWCURVEDIR, OnShowCurveDir)
ON_BN_CLICKED( IDC_ANALYZE, OnAnalyze)
ON_BN_CLICKED( IDC_GETDIST, OnGetDistance)
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)
@@ -240,8 +242,11 @@ CTestEGrDlg::OnInitDialog( void)
UpdateViewButtons() ;
}
// recupero gli attributi del rettangolo per ZoomWin e li imposto
// recupero gli attributi della linea di distanza e del rettangolo per ZoomWin e li imposto
if ( m_View.GetScene() != nullptr) {
Color colDstL( 0, 0, 0) ;
GetIniColor( "Scene", "DistLine", colDstL) ;
m_View.GetScene()->SetGeoLineAttribs( colDstL) ;
bool bOutline = true ;
Color colRect( 0, 0, 0) ;
GetIniZoomWinAttrib( "Scene", "ZoomWin", bOutline, colRect) ;
@@ -477,6 +482,8 @@ CTestEGrDlg::OnSize( UINT nType, int cx, int cy)
MoveDlgItem( IDC_HIDDENLINE, IP_TR, cx, cy) ;
MoveDlgItem( IDC_SHADING, IP_TR, cx, cy) ;
MoveDlgItem( IDC_SHOWCURVEDIR, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ANALYZE, IP_TR, cx, cy) ;
MoveDlgItem( IDC_GETDIST, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ZOOM_ALL, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ZOOM_IN, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ZOOM_OUT, IP_TR, cx, cy) ;
@@ -913,6 +920,20 @@ CTestEGrDlg::OnShowCurveDir( void)
m_View.ShowCurveDir( bShow) ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnAnalyze( void)
{
m_View.SetAnalyze() ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnGetDistance( void)
{
m_View.SetGetDistance() ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::UpdateShowCurveDir( void)
+5 -1
View File
@@ -39,6 +39,8 @@ class CTestEGrDlg : public CDialog
void UpdateShowModeButtons( void) ;
void UpdateShowCurveDir( void) ;
void UpdateViewButtons( void) ;
bool SelectIdInTree( int nId)
{ return SelectIdInTree( nId, nullptr) ; }
protected :
virtual BOOL OnInitDialog( void) ;
@@ -56,6 +58,8 @@ class CTestEGrDlg : public CDialog
afx_msg void OnFileExec( void) ;
afx_msg void OnShowMode( UINT nID) ;
afx_msg void OnShowCurveDir( void) ;
afx_msg void OnAnalyze( void) ;
afx_msg void OnGetDistance( void) ;
afx_msg void OnZoom( UINT nID) ;
afx_msg void OnView( UINT nID) ;
afx_msg void OnCommand( void) ;
@@ -96,7 +100,7 @@ class CTestEGrDlg : public CDialog
bool InsertGroupInTree( int nId, HTREEITEM hParent) ;
bool InsertGeoObjInTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent) ;
int GetGeoObjImage( int nType) ;
bool SelectIdInTree( int nId, HTREEITEM hParent = nullptr) ;
bool SelectIdInTree( int nId, HTREEITEM hParent) ;
int RevertOldIdInTree( void) ;
void OutMaterialData( int nId) ;
void OutGroupData( int nId) ;
+7
View File
@@ -53,3 +53,10 @@ UpdateButtons( void)
((CTestEGrDlg*)AfxGetMainWnd())->UpdateShowCurveDir() ;
((CTestEGrDlg*)AfxGetMainWnd())->UpdateViewButtons() ;
}
//----------------------------------------------------------------------------
bool
SelectIdInGeomDbTree( int nId)
{
return ((CTestEGrDlg*)AfxGetMainWnd())->SelectIdInTree( nId) ;
}
+1
View File
@@ -20,4 +20,5 @@ void OutInfo( const std::string& sOut, bool bLog = true) ;
bool GetSceneInfo( std::string& sInfo) ;
bool LineExec( const std::string& sLine) ;
void UpdateButtons( void) ;
bool SelectIdInGeomDbTree( int nId) ;
+193 -8
View File
@@ -15,15 +15,22 @@
#include "stdafx.h"
#include "TestEGrView.h"
#include "TestEGrUtils.h"
#include "SelectDlg.h"
#include "resource.h"
#include "/EgtDev/Include/EgkGdbConst.h"
#include "/EgtDev/Include/EgkGeomDB.h"
#include "/EgtDev/Include/EgkCurve.h"
#include "/EgtDev/Include/EgkStringUtils3d.h"
#include "/EgtDev/Include/EGrScene.h"
#include "/EgtDev/Include/EgtPerfCounter.h"
#include "/EgtDev/Include/EgtILogger.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EGrScene.h"
using namespace std ;
//----------------------------------------------------------------------------
static const int DIM_SEL = 13 ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -34,10 +41,14 @@ using namespace std ;
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( TestEGrView, CWnd)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_RBUTTONUP()
ON_WM_MBUTTONDOWN()
ON_WM_MBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_MOUSEWHEEL()
ON_COMMAND_RANGE( IDM_ENDPOINT, IDM_NEARPOINT, OnSelSnapPoint)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
@@ -46,7 +57,10 @@ TestEGrView::TestEGrView( void)
m_pDC = nullptr ;
m_pScene = nullptr ;
m_nStatus = ST_NULL ;
m_nOldStatus = ST_NULL ;
m_PrevPoint.SetPoint( 0, 0) ;
m_ptPrev.Set( 0, 0, 0) ;
m_nSnapPoint = SP_END ;
}
//----------------------------------------------------------------------------
@@ -78,7 +92,7 @@ TestEGrView::Create( CWnd* pParent, int nID)
if ( CreateEx( 0, className, L"TestEGrView",
WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rectWin, pParent, nID) != 0) {
SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE) ;
SetCursor( AfxGetApp()->LoadCursor( IDC_POINTER)) ;
SetCursor( AfxGetApp()->LoadCursor( IDC_SELECT)) ;
m_pDC = new CClientDC( this) ;
m_pScene = CreateEGrScene() ;
@@ -275,19 +289,168 @@ TestEGrView::View( UINT nID)
RedrawWindow() ;
}
//----------------------------------------------------------------------------
void
TestEGrView::SetAnalyze( void)
{
m_nStatus = ST_ANALYZE ;
}
//----------------------------------------------------------------------------
void
TestEGrView::SetGetDistance( void)
{
m_pScene->ResetGeoLine() ;
m_pScene->Draw() ;
m_nStatus = ST_GETDIST ;
}
//----------------------------------------------------------------------------
void
TestEGrView::OnLButtonDown( UINT nFlags, CPoint point)
{
if ( m_nStatus == ST_NULL) {
int nSel ;
m_pScene->Select( Point3d( point.x, point.y), DIM_SEL, DIM_SEL, nSel) ;
if ( nSel == 1) {
int nId = m_pScene->GetFirstSelectedObj() ;
if ( m_pScene->GetGeomDB()->IsSelectedObj( nId))
m_pScene->GetGeomDB()->DeselectObj( nId) ;
else
m_pScene->GetGeomDB()->SelectObj( nId) ;
m_pScene->Draw() ;
}
else if ( nSel > 1) {
CSelectDlg dlgSelect( m_pScene) ;
dlgSelect.DoModal() ;
int nId = dlgSelect.GetCurrId() ;
if ( nId != GDB_ID_NULL) {
if ( m_pScene->GetGeomDB()->IsSelectedObj( nId))
m_pScene->GetGeomDB()->DeselectObj( nId) ;
else
m_pScene->GetGeomDB()->SelectObj( nId) ;
m_pScene->Draw() ;
}
}
}
else if ( m_nStatus == ST_ANALYZE) {
int nSel = 0 ;
int nId = GDB_ID_NULL ;
m_pScene->Select( Point3d( point.x, point.y), DIM_SEL, DIM_SEL, nSel) ;
if ( nSel == 1)
nId = m_pScene->GetFirstSelectedObj() ;
else if ( nSel > 1) {
CSelectDlg dlgSelect( m_pScene) ;
dlgSelect.DoModal() ;
nId = dlgSelect.GetCurrId() ;
}
if ( nId != GDB_ID_NULL)
SelectIdInGeomDbTree( nId) ;
SetCursor( AfxGetApp()->LoadCursor( IDC_SELECT)) ;
m_nStatus = ST_NULL ;
}
else if ( m_nStatus == ST_GETDIST) {
if ( m_pScene->GetSelectedSnapPoint( m_nSnapPoint, Point3d( point.x, point.y), DIM_SEL, DIM_SEL, m_ptPrev)) {
// salvo il punto di riferimento
Point3d ptWin ;
m_pScene->Project( m_ptPrev, ptWin) ;
m_PrevPoint.SetPoint( int( ptWin.x), int( ptWin.y)) ;
m_nStatus = ST_GETDIST2 ;
}
else {
SetCursor( AfxGetApp()->LoadCursor( IDC_SELECT)) ;
m_nStatus = ST_NULL ;
}
}
else if ( m_nStatus == ST_GETDIST2) {
// recupero il punto selezionato
Point3d ptSel ;
if ( m_pScene->GetSelectedSnapPoint( m_nSnapPoint, Point3d( point.x, point.y), DIM_SEL, DIM_SEL, ptSel)) {
// disegno la linea (coordinate geo globali)
m_pScene->SetGeoLine( m_ptPrev, ptSel) ;
RedrawWindow() ;
// calcolo la distanza e il delta e li visualizzo
double dDist = Dist( ptSel, m_ptPrev) ;
Vector3d vtDiff = ptSel - m_ptPrev ;
string sOut ;
sOut = "Dist=" + ToString( dDist, 4) +
" dX=" + ToString( vtDiff.x, 4) +
" dY=" + ToString( vtDiff.y, 4) +
" dZ=" + ToString( vtDiff.z, 4) ;
AfxMessageBox( stringtoW( sOut), MB_ICONINFORMATION | MB_OK) ;
}
// annullo eventuale linea di misura e lo stato
m_pScene->ResetGeoLine() ;
RedrawWindow() ;
m_nStatus = ST_NULL ;
}
}
//----------------------------------------------------------------------------
void
TestEGrView::OnLButtonUp( UINT nFlags, CPoint point)
{
;
}
//----------------------------------------------------------------------------
void
TestEGrView::OnRButtonUp( UINT nFlags, CPoint point)
{
// se utile menù punti notevoli proseguo
if ( m_nStatus != ST_GETDIST && m_nStatus != ST_GETDIST2)
return ;
// inserisco menù per punti notevoli
CMenu Menu ;
Menu.CreatePopupMenu() ;
Menu.AppendMenu( MF_STRING, IDM_ENDPOINT, L"EndPoint") ;
Menu.CheckMenuItem( IDM_ENDPOINT, MF_BYCOMMAND | ( m_nSnapPoint == SP_END ? MF_CHECKED : MF_UNCHECKED)) ;
Menu.AppendMenu( MF_STRING, IDM_MIDPOINT, L"MidPoint") ;
Menu.CheckMenuItem( IDM_MIDPOINT, MF_BYCOMMAND | ( m_nSnapPoint == SP_MID ? MF_CHECKED : MF_UNCHECKED)) ;
Menu.AppendMenu( MF_STRING, IDM_CENTERPOINT, L"CenterPoint") ;
Menu.CheckMenuItem( IDM_CENTERPOINT, MF_BYCOMMAND | ( m_nSnapPoint == SP_CENTER ? MF_CHECKED : MF_UNCHECKED)) ;
Menu.AppendMenu( MF_STRING, IDM_NEARPOINT, L"NearPoint") ;
Menu.CheckMenuItem( IDM_NEARPOINT, MF_BYCOMMAND | ( m_nSnapPoint == SP_NEAR ? MF_CHECKED : MF_UNCHECKED)) ;
ClientToScreen( &point) ;
Menu.TrackPopupMenu( TPM_LEFTALIGN, point.x, point.y, this) ;
}
//----------------------------------------------------------------------------
void
TestEGrView::OnSelSnapPoint( UINT nID)
{
switch ( nID) {
case IDM_ENDPOINT :
m_nSnapPoint = SP_END ;
break ;
case IDM_MIDPOINT :
m_nSnapPoint = SP_MID ;
break ;
case IDM_CENTERPOINT :
m_nSnapPoint = SP_CENTER ;
break ;
case IDM_NEARPOINT :
m_nSnapPoint = SP_NEAR ;
break ;
}
}
//----------------------------------------------------------------------------
void
TestEGrView::OnMButtonDown( UINT nFlags, CPoint point)
{
if ( nFlags & MK_SHIFT) {
m_nOldStatus = ( m_nStatus == ST_GETDIST2) ? ST_GETDIST2 : ST_NULL ;
m_nStatus = ST_ZOOMWIN ;
SetCursor( AfxGetApp()->LoadCursor( IDC_ZOOMWIN)) ;
}
else if ( nFlags & MK_CONTROL) {
m_nOldStatus = ( m_nStatus == ST_GETDIST2) ? ST_GETDIST2 : ST_NULL ;
m_nStatus = ST_ROT ;
SetCursor( AfxGetApp()->LoadCursor( IDC_ROTATE)) ;
}
else {
m_nOldStatus = ( m_nStatus == ST_GETDIST2) ? ST_GETDIST2 : ST_NULL ;
m_nStatus = ST_PAN ;
SetCursor( AfxGetApp()->LoadCursor( IDC_PAN)) ;
}
@@ -310,10 +473,15 @@ TestEGrView::OnMButtonUp( UINT nFlags, CPoint point)
// aggiorno il disegno
RedrawWindow() ;
}
// eventuale ripristino vecchio stato
if ( m_nOldStatus == ST_GETDIST2) {
m_nStatus = ST_GETDIST2 ;
SetCursor( AfxGetApp()->LoadCursor( IDC_GETDIST)) ;
}
// reset dello stato se non NULL
if ( m_nStatus != ST_NULL) {
else if ( m_nStatus != ST_NULL) {
m_nStatus = ST_NULL ;
SetCursor( AfxGetApp()->LoadCursor( IDC_POINTER)) ;
SetCursor( AfxGetApp()->LoadCursor( IDC_SELECT)) ;
}
}
@@ -357,9 +525,26 @@ TestEGrView::OnMouseMove( UINT nFlags, CPoint point)
// salvo il punto di riferimento
m_PrevPoint = point ;
}
// se in modalità ANALYZE
else if ( m_nStatus == ST_ANALYZE) {
SetCursor( AfxGetApp()->LoadCursor( IDC_ANALYZE)) ;
}
// se in modalità GETDIST
else if ( m_nStatus == ST_GETDIST) {
SetCursor( AfxGetApp()->LoadCursor( IDC_GETDIST)) ;
}
// se in modalità GETDIST2
else if ( m_nStatus == ST_GETDIST2) {
SetCursor( AfxGetApp()->LoadCursor( IDC_GETDIST)) ;
Point3d ptP ;
m_pScene->UnProject( Point3d( point.x, point.y, 0.5), ptP) ;
m_pScene->SetGeoLine( m_ptPrev, ptP) ;
// aggiorno il disegno
RedrawWindow() ;
}
// altrimenti reset dello stato e cursore standard
else {
SetCursor( AfxGetApp()->LoadCursor( IDC_POINTER)) ;
SetCursor( AfxGetApp()->LoadCursor( IDC_SELECT)) ;
m_nStatus = ST_NULL ;
}
}
@@ -368,8 +553,8 @@ TestEGrView::OnMouseMove( UINT nFlags, CPoint point)
BOOL
TestEGrView::OnMouseWheel( UINT nFlags, short zDelta, CPoint point)
{
// devo essere nello stato NULL
if ( m_nStatus != ST_NULL)
// devo essere nello stato NULL o GETDIST
if ( m_nStatus != ST_NULL && m_nStatus != ST_GETDIST && m_nStatus != ST_GETDIST2)
return 0 ;
// calcolo coefficiente
+10 -3
View File
@@ -6,8 +6,6 @@
#include <windows.h>
#include <string>
class IGeomDB ;
class ILogger ;
class IEGrScene ;
//----------------------------------------------------------------------------
@@ -28,11 +26,17 @@ class TestEGrView : public CWnd
void ShowCurveDir( bool bShow) ;
void Zoom( UINT nID) ;
void View( UINT nID) ;
void SetAnalyze( void) ;
void SetGetDistance( void) ;
protected :
afx_msg void OnPaint( void) ;
afx_msg BOOL OnEraseBkgnd( CDC* pDC)
{ return TRUE ; }
afx_msg void OnLButtonDown( UINT nFlags, CPoint point) ;
afx_msg void OnLButtonUp( UINT nFlags, CPoint point) ;
afx_msg void OnRButtonUp( UINT nFlags, CPoint point) ;
afx_msg void OnSelSnapPoint( UINT nID) ;
afx_msg void OnMButtonDown( UINT nFlags, CPoint point) ;
afx_msg void OnMButtonUp( UINT nFlags, CPoint point) ;
afx_msg void OnMouseMove( UINT nFlags, CPoint point) ;
@@ -47,13 +51,16 @@ class TestEGrView : public CWnd
void ShowCursorCoordinates( const Point3d& ptWin) ;
private :
enum Status { ST_NULL = 0, ST_PAN, ST_ROT, ST_ZOOMWIN} ;
enum Status { ST_NULL = 0, ST_PAN, ST_ROT, ST_ZOOMWIN, ST_ANALYZE, ST_GETDIST, ST_GETDIST2} ;
private :
CClientDC* m_pDC ;
IEGrScene* m_pScene ;
Status m_nStatus ;
Status m_nOldStatus ;
CPoint m_PrevPoint ;
Point3d m_ptPrev ;
int m_nSnapPoint ;
DECLARE_MESSAGE_MAP()
} ;
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
View File
Binary file not shown.