EgtInterface 1.6a3 :

- modifiche varie per gestire GLOB, LOC e GRID sui dati geometrici
- aggiornamenti e miglirie varie
- eliminate alcune funzioni lua ormai obsolete (ArcXY e CircleXY).
This commit is contained in:
Dario Sassi
2015-01-19 18:21:58 +00:00
parent e23999b6a3
commit 4e5a81c493
19 changed files with 945 additions and 415 deletions
+178 -45
View File
@@ -17,6 +17,7 @@
#include "API_Macro.h"
#include "AuxTools.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EgkGeoPoint3d.h"
#include "/EgtDev/Include/EgkGeoVector3d.h"
#include "/EgtDev/Include/EgkExtText.h"
@@ -29,16 +30,37 @@ using namespace std ;
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateGroup( int nParentId, const double ptOrig[3],
const double vX[3], const double vY[3], const double vZ[3])
const double vX[3], const double vY[3], const double vZ[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// porto in locale l'origine e i versori
Point3d ptOrigL( ptOrig) ;
Vector3d vtXL( vX) ;
Vector3d vtYL( vY) ;
Vector3d vtZL( vZ) ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( nRefType == RTY_GLOB) {
ptOrigL.ToLoc( frLoc) ;
vtXL.ToLoc( frLoc) ;
vtYL.ToLoc( frLoc) ;
vtZL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptOrigL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtXL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtYL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtZL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// costruisco il riferimento
Frame3d frFrame ;
if ( ! frFrame.Set( ptOrig, vX, vY, vZ))
return GDB_ID_NULL ;
bOk = bOk && frFrame.Set( ptOrigL, vtXL, vtYL, vtZL) ;
// creo il gruppo
int nId = pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrame) ;
int nId = ( bOk ? pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrame) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
@@ -50,7 +72,8 @@ __stdcall EgtCreateGroup( int nParentId, const double ptOrig[3],
ToString( Point3d( ptOrig)) + "},{" +
ToString( Vector3d( vX)) + "},{" +
ToString( Vector3d( vY)) + "},{" +
ToString( Vector3d( vZ)) + "}})" +
ToString( Vector3d( vZ)) + "}}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -60,23 +83,35 @@ __stdcall EgtCreateGroup( int nParentId, const double ptOrig[3],
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3])
__stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// porto in locale il punto
Point3d ptPL( ptP) ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( nRefType == RTY_GLOB) {
ptPL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// creo il punto
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
if ( IsNull( pGeoPnt))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pGeoPnt) ;
// setto il punto
if ( ! pGeoPnt->Set( ptP))
return GDB_ID_NULL ;
bOk = bOk && pGeoPnt->Set( ptPL) ;
// inserisco il punto nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtPoint(" + ToString( nParentId) + ",{" +
ToString( Point3d( ptP)) + "})" +
ToString( Point3d( ptP)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -86,30 +121,46 @@ __stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3])
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double ptB[3])
__stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double ptB[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// porto in locale il vettore e il punto
Vector3d vtVL( vtV) ;
Point3d ptBL( ptB) ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( nRefType == RTY_GLOB) {
vtVL.ToLoc( frLoc) ;
ptBL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
vtVL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
ptBL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// creo il vettore
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
if ( IsNull( pGeoVct))
return GDB_ID_NULL ;
bOk = bOk && ! IsNull( pGeoVct) ;
// setto il vettore (con il punto base)
if ( ! pGeoVct->Set( vtV, ptB))
return GDB_ID_NULL ;
bOk = bOk && pGeoVct->Set( vtVL, ptBL) ;
// inserisco il vettore nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua ;
if ( Point3d( ptB).IsSmall())
sLua = "EgtVector(" + ToString( nParentId) + ",{" +
ToString( Vector3d( vtV)) + "})" +
ToString( Vector3d( vtV)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
else
sLua = "EgtVector(" + ToString( nParentId) + ",{" +
ToString( Vector3d( vtV)) + "},{" +
ToString( Point3d( ptB)) + "})" +
ToString( Point3d( ptB)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -120,26 +171,46 @@ __stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double p
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateGeoFrame( int nParentId, const double ptOrig[3],
const double vX[3], const double vY[3], const double vZ[3])
const double vX[3], const double vY[3], const double vZ[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// creo il riferimento
bool bOk = true ;
// porto in locale l'origine e i versori
Point3d ptOrigL( ptOrig) ;
Vector3d vtXL( vX) ;
Vector3d vtYL( vY) ;
Vector3d vtZL( vZ) ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( nRefType == RTY_GLOB) {
ptOrigL.ToLoc( frLoc) ;
vtXL.ToLoc( frLoc) ;
vtYL.ToLoc( frLoc) ;
vtZL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptOrigL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtXL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtYL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtZL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// creo e setto il riferimento
PtrOwner<IGeoFrame3d> pGeoFrm( CreateGeoFrame3d()) ;
if ( IsNull( pGeoFrm))
return GDB_ID_NULL ;
// setto il riferimento
if ( ! pGeoFrm->Set( ptOrig, vX, vY, vZ))
return GDB_ID_NULL ;
bOk = bOk & ! IsNull( pGeoFrm) ;
bOk = bOk & pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ;
// inserisco il riferimento nel DB
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) ;
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) : GDB_ID_NULL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtFrame(" + ToString( nParentId) + ",{{" +
ToString( Point3d( ptOrig)) + "},{" +
ToString( Vector3d( vX)) + "},{" +
ToString( Vector3d( vY)) + "},{" +
ToString( Vector3d( vZ)) + "}})" +
ToString( Vector3d( vZ)) + "}}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -150,21 +221,41 @@ __stdcall EgtCreateGeoFrame( int nParentId, const double ptOrig[3],
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateText( int nParentId, const double ptP[3], double dAngRotDeg,
const wchar_t* wsText, double dH)
const wchar_t* wsText, double dH, int nRefType)
{
return EgtCreateText( nParentId, ptP, dAngRotDeg, wstrztoA( wsText), dH) ;
return EgtCreateText( nParentId, ptP, dAngRotDeg, wstrztoA( wsText), dH, nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg,
const string& sText, double dH)
const string& sText, double dH, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// porto in locale l'origine e i versori
Point3d ptPL( ptP) ;
Vector3d vtNL = Z_AX ;
Vector3d vtDL = X_AX ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( nRefType == RTY_GLOB) {
ptPL.ToLoc( frLoc) ;
vtNL.ToLoc( frLoc) ;
vtDL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtDL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// creo il testo e lo riempio
PtrOwner<IExtText> pTXT( CreateExtText()) ;
bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, dAngRotDeg, sText, dH)) ;
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) ;
// se richiesto, salvo il comando Lua equivalente
@@ -173,7 +264,8 @@ __stdcall EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg,
ToString( ptP) + "}," +
ToString( dAngRotDeg) + ",'" +
sText + "','" +
ToString( dH) + ")" +
ToString( dH) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -184,23 +276,42 @@ __stdcall EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg,
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateTextEx( int nParentId, const double ptP[3], const double vtN[3], const double vtD[3],
const wchar_t* wsText, const wchar_t* wsFont, BOOL bItalic, double dH)
const wchar_t* wsText, const wchar_t* wsFont, BOOL bItalic, double dH, int nRefType)
{
return EgtCreateTextEx( nParentId, ptP, vtN, vtD,
wstrztoA( wsText), wstrztoA( wsFont), (bItalic != FALSE), dH) ;
wstrztoA( wsText), wstrztoA( wsFont), (bItalic != FALSE), dH, nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD,
const string& sText, const string& sFont, bool bItalic, double dH)
const string& sText, const string& sFont, bool bItalic, double dH, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// porto in locale l'origine e i versori
Point3d ptPL( ptP) ;
Vector3d vtNL( vtN) ;
Vector3d vtDL( vtD) ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( nRefType == RTY_GLOB) {
ptPL.ToLoc( frLoc) ;
vtNL.ToLoc( frLoc) ;
vtDL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtDL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// creo il testo e lo riempio
PtrOwner<IExtText> pTXT( CreateExtText()) ;
//bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, dAngRotDeg, sText, dH)) ;
bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, vtN, vtD, sText, sFont, bItalic, dH)) ;
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) ;
// se richiesto, salvo il comando Lua equivalente
@@ -212,7 +323,8 @@ __stdcall EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vt
sText + "','" +
sFont + "'," +
( bItalic ? "'I'" : "'S'") + "," +
ToString( dH) + ")" +
ToString( dH) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -224,24 +336,44 @@ __stdcall EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vt
int
__stdcall EgtCreateTextAdv( int nParentId, const double ptP[3], const double vtN[3], const double vtD[3],
const wchar_t* wsText, const wchar_t* wsFont,
int nW, BOOL bItalic, double dH, double dRat, double dAddAdv, int nInsPos)
int nW, BOOL bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType)
{
return EgtCreateTextAdv( nParentId, ptP, vtN, vtD,
wstrztoA( wsText), wstrztoA( wsFont),
nW, ( bItalic != FALSE), dH, dRat, dAddAdv, nInsPos) ;
nW, ( bItalic != FALSE), dH, dRat, dAddAdv, nInsPos, nRefType) ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateTextAdv( 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 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 ;
// porto in locale l'origine e i versori
Point3d ptPL( ptP) ;
Vector3d vtNL( vtN) ;
Vector3d vtDL( vtD) ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
if ( nRefType == RTY_GLOB) {
ptPL.ToLoc( frLoc) ;
vtNL.ToLoc( frLoc) ;
vtDL.ToLoc( frLoc) ;
}
else /* RTY_GRID */ {
ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
vtDL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
}
// creo il testo e lo imposto
PtrOwner<IExtText> pTXT( CreateExtText()) ;
bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, vtN, vtD, sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos)) ;
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) ;
// se richiesto, salvo il comando Lua equivalente
@@ -257,7 +389,8 @@ __stdcall EgtCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& v
ToString( dH) + "," +
ToString( dRat) + "," +
ToString( dAddAdv) + "," +
ETxtInsPosToString( nInsPos) + ")" +
ETxtInsPosToString( nInsPos) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}