EgtExecutor 2.2a1 :
- aggiunte funzioni Exe e Lua CreateHorizontalDimension, CreateVerticalDimension e CreateAlignedDimension.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkExtDimension.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
@@ -310,3 +311,122 @@ ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg,
|
||||
// restituisco l'identificativo del oggetto
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateHorizontalDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2,
|
||||
const Point3d& ptDim, const string& sText, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale i punti e assegno i versori
|
||||
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
|
||||
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
|
||||
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
||||
Vector3d vtDL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ;
|
||||
// creo la quota
|
||||
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
||||
bOk = bOk && ! IsNull( pDim) ;
|
||||
bOk = bOk && pDim->SetLinear( ptP1L, ptP2L, ptDimL, vtNL, vtDL, sText) ;
|
||||
// inserisco la quota nel DB
|
||||
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtHorizontalDimension(" + IdToString( nParentId) + ",{" +
|
||||
ToString( ptP1) + "},{" +
|
||||
ToString( ptP2) + "},{" +
|
||||
ToString( ptDim) + "}," +
|
||||
StringToLuaString( sText) + "','" +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo del oggetto
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateVerticalDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2,
|
||||
const Point3d& ptDim, const string& sText, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale i punti e assegno i versori
|
||||
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
|
||||
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
|
||||
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
||||
Vector3d vtDL = GetVectorLocal( pGeomDB, Y_AX, nRefType, frLoc) ;
|
||||
// creo la quota
|
||||
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
||||
bOk = bOk && ! IsNull( pDim) ;
|
||||
bOk = bOk && pDim->SetLinear( ptP1L, ptP2L, ptDimL, vtNL, vtDL, sText) ;
|
||||
// inserisco la quota nel DB
|
||||
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtVerticalDimension(" + IdToString( nParentId) + ",{" +
|
||||
ToString( ptP1) + "},{" +
|
||||
ToString( ptP2) + "},{" +
|
||||
ToString( ptDim) + "}," +
|
||||
StringToLuaString( sText) + "','" +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo del oggetto
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateAlignedDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2,
|
||||
const Point3d& ptDim, const string& sText, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale i punti e assegno i versori
|
||||
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
|
||||
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
|
||||
Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
||||
// creo la quota
|
||||
PtrOwner<IExtDimension> pDim( CreateExtDimension()) ;
|
||||
bOk = bOk && ! IsNull( pDim) ;
|
||||
bOk = bOk && pDim->SetLinear( ptP1L, ptP2L, ptDimL, vtNL, V_NULL, sText) ;
|
||||
// inserisco la quota nel DB
|
||||
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtAlignedDimension(" + IdToString( nParentId) + ",{" +
|
||||
ToString( ptP1) + "},{" +
|
||||
ToString( ptP2) + "},{" +
|
||||
ToString( ptDim) + "}," +
|
||||
StringToLuaString( sText) + "','" +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo del oggetto
|
||||
return nId ;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -220,6 +220,90 @@ LuaCreateTextAdv( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateHorizontalDimension( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : ParentId, ptP1, ptP2, ptDim, Text [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptP1 ;
|
||||
LuaCheckParam( L, 2, ptP1) ;
|
||||
Point3d ptP2 ;
|
||||
LuaCheckParam( L, 3, ptP2) ;
|
||||
Point3d ptDim ;
|
||||
LuaCheckParam( L, 4, ptDim) ;
|
||||
string sText ;
|
||||
LuaCheckParam( L, 5, sText) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo la quota orizzontale
|
||||
int nId = ExeCreateHorizontalDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateVerticalDimension( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : ParentId, ptP1, ptP2, ptDim, Text [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptP1 ;
|
||||
LuaCheckParam( L, 2, ptP1) ;
|
||||
Point3d ptP2 ;
|
||||
LuaCheckParam( L, 3, ptP2) ;
|
||||
Point3d ptDim ;
|
||||
LuaCheckParam( L, 4, ptDim) ;
|
||||
string sText ;
|
||||
LuaCheckParam( L, 5, sText) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo la quota verticale
|
||||
int nId = ExeCreateVerticalDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateAlignedDimension( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : ParentId, ptP1, ptP2, ptDim, Text [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptP1 ;
|
||||
LuaCheckParam( L, 2, ptP1) ;
|
||||
Point3d ptP2 ;
|
||||
LuaCheckParam( L, 3, ptP2) ;
|
||||
Point3d ptDim ;
|
||||
LuaCheckParam( L, 4, ptDim) ;
|
||||
string sText ;
|
||||
LuaCheckParam( L, 5, sText) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo la quota allineata
|
||||
int nId = ExeCreateAlignedDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreate( LuaMgr& luaMgr)
|
||||
@@ -232,5 +316,8 @@ LuaInstallGdbCreate( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtText", LuaCreateText) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextEx", LuaCreateTextEx) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextAdv", LuaCreateTextAdv) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtHorizontalDimension", LuaCreateHorizontalDimension) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVerticalDimension", LuaCreateVerticalDimension) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtAlignedDimension", LuaCreateAlignedDimension) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user