46c5fce044
- ora si imposta un context corrente anche per le API come per LUA - il context corrente di LUA coincide con quello delle API.
412 lines
12 KiB
C++
412 lines
12 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : API_GdbObjAttribs.cpp Data : 03.09.14 Versione : 1.5i1
|
|
// Contenuto : Funzioni sugli attributi degli oggetti di GeomDB per API.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 03.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "API.h"
|
|
#include "API_Macro.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
#include "/EgtDev/Include/EGnStringConverter.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetLevel( int nId, int nLevel)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// imposto il livello
|
|
return ( pGeomDB->SetLevel( nId, nLevel) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtRevertLevel( int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// porto il livello allo stato precedente
|
|
return ( pGeomDB->RevertLevel( nId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetLevel( int nId, int* pnLevel)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pnLevel == nullptr)
|
|
return FALSE ;
|
|
// recupero il livello
|
|
return ( pGeomDB->GetLevel( nId, *pnLevel) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetCalcLevel( int nId, int* pnLevel)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pnLevel == nullptr)
|
|
return FALSE ;
|
|
// recupero il modo
|
|
return ( pGeomDB->GetCalcLevel( nId, *pnLevel) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetMode( int nId, int nMode)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// imposto il modo
|
|
return ( pGeomDB->SetMode( nId, nMode) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtRevertMode( int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// porto il modo allo stato precedente
|
|
return ( pGeomDB->RevertMode( nId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetMode( int nId, int* pnMode)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pnMode == nullptr)
|
|
return FALSE ;
|
|
// recupero il modo
|
|
return ( pGeomDB->GetMode( nId, *pnMode) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetCalcMode( int nId, int* pnMode)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pnMode == nullptr)
|
|
return FALSE ;
|
|
// recupero il modo
|
|
return ( pGeomDB->GetCalcMode( nId, *pnMode) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetStatus( int nId, int nStat)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// imposto il modo
|
|
return ( pGeomDB->SetStatus( nId, nStat) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtRevertStatus( int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// porto lo stato al valore precedente
|
|
return ( pGeomDB->RevertStatus( nId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetStatus( int nId, int* pnStat)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pnStat == nullptr)
|
|
return FALSE ;
|
|
// recupero il modo
|
|
return ( pGeomDB->GetStatus( nId, *pnStat) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetCalcStatus( int nId, int* pnStat)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pnStat == nullptr)
|
|
return FALSE ;
|
|
// recupero il modo
|
|
return ( pGeomDB->GetCalcStatus( nId, *pnStat) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetMark( int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// imposto l'evidenziazione
|
|
return ( pGeomDB->SetMark( nId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtResetMark( int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// cancello l'evidenziazione
|
|
return ( pGeomDB->ResetMark( nId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetMark( int nId, BOOL* pbMark)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pbMark == nullptr)
|
|
return FALSE ;
|
|
// recupero il modo
|
|
return ( pGeomDB->GetMark( nId, *pbMark) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetCalcMark( int nId, BOOL* pbMark)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico il parametro
|
|
if ( pbMark == nullptr)
|
|
return FALSE ;
|
|
// recupero il modo
|
|
return ( pGeomDB->GetCalcMark( nId, *pbMark) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtStdColor( const wchar_t* wsName, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
|
{
|
|
return EgtStdColor( wstrztoA( wsName), nRed, nGreen, nBlue, nAlpha) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtStdColor( const string& sName, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
|
{
|
|
// recupero il colore standard
|
|
Color cCol ;
|
|
if ( GetStdColor( sName, cCol)) {
|
|
nRed = cCol.GetIntRed() ;
|
|
nGreen = cCol.GetIntGreen() ;
|
|
nBlue = cCol.GetIntBlue() ;
|
|
nAlpha = cCol.GetIntAlpha() ;
|
|
return TRUE ;
|
|
}
|
|
else
|
|
return FALSE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetColor( int nId, int nRed, int nGreen, int nBlue, int nAlpha)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// assegno il colore
|
|
Color cCol( nRed, nGreen, nBlue, nAlpha) ;
|
|
return ( pGeomDB->SetMaterial( nId, cCol) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetColor( int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// recupero il colore
|
|
Color cCol ;
|
|
if ( pGeomDB->GetMaterial( nId, cCol)) {
|
|
nRed = cCol.GetIntRed() ;
|
|
nGreen = cCol.GetIntGreen() ;
|
|
nBlue = cCol.GetIntBlue() ;
|
|
nAlpha = cCol.GetIntAlpha() ;
|
|
return TRUE ;
|
|
}
|
|
else
|
|
return FALSE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetCalcColor( int nId, int& nRed, int& nGreen, int& nBlue, int& nAlpha)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// recupero il colore
|
|
Color cCol ;
|
|
if ( pGeomDB->GetCalcMaterial( nId, cCol)) {
|
|
nRed = cCol.GetIntRed() ;
|
|
nGreen = cCol.GetIntGreen() ;
|
|
nBlue = cCol.GetIntBlue() ;
|
|
nAlpha = cCol.GetIntAlpha() ;
|
|
return TRUE ;
|
|
}
|
|
else
|
|
return FALSE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetName( int nId, const wchar_t* wsName)
|
|
{
|
|
return EgtSetName( nId, wstrztoA( wsName)) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetName( int nId, const string& sName)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// assegno il nome
|
|
return ( pGeomDB->SetName( nId, sName) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetName( int nId, wchar_t*& wsName)
|
|
{
|
|
string sName ;
|
|
if ( ! EgtGetName( nId, sName))
|
|
return FALSE ;
|
|
wsName = _wcsdup( stringtoW( sName)) ;
|
|
return (( wsName == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetName( int nId, string& sName)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// recupero il nome
|
|
return pGeomDB->GetName( nId, sName) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtExistsName( int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico esistenza del nome
|
|
return ( pGeomDB->ExistsName( nId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtRemoveName( int nId)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// rimuovo il nome
|
|
return ( pGeomDB->RemoveName( nId) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetInfo( int nId, const wchar_t* wsKey, const wchar_t* wsInfo)
|
|
{
|
|
return EgtSetInfo( nId, wstrztoA( wsKey), wstrztoA( wsInfo)) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtSetInfo( int nId, const string& sKey, const string& sInfo)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// assegno la info
|
|
return ( pGeomDB->SetInfo( nId, sKey, sInfo) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetInfo( int nId, const wchar_t* wsKey, wchar_t*& wsInfo)
|
|
{
|
|
string sInfo ;
|
|
if ( ! EgtGetInfo( nId, wstrztoA( wsKey), sInfo))
|
|
return FALSE ;
|
|
wsInfo = _wcsdup( stringtoW( sInfo)) ;
|
|
return (( wsInfo == nullptr) ? FALSE : TRUE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtGetInfo( int nId, const string& sKey, string& sInfo)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// recupero la info
|
|
return pGeomDB->GetInfo( nId, sKey, sInfo) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtExistsInfo( int nId, const wchar_t* wsKey)
|
|
{
|
|
return EgtExistsInfo( nId, wstrztoA( wsKey)) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtExistsInfo( int nId, const string& sKey)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// verifico esistenza info
|
|
return ( pGeomDB->ExistsInfo( nId, sKey) ? TRUE : FALSE) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtRemoveInfo( int nId, const wchar_t* wsKey)
|
|
{
|
|
return EgtRemoveInfo( nId, wstrztoA( wsKey)) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
BOOL
|
|
__stdcall EgtRemoveInfo( int nId, const string& sKey)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, FALSE)
|
|
// rimuovo la info
|
|
return ( pGeomDB->RemoveInfo( nId, sKey) ? TRUE : FALSE) ;
|
|
}
|