Files
EgtExecutor/EXE_GdbCreate.cpp
T
Dario Sassi 66b56c544f EgtExecutor 1.6e4 :
- aggiornamenti per cambio nomi include di base
- corretto errore in registrazione comando EgtArcC2PNEx
- corretto errore in ExeExplodeSurfTm (crash con entità non superfici)
- aggiunte funzioni Exe e Lua di movimento assi e carico/scarico teste di macchina
- aggiunta Exe e Lua ZoomRadius
- possibilità di lua EgtOutBox non modale (solo per usi interni).
2015-05-11 21:09:07 +00:00

304 lines
13 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2015
//----------------------------------------------------------------------------
// File : EXE_GdbCreate.cpp Data : 04.05.15 Versione : 1.6e1
// Contenuto : Funzioni di creazione oggetti del DB geometrico per EXE.
//
//
//
// Modifiche : 30.09.14 DS Creazione modulo.
// 07.01.15 DS Agg. scrittura comandi Lua.
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "EXE.h"
#include "EXE_Macro.h"
#include "AuxTools.h"
#include "GeoTools.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkGeoVector3d.h"
#include "/EgtDev/Include/EGkExtText.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//-------------------------------------------------------------------------------
int
ExeCreateGroup( int nParentId, const Frame3d& frFrame, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale l'origine e i versori
Point3d ptOrigL = GetPointLocal( pGeomDB, frFrame.Orig(), nRefType, frLoc) ;
Vector3d vtXL = GetVectorLocal( pGeomDB, frFrame.VersX(), nRefType, frLoc) ;
Vector3d vtYL = GetVectorLocal( pGeomDB, frFrame.VersY(), nRefType, frLoc) ;
Vector3d vtZL = GetVectorLocal( pGeomDB, frFrame.VersZ(), nRefType, frLoc) ;
// costruisco il riferimento
Frame3d frFrameL ;
bOk = bOk && frFrameL.Set( ptOrigL, vtXL, vtYL, vtZL) ;
// creo il gruppo
int nId = ( bOk ? pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrameL) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
if ( AreSameFrame( frFrame, GLOB_FRM))
sLua = "EgtGroup(" + ToString( nParentId) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtGroup(" + ToString( nParentId) + ",{{" +
ToString( frFrame.Orig()) + "},{" +
ToString( frFrame.VersX()) + "},{" +
ToString( frFrame.VersY()) + "},{" +
ToString( frFrame.VersZ()) + "}}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo del nuovo gruppo
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateGeoPoint( int nParentId, const Point3d& ptP, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale il punto
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; ;
// creo il punto
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
bOk = bOk && ! IsNull( pGeoPnt) ;
// setto il punto
bOk = bOk && pGeoPnt->Set( ptPL) ;
// inserisco il punto nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtPoint(" + ToString( nParentId) + ",{" +
ToString( ptP) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateGeoVector( int nParentId, const Vector3d& vtV, const Point3d& ptB, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale il vettore e il punto
Vector3d vtVL = GetVectorLocal( pGeomDB, vtV, nRefType, frLoc) ; ;
Point3d ptBL = GetPointLocal( pGeomDB, ptB, nRefType, frLoc) ; ;
// creo il vettore
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
bOk = bOk && ! IsNull( pGeoVct) ;
// setto il vettore (con il punto base)
bOk = bOk && pGeoVct->Set( vtVL, ptBL) ;
// inserisco il vettore nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
if ( ptB.IsSmall())
sLua = "EgtVector(" + ToString( nParentId) + ",{" +
ToString( vtV) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtVector(" + ToString( nParentId) + ",{" +
ToString( vtV) + "},{" +
ToString( ptB) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateGeoFrame( int nParentId, const Frame3d& frFrame, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale l'origine e i versori
Point3d ptOrigL = GetPointLocal( pGeomDB, frFrame.Orig(), nRefType, frLoc) ; ;
Vector3d vtXL = GetVectorLocal( pGeomDB, frFrame.VersX(), nRefType, frLoc) ; ;
Vector3d vtYL = GetVectorLocal( pGeomDB, frFrame.VersY(), nRefType, frLoc) ; ;
Vector3d vtZL = GetVectorLocal( pGeomDB, frFrame.VersZ(), nRefType, frLoc) ; ;
// creo e setto il riferimento
PtrOwner<IGeoFrame3d> pGeoFrm( CreateGeoFrame3d()) ;
bOk = bOk & ! IsNull( pGeoFrm) ;
bOk = bOk & pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ;
// inserisco il riferimento nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtFrame(" + ToString( nParentId) + ",{{" +
ToString( frFrame.Orig()) + "},{" +
ToString( frFrame.VersX()) + "},{" +
ToString( frFrame.VersY()) + "},{" +
ToString( frFrame.VersZ()) + "}}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo del nuovo gruppo
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg,
const string& sText, double dH, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale l'origine e i versori
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; ;
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; ;
Vector3d vtDL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ; ;
// creo il testo e lo riempio
PtrOwner<IExtText> pTXT( CreateExtText()) ;
bOk = bOk && ! IsNull( pTXT) ;
bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, "", false, dH) ;
// inserisco il testo nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtText(" + ToString( nParentId) + ",{" +
ToString( ptP) + "}," +
ToString( dAngRotDeg) + ",'" +
sText + "','" +
ToString( dH) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo del oggetto
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD,
const string& sText, const string& sFont, bool bItalic, double dH, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale l'origine e i versori
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; ;
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; ;
Vector3d vtDL = GetVectorLocal( pGeomDB, vtD, nRefType, frLoc) ; ;
// creo il testo e lo riempio
PtrOwner<IExtText> pTXT( CreateExtText()) ;
bOk = bOk && ! IsNull( pTXT) ;
bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, bItalic, dH) ;
// inserisco il testo nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtTextEx(" + ToString( nParentId) + ",{" +
ToString( ptP) + "},{" +
ToString( vtN) + "},{" +
ToString( vtD) + "},'" +
sText + "','" +
sFont + "'," +
( bItalic ? "'I'" : "'S'") + "," +
ToString( dH) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo del oggetto
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD,
const string& sText, const string& sFont,
int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// porto in locale l'origine e i versori
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; ;
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; ;
Vector3d vtDL = GetVectorLocal( pGeomDB, vtD, nRefType, frLoc) ; ;
// creo il testo e lo imposto
PtrOwner<IExtText> pTXT( CreateExtText()) ;
bOk = bOk && ! IsNull( pTXT) ;
bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos) ;
// inserisco il testo nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtTextAdv(" + ToString( nParentId) + ",{" +
ToString( ptP) + "},{" +
ToString( vtN) + "},{" +
ToString( vtD) + "},'" +
sText + "','" +
sFont + "'," +
ToString( nW) + "," +
( bItalic ? "'I'" : "'S'") + "," +
ToString( dH) + "," +
ToString( dRat) + "," +
ToString( dAddAdv) + "," +
ETxtInsPosToString( nInsPos) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo del oggetto
return nId ;
}