EgtGraphics 1.5l1 :
- aggiornamento a VS2013 - curve marcate ora hanno spessore 2 e evidenziate 4. - gestione riferimento griglia (CPlane) spostata in EgtGeomKernel - aggiunta possibilità di visualizzare piccolo riferimento globale in basso a sinistra. - migliorato snap a intersezione di curve.
This commit is contained in:
Binary file not shown.
+8
-3
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@@ -28,23 +28,27 @@
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -154,7 +158,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
|
||||
<DisableSpecificWarnings>
|
||||
</DisableSpecificWarnings>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -186,7 +190,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
|
||||
<DisableSpecificWarnings>
|
||||
</DisableSpecificWarnings>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -232,6 +236,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="SceneCamera.cpp" />
|
||||
<ClCompile Include="SceneGeom.cpp" />
|
||||
<ClCompile Include="SceneDirect.cpp" />
|
||||
<ClCompile Include="SceneGlobFrame.cpp" />
|
||||
<ClCompile Include="SceneGrid.cpp" />
|
||||
<ClCompile Include="SceneSelect.cpp" />
|
||||
<ClCompile Include="SceneSnap.cpp" />
|
||||
|
||||
@@ -110,6 +110,9 @@
|
||||
<ClCompile Include="SceneSelect.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SceneGlobFrame.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGraphics.rc">
|
||||
|
||||
+2
-2
@@ -287,7 +287,7 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
return true ;
|
||||
if ( nStat == GDB_ST_SEL) {
|
||||
glPointSize( 5) ;
|
||||
glLineWidth( 3) ;
|
||||
glLineWidth( 2) ;
|
||||
}
|
||||
|
||||
// colori speciali per superficie shading selezionata o marcata
|
||||
@@ -357,7 +357,7 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
|
||||
// dimensioni per halo
|
||||
glPointSize( 7) ;
|
||||
glLineWidth( 5) ;
|
||||
glLineWidth( 4) ;
|
||||
|
||||
// colore di marcatura
|
||||
Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 192, 192, 0)) ;
|
||||
|
||||
+2
-2
@@ -189,7 +189,7 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
return true ;
|
||||
if ( nStat == GDB_ST_SEL) {
|
||||
glPointSize( 5) ;
|
||||
glLineWidth( 3) ;
|
||||
glLineWidth( 2) ;
|
||||
}
|
||||
|
||||
// colore speciale per superficie shading selezionata o marcata
|
||||
@@ -268,7 +268,7 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bShowAux)
|
||||
|
||||
// dimensioni per halo
|
||||
glPointSize( 7) ;
|
||||
glLineWidth( 5) ;
|
||||
glLineWidth( 4) ;
|
||||
|
||||
// colore di marcatura
|
||||
Color colMark = ( ( GetScene() != nullptr) ? GetScene()->GetMark() : Color( 192, 192, 0)) ;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
#include "/EgtDev/Include/EGrScene.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "OpenGL.h"
|
||||
|
||||
class IGdbIterator ;
|
||||
@@ -110,11 +110,10 @@ class Scene : public IEGrScene
|
||||
virtual bool SetSelSurf( Color colSelSurf) ;
|
||||
// Grid
|
||||
virtual bool SetGridShow( bool bShowGrid, bool bShowFrame) ;
|
||||
virtual bool SetGridFrame( const Frame3d& frFrame) ;
|
||||
virtual bool SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) ;
|
||||
virtual bool SetGridColor( Color colMinLine, Color colMajLine) ;
|
||||
virtual const Frame3d& GetGridFrame( void)
|
||||
{ return m_frGrid ; }
|
||||
// Glob Frame
|
||||
virtual bool SetGlobFrameShow( bool bShow) ;
|
||||
// Direct
|
||||
virtual bool SetGeoLineAttribs( Color GLcol) ;
|
||||
virtual bool SetGeoLine( const Point3d& ptP1, const Point3d& ptP2) ;
|
||||
@@ -166,7 +165,14 @@ class Scene : public IEGrScene
|
||||
bool DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj) ;
|
||||
bool DeleteObjGraphicsGroup( int nId) ;
|
||||
// Grid
|
||||
const Frame3d& GetGridFrame( void)
|
||||
{ if ( m_pGeomDB != nullptr)
|
||||
return m_pGeomDB->GetGridFrame() ;
|
||||
static Frame3d frGrid ;
|
||||
return frGrid ; }
|
||||
bool DrawGrid( void) ;
|
||||
// Glob Frame
|
||||
bool DrawGlobFrame( void) ;
|
||||
// Direct
|
||||
bool DrawDirect( void) ;
|
||||
bool DrawGeoLine( void) ;
|
||||
@@ -180,12 +186,13 @@ class Scene : public IEGrScene
|
||||
bool GetSelectedIntersectionPoint( const Point3d& ptWin, int nW, int nH, Point3d& ptSel) ;
|
||||
|
||||
private :
|
||||
// Basic
|
||||
HDC m_hDC ; // Device Context
|
||||
HGLRC m_hRC ; // OpenGL Rendering Context
|
||||
WGLEWContext m_wglewc ; // WGLEW Context
|
||||
GLEWContext m_glewc ; // GLEW Context
|
||||
bool m_bNewWay ; // flag che indica nuova modalità (OpenGL 3.0 in poi)
|
||||
|
||||
// Camera
|
||||
Point3d m_ptCenter ; // centro verso cui è rivolta la camera
|
||||
Vector3d m_vtDirCamera ; // versore direzione dal centro alla camera
|
||||
double m_dDistCamera ; // distanza dal centro alla camera
|
||||
@@ -193,13 +200,13 @@ class Scene : public IEGrScene
|
||||
bool m_bUpOk ; // flag per stato aggiornamento di Up
|
||||
int m_nViewportW ; // larghezza della finestra
|
||||
int m_nViewportH ; // altezza della finestra
|
||||
|
||||
// Background
|
||||
Color m_colBackTop ; // colore di sfondo in alto
|
||||
Color m_colBackBottom ; // colore di sfondo in basso
|
||||
|
||||
// ShowMode
|
||||
int m_nShowMode ; // modo di visualizzazione (wireframe, hiddenline, shading)
|
||||
bool m_bShowCurveDirection ; // flag di visualizzazione direzione curve
|
||||
|
||||
// Selection
|
||||
bool m_bSelect ; // flag di selezione attiva
|
||||
INTVECTOR m_Unsel ; // vettore indici oggetti non selezionabili
|
||||
Point3d m_ptSelCent ; // centro di selezione
|
||||
@@ -209,34 +216,35 @@ class Scene : public IEGrScene
|
||||
int m_nSelCurr ; // indice oggetto selezionato corrente
|
||||
static const int DIM_SEL_BUF = 32768 ;
|
||||
SelRec m_nSelBuff[DIM_SEL_BUF] ; // buffer per selezione con OpenGL
|
||||
|
||||
// Snap
|
||||
int m_nLastSnapId ; // Id dell'entità generatrice dell'ultimo punto snap
|
||||
bool m_bLastSnapDirOk ; // flag validità direzione associata a ultimo punto snap
|
||||
Vector3d m_vtLastSnapDir ; // direzione associata a ultimo punto snap
|
||||
|
||||
// Geometry
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||
Color m_colDef ; // colore di default
|
||||
Color m_colMark ; // colore per marcatura
|
||||
Color m_colSelSurf ; // colore di superficie selezionata
|
||||
|
||||
BBox3d m_b3ExtWorld ; // estensione della geometria nel riferimento globale (mondo)
|
||||
BBox3d m_b3ExtView ; // estensione nel riferimento di vista
|
||||
bool m_bExtViewOk ; // flag per stato aggiornamento di EView
|
||||
double m_dHalfWidth ; // semialtezza della vista
|
||||
double m_dHalfHeight ; // semilarghezza della vista
|
||||
double m_dZNear ; // distanza del piano di clipping vicino
|
||||
double m_dZFar ; // distanza del piano di clipping lontano
|
||||
|
||||
// Extension
|
||||
BBox3d m_b3ExtWorld ; // estensione della geometria nel riferimento globale (mondo)
|
||||
BBox3d m_b3ExtView ; // estensione nel riferimento di vista
|
||||
bool m_bExtViewOk ; // flag per stato aggiornamento di EView
|
||||
double m_dHalfWidth ; // semialtezza della vista
|
||||
double m_dHalfHeight ; // semilarghezza della vista
|
||||
double m_dZNear ; // distanza del piano di clipping vicino
|
||||
double m_dZFar ; // distanza del piano di clipping lontano
|
||||
// Grid
|
||||
bool m_bShowGrid ; // flag di visualizzazione della griglia
|
||||
bool m_bShowFrame ; // flag di visualizzazione del frame della griglia
|
||||
Frame3d m_frGrid ; // riferimento della griglia
|
||||
double m_dSnapStep ; // passo di snap
|
||||
int m_nMinLineSstep ; // interasse tra due linee minori come numero di passi di snap
|
||||
int m_nMajLineSstep ; // interasse tra due linee maggiori come numero di passi di snap
|
||||
int m_nExtSstep ; // estensione della griglia come numero di passi di snap
|
||||
Color m_colMinLine ; // colore delle linee minori
|
||||
Color m_colMajLine ; // colore delle linee maggiori
|
||||
|
||||
// Glob Frame
|
||||
bool m_bShowGlobFrame ; // flag di visualizzazione del riferimento globale
|
||||
// Direct
|
||||
Color m_colorGL ; // colore per GeoLine
|
||||
bool m_bGeoLine ; // flag esistenza linea diretta in finestra
|
||||
Point3d m_ptGeoLineP1 ; // primo estremo della linea diretta
|
||||
|
||||
+10
-4
@@ -74,13 +74,14 @@ Scene::Scene( void)
|
||||
// Grid
|
||||
m_bShowGrid = false ;
|
||||
m_bShowFrame = false ;
|
||||
m_frGrid = GLOB_FRM ;
|
||||
m_dSnapStep = 1 ;
|
||||
m_nMinLineSstep = 10 ;
|
||||
m_nMajLineSstep = 100 ;
|
||||
m_nExtSstep = 500 ;
|
||||
m_colMinLine.Set( 160, 160, 160) ;
|
||||
m_colMajLine.Set( 160, 160, 160) ;
|
||||
m_colMajLine.Set( 160, 160, 160) ;
|
||||
// Global Frame
|
||||
m_bShowGlobFrame = false ;
|
||||
// Direct
|
||||
m_colorGL.Set( 255, 0, 0) ;
|
||||
m_bGeoLine = false ;
|
||||
@@ -663,7 +664,7 @@ Scene::Draw( void)
|
||||
glDepthFunc( GL_LEQUAL) ;
|
||||
glEnable( GL_DEPTH_TEST) ;
|
||||
|
||||
// disegno griglia
|
||||
// disegno griglia senza illuminazione
|
||||
glDisable( GL_LIGHTING) ;
|
||||
DrawGrid() ;
|
||||
|
||||
@@ -735,9 +736,14 @@ Scene::Draw( void)
|
||||
break ;
|
||||
}
|
||||
|
||||
// aggiungo disegni diretti (senza test Zbuffer e con poligoni riempiti)
|
||||
// disabilito uso Zbuffer e illuminazione
|
||||
glDisable( GL_DEPTH_TEST) ;
|
||||
glDisable( GL_LIGHTING) ;
|
||||
|
||||
// disegno riferimento globale
|
||||
DrawGlobFrame() ;
|
||||
|
||||
// aggiungo disegni diretti (con poligoni riempiti)
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL) ;
|
||||
DrawDirect() ;
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ Scene::SetCamera( int nDir, double dDist)
|
||||
case CT_ISO_NW :
|
||||
m_vtDirCamera.Set( - SQRT1_3, SQRT1_3, SQRT1_3) ;
|
||||
break ;
|
||||
case CT_CPLANE :
|
||||
m_vtDirCamera = GetGridFrame().VersZ() ;
|
||||
break ;
|
||||
default :
|
||||
return false ;
|
||||
break ;
|
||||
|
||||
+38
-16
@@ -34,8 +34,8 @@ using namespace std ;
|
||||
|
||||
//------------------------------ Local functions -----------------------------
|
||||
static ObjEGrGraphics* CreateObjEGrGraphics( bool bNewWay) ;
|
||||
static bool CalcCurveTailMark( const PolyLine& plCrv, PolyLine& plMark) ;
|
||||
static bool CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr) ;
|
||||
static bool CalcCurveTailMark( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plMark) ;
|
||||
static bool CalcCurveTipArrow( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plArr) ;
|
||||
static bool CalcConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -239,11 +239,14 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, MdStMk siObj)
|
||||
pGraphics->AddColor( cCol) ;
|
||||
pGraphics->AddPolyLine( PL) ;
|
||||
// eventuali segni ausiliari (mark, frecce, ...)
|
||||
Vector3d vtRef ;
|
||||
if ( ! pCurve->GetExtrusion( vtRef) || vtRef.IsSmall())
|
||||
vtRef = Z_AX ;
|
||||
PolyLine PLM ;
|
||||
if ( CalcCurveTailMark( PL, PLM))
|
||||
if ( CalcCurveTailMark( vtRef, PL, PLM))
|
||||
pGraphics->AddPolyLine( PLM, true) ;
|
||||
PolyLine PLA ;
|
||||
if ( CalcCurveTipArrow( PL, PLA))
|
||||
if ( CalcCurveTipArrow( vtRef, PL, PLA))
|
||||
pGraphics->AddPolyLine( PLA, true) ;
|
||||
// eventuale spessore
|
||||
double dTh ;
|
||||
@@ -387,7 +390,7 @@ CreateObjEGrGraphics( bool bNewWay)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcCurveTailMark( const PolyLine& plCrv, PolyLine& plMark)
|
||||
CalcCurveTailMark( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plMark)
|
||||
{
|
||||
// pulisco la polilinea per il segno
|
||||
plMark.Clear() ;
|
||||
@@ -429,19 +432,37 @@ CalcCurveTailMark( const PolyLine& plCrv, PolyLine& plMark)
|
||||
dLenTr = MIN_LEN_TR ;
|
||||
// disegno traverso
|
||||
Frame3d frF ;
|
||||
frF.Set( ptTail, vtDir) ;
|
||||
Point3d ptP1 = ORIG + Vector3d( 0.5 * dLenTr, 0, 0) ;
|
||||
ptP1.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 0, ptP1) ;
|
||||
Point3d ptP2 = ORIG - Vector3d( 0.5 * dLenTr, 0, 0) ;
|
||||
ptP2.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 1, ptP2) ;
|
||||
if ( frF.Set( ptTail, vtDir, vtRef)) {
|
||||
Point3d ptP0 = ORIG + Vector3d( 0, 0.5 * dLenTr, 0) ;
|
||||
ptP0.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 0, ptP0) ;
|
||||
Point3d ptP1 = ORIG + Vector3d( 0, - 0.5 * dLenTr, 0) ;
|
||||
ptP1.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 1, ptP1) ;
|
||||
}
|
||||
else {
|
||||
frF.Set( ptTail, vtDir) ;
|
||||
Point3d ptP0 = ORIG + Vector3d( - 0.5 * dLenTr, - 0.5 * dLenTr, 0) ;
|
||||
ptP0.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 0, ptP0) ;
|
||||
Point3d ptP1 = ORIG + Vector3d( 0.5 * dLenTr, - 0.5 * dLenTr, 0) ;
|
||||
ptP1.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 1, ptP1) ;
|
||||
Point3d ptP2 = ORIG + Vector3d( 0.5 * dLenTr, 0.5 * dLenTr, 0) ;
|
||||
ptP2.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 2, ptP2) ;
|
||||
Point3d ptP3 = ORIG + Vector3d( - 0.5 * dLenTr, 0.5 * dLenTr, 0) ;
|
||||
ptP3.ToGlob( frF) ;
|
||||
plMark.AddUPoint( 3, ptP3) ;
|
||||
// punto di chiusura coincidente con il primo
|
||||
plMark.AddUPoint( 4, ptP0) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr)
|
||||
CalcCurveTipArrow( const Vector3d& vtRef, const PolyLine& plCrv, PolyLine& plArr)
|
||||
{
|
||||
// pulisco la polilinea per la freccia
|
||||
plArr.Clear() ;
|
||||
@@ -488,12 +509,13 @@ CalcCurveTipArrow( const PolyLine& plCrv, PolyLine& plArr)
|
||||
// disegno freccia
|
||||
const double A_WIDTH_COEFF = 0.3 ;
|
||||
Frame3d frF ;
|
||||
frF.Set( ptTip, vtDir) ;
|
||||
if ( ! frF.Set( ptTip, vtDir, vtRef))
|
||||
frF.Set( ptTip, vtDir) ;
|
||||
plArr.AddUPoint( 0, ptTip) ;
|
||||
Point3d ptP1 = ORIG + Vector3d( A_WIDTH_COEFF, 0, -1) * dLenArr ;
|
||||
Point3d ptP1 = ORIG + Vector3d( 0, A_WIDTH_COEFF, -1) * dLenArr ;
|
||||
ptP1.ToGlob( frF) ;
|
||||
plArr.AddUPoint( 1, ptP1) ;
|
||||
Point3d ptP2 = ORIG + Vector3d( -A_WIDTH_COEFF, 0, -1) * dLenArr ;
|
||||
Point3d ptP2 = ORIG + Vector3d( 0, - A_WIDTH_COEFF, -1) * dLenArr ;
|
||||
ptP2.ToGlob( frF) ;
|
||||
plArr.AddUPoint( 2, ptP2) ;
|
||||
plArr.AddUPoint( 3, ptTip) ;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SceneGlobFrame.cpp Data : 02.12.14 Versione : 1.5l1
|
||||
// Contenuto : Implementazione gestione e disegno terna di riferimento globale.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 02.12.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "Scene.h"
|
||||
#include "EGrUtils.h"
|
||||
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::SetGlobFrameShow( bool bShow)
|
||||
{
|
||||
m_bShowGlobFrame = bShow ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGlobFrame( void)
|
||||
{
|
||||
// se non devo disegnare, esco subito
|
||||
if ( ! m_bShowGlobFrame)
|
||||
return true ;
|
||||
|
||||
// recupero la matrice viewport
|
||||
GLint Viewport[ 4] ;
|
||||
glGetIntegerv( GL_VIEWPORT, Viewport) ;
|
||||
|
||||
// imposto il riferimento
|
||||
glPushMatrix() ;
|
||||
|
||||
// origine del riferimento globale
|
||||
const double DIST_BORDER = 30 ;
|
||||
const double POS_Z = 0.5 ;
|
||||
Point3d ptOrig ;
|
||||
UnProject( Point3d( DIST_BORDER, Viewport[3] - DIST_BORDER, POS_Z), ptOrig) ;
|
||||
|
||||
// lunghezza degli assi
|
||||
const double LEN_AX = DIST_BORDER - 2 ;
|
||||
double dLen = LEN_AX * ( 2 * m_dHalfWidth) / Viewport[2] ;
|
||||
|
||||
// disegno degli assi
|
||||
glLineWidth( 2) ;
|
||||
glBegin( GL_LINES) ;
|
||||
// asse X+
|
||||
glColor3f( RED.GetRed(), RED.GetGreen(), RED.GetBlue()) ;
|
||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ;
|
||||
glVertex3f( float( ptOrig.x + dLen), float( ptOrig.y), float( ptOrig.z)) ;
|
||||
// asse Y+
|
||||
glColor3f( LIME.GetRed(), LIME.GetGreen(), LIME.GetBlue()) ;
|
||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ;
|
||||
glVertex3f( float( ptOrig.x), float( ptOrig.y + dLen), float( ptOrig.z)) ;
|
||||
// asse Z+
|
||||
glColor3f( BLUE.GetRed(), BLUE.GetGreen(), BLUE.GetBlue()) ;
|
||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ;
|
||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z + dLen)) ;
|
||||
glEnd() ;
|
||||
glLineWidth( 1) ;
|
||||
|
||||
// ripristino lo stack delle matrici
|
||||
glPopMatrix() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
+2
-12
@@ -2,7 +2,7 @@
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SceneGrid.cpp Data : 25.10.14 Versione : 1.5j6
|
||||
// Contenuto : Implementazione snap di punti trmite selezione.
|
||||
// Contenuto : Implementazione gestione e disegno griglia.
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -28,16 +28,6 @@ Scene::SetGridShow( bool bShowGrid, bool bShowFrame)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::SetGridFrame( const Frame3d& frFrame)
|
||||
{
|
||||
if ( ! frFrame.IsValid())
|
||||
return false ;
|
||||
m_frGrid = frFrame ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep)
|
||||
@@ -70,7 +60,7 @@ Scene::DrawGrid( void)
|
||||
// imposto il riferimento
|
||||
glPushMatrix() ;
|
||||
double Matrix[OGLMAT_DIM] ;
|
||||
if ( FrameToOpenGlMatrix( m_frGrid, Matrix))
|
||||
if ( FrameToOpenGlMatrix( GetGridFrame(), Matrix))
|
||||
glMultMatrixd( Matrix) ;
|
||||
|
||||
// semi-estensione della griglia
|
||||
|
||||
+50
-33
@@ -35,6 +35,9 @@ Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Poi
|
||||
// reset dati associati a ultimo punto snap
|
||||
m_nLastSnapId = GDB_ID_NULL ;
|
||||
m_bLastSnapDirOk = false ;
|
||||
// verifico validità GDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// se Snap Sketch o Grid, devo trovare il punto sulla griglia
|
||||
if ( nSnap == SP_SKETCH || nSnap == SP_GRID)
|
||||
return GetGridSnapPoint( ( nSnap == SP_SKETCH), ptWin, ptSel) ;
|
||||
@@ -50,6 +53,9 @@ Scene::GetGraphicSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Poi
|
||||
bool
|
||||
Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
{
|
||||
// recupero il riferimento di griglia
|
||||
Frame3d frGrid = GetGridFrame() ;
|
||||
|
||||
// calcolo un punto e la direzione della linea di mira
|
||||
Point3d ptLine ;
|
||||
if ( ! UnProject( ptWin, ptLine))
|
||||
@@ -57,14 +63,14 @@ Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
Vector3d vtLine = - m_vtDirCamera ;
|
||||
|
||||
// determino l'intersezione di questa linea con il piano della griglia
|
||||
double dDenom = vtLine * m_frGrid.VersZ() ;
|
||||
double dDenom = vtLine * frGrid.VersZ() ;
|
||||
if ( fabs( dDenom) < COS_ORTO_ANG_SMALL)
|
||||
return false ;
|
||||
double dU = ( ( m_frGrid.Orig() - ptLine) * m_frGrid.VersZ()) / dDenom ;
|
||||
double dU = ( ( frGrid.Orig() - ptLine) * frGrid.VersZ()) / dDenom ;
|
||||
ptSel = ptLine + dU * vtLine ;
|
||||
|
||||
// porto il punto sul piano di griglia
|
||||
ptSel.ToLoc( m_frGrid) ;
|
||||
ptSel.ToLoc( frGrid) ;
|
||||
// se punto grid, devo arrotondare al nodo di griglia più vicino
|
||||
if ( ! bSketch) {
|
||||
ptSel.x = floor( ptSel.x / m_dSnapStep + 0.5) * m_dSnapStep ;
|
||||
@@ -73,7 +79,7 @@ Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
// il punto deve stare sulla griglia
|
||||
ptSel.z = 0 ;
|
||||
// lo riporto in globale
|
||||
ptSel.ToGlob( m_frGrid) ;
|
||||
ptSel.ToGlob( frGrid) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -81,6 +87,9 @@ Scene::GetGridSnapPoint( bool bSketch, const Point3d& ptWin, Point3d& ptSel)
|
||||
bool
|
||||
Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptGrid, Point3d& ptSel)
|
||||
{
|
||||
// recupero il riferimento di griglia
|
||||
Frame3d frGrid = GetGridFrame() ;
|
||||
|
||||
// calcolo un punto e la direzione della linea di mira
|
||||
Point3d ptLine ;
|
||||
if ( ! UnProject( ptWin, ptLine))
|
||||
@@ -89,7 +98,7 @@ Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptG
|
||||
|
||||
// piano di elevazione :
|
||||
// per il punto di griglia, contenente la perp. alla griglia e più perp. possibile alla direzione di mira
|
||||
Vector3d vtNorm = vtLine - ( vtLine * m_frGrid.VersZ()) * m_frGrid.VersZ() ;
|
||||
Vector3d vtNorm = vtLine - ( vtLine * frGrid.VersZ()) * frGrid.VersZ() ;
|
||||
if ( ! vtNorm.Normalize())
|
||||
return false ;
|
||||
|
||||
@@ -101,10 +110,10 @@ Scene::GetGridSnapPointZ( bool bSketch, const Point3d& ptWin, const Point3d& ptG
|
||||
Point3d ptNear = ptLine + dU * vtLine ;
|
||||
|
||||
// proietto il punto sulla linea di elevazione
|
||||
double dDeltaZ = ( ptNear - ptGrid) * m_frGrid.VersZ() ;
|
||||
double dDeltaZ = ( ptNear - ptGrid) * frGrid.VersZ() ;
|
||||
if ( ! bSketch)
|
||||
dDeltaZ = floor( dDeltaZ / m_dSnapStep + 0.5) * m_dSnapStep ;
|
||||
ptSel = ptGrid + dDeltaZ * m_frGrid.VersZ() ;
|
||||
ptSel = ptGrid + dDeltaZ * frGrid.VersZ() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -180,13 +189,25 @@ Scene::GetSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH, Po
|
||||
const ICurveComposite* pCrvCompo = GetCurveComposite( pGObj) ;
|
||||
// il punto di riferimento deriva da XY su viewport e Z da selezione
|
||||
Point3d ptWinZ( ptWin.x, ptWin.y, GetSelectedObjWinZ()) ;
|
||||
// determino la curva elementare più vicina al punto di riferimento
|
||||
int nCrv = - 1 ;
|
||||
Point3d ptRef ;
|
||||
if ( UnProject( ptWinZ, ptRef)) {
|
||||
double dPar ;
|
||||
int nFlag ;
|
||||
if ( DistPointCurve( ptRef, *pCrvCompo).GetParamAtMinDistPoint( 0, dPar, nFlag))
|
||||
nCrv = static_cast<int>( dPar) ;
|
||||
}
|
||||
// ciclo sulle curve elementari
|
||||
int nCont = 0 ;
|
||||
const ICurve* pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
// verifico i punti notevoli della curva
|
||||
if ( TestCurveSnapPoints( nSnap, ptWinZ, nId, frEnt, pCrv, dMinSqDist, ptSel))
|
||||
if ( nCont == nCrv &&
|
||||
TestCurveSnapPoints( nSnap, ptWinZ, nId, frEnt, pCrv, dMinSqDist, ptSel))
|
||||
bFound = true ;
|
||||
// passo alla successiva
|
||||
++ nCont ;
|
||||
pCrv = pCrvCompo->GetNextCurve() ;
|
||||
}
|
||||
}
|
||||
@@ -480,66 +501,62 @@ Scene::VerifySnapPoint( const Point3d& ptP, const Point3d& ptWin, double& dMinSq
|
||||
bool
|
||||
Scene::GetSelectedIntersectionPoint( const Point3d& ptWin, int nW, int nH, Point3d& ptSel)
|
||||
{
|
||||
// l'intersezione viene calcolata nel piano della griglia
|
||||
// --- l'intersezione viene calcolata nel piano della griglia ---
|
||||
// verifico siano state selezionate delle entità
|
||||
int nSel ;
|
||||
Select( ptWin, nW, nH, nSel) ;
|
||||
if ( nSel <= 0)
|
||||
return false ;
|
||||
// recupero le entità selezionate
|
||||
INTVECTOR nIds ;
|
||||
GetSelectedObjs( nIds) ;
|
||||
// cerco le prime due curve inquadrate
|
||||
// cerco le prime due curve inquadrate con i loro riferimenti
|
||||
const ICurve* pCrv[2] ;
|
||||
Frame3d frEnt[2] ;
|
||||
double dWinZ = 0 ;
|
||||
int nCrvNum = 0 ;
|
||||
int nId[2] = { GDB_ID_NULL, GDB_ID_NULL} ;
|
||||
const ICurve* pCrv[2] = { nullptr, nullptr} ;
|
||||
for ( size_t i = 0 ; i < nIds.size() && nCrvNum < 2 ; ++ i) {
|
||||
for ( int i = GetFirstSelectedObj() ; i != GDB_ID_NULL && nCrvNum < 2 ; i = GetNextSelectedObj()) {
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = m_pGeomDB->GetGeoObj( nIds[i])) == nullptr)
|
||||
if ( ( pGObj = m_pGeomDB->GetGeoObj( i)) == nullptr)
|
||||
continue ;
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
nId[nCrvNum] = nIds[i] ;
|
||||
pCrv[nCrvNum] = GetCurve( pGObj) ;
|
||||
if ( ! m_pGeomDB->GetGlobFrame( i, frEnt[nCrvNum]))
|
||||
return false ;
|
||||
dWinZ += 0.5 * GetSelectedObjWinZ() ;
|
||||
++ nCrvNum ;
|
||||
}
|
||||
}
|
||||
if ( nCrvNum < 2)
|
||||
return false ;
|
||||
// recupero i riferimenti in cui sono immerse
|
||||
Frame3d frEnt[2] ;
|
||||
if ( ! m_pGeomDB->GetGlobFrame( nId[0], frEnt[0]))
|
||||
return false ;
|
||||
if ( ! m_pGeomDB->GetGlobFrame( nId[1], frEnt[1]))
|
||||
if ( nCrvNum != 2)
|
||||
return false ;
|
||||
// recupero il riferimento di griglia
|
||||
Frame3d frGrid = GetGridFrame() ;
|
||||
// se il riferimento della seconda curva è diverso da quello della griglia, devo trasformarla
|
||||
PtrOwner<ICurve> crvTrans0( nullptr) ;
|
||||
if ( ! AreSameFrame( frEnt[0], m_frGrid)) {
|
||||
if ( ! AreSameFrame( frEnt[0], frGrid)) {
|
||||
crvTrans0.Set( pCrv[0]->Clone()) ;
|
||||
if ( IsNull( crvTrans0))
|
||||
return false ;
|
||||
crvTrans0->LocToLoc( frEnt[0],m_frGrid) ;
|
||||
crvTrans0->LocToLoc( frEnt[0], frGrid) ;
|
||||
pCrv[0] = ::Get( crvTrans0) ;
|
||||
}
|
||||
// se il riferimento della seconda curva è diverso da quello della griglia, devo trasformarla
|
||||
PtrOwner<ICurve> crvTrans1( nullptr) ;
|
||||
if ( ! AreSameFrame( frEnt[1], m_frGrid)) {
|
||||
if ( ! AreSameFrame( frEnt[1], frGrid)) {
|
||||
crvTrans1.Set( pCrv[1]->Clone()) ;
|
||||
if ( IsNull( crvTrans1))
|
||||
return false ;
|
||||
crvTrans1->LocToLoc( frEnt[1], m_frGrid) ;
|
||||
crvTrans1->LocToLoc( frEnt[1], frGrid) ;
|
||||
pCrv[1] = ::Get( crvTrans1) ;
|
||||
}
|
||||
// uso il punto sketch come punto vicino e lo porto nel riferimento della griglia
|
||||
Point3d ptWinZ( ptWin.x, ptWin.y, dWinZ) ;
|
||||
Point3d ptNear ;
|
||||
if ( ! GetGridSnapPoint( true, ptWin, ptNear) ||
|
||||
! UnProject( ptWin, ptNear))
|
||||
if ( ! UnProject( ptWinZ, ptNear))
|
||||
ptNear = ORIG ;
|
||||
ptNear.ToLoc( m_frGrid) ;
|
||||
ptNear.ToLoc( frGrid) ;
|
||||
// calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento
|
||||
IntersCurveCurve intCC( *pCrv[0], *pCrv[1], true) ;
|
||||
if ( ! intCC.GetIntersPointNearTo( 0, ptNear, ptSel))
|
||||
return false ;
|
||||
ptSel.ToGlob( m_frGrid) ;
|
||||
ptSel.ToGlob( frGrid) ;
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user