EgtExecutor 3.1b2 :

- in Trimming aggiunte funzioni per interpolazione curve di sincronizzazione
- in LUA_GENERAL aggiunto il dialogo di tipo Brush/ColorPicker.
This commit is contained in:
Riccardo Elitropi
2026-02-20 16:51:40 +01:00
parent e9f38149ac
commit 5723c92e09
4 changed files with 406 additions and 121 deletions
+70
View File
@@ -641,6 +641,76 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i
return nSurfBzId ;
}
// ---------------------------------------------------------------------------
bool
ExeTrimmingInterpolateSyncLines( int nParentId, int nSync1Id, int nSync2Id, int nBorder1Id,
int nBorder2Id, double dEdgeLinTol, double dEdgeAngTol,
int& nFirstId, int& nCount)
{
// Verifica database geometrico
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// Reset parametri di ritorno
nFirstId = GDB_ID_NULL ;
nCount = 0 ;
// Aggiusto la tolleranza lineare e angolare se necessario
double dMyEdgeLinTol = Clamp( dEdgeLinTol, EPS_SMALL, 1e5 * EPS_SMALL) ;
double dMyEdgeAngTol = Clamp( dEdgeAngTol, EPS_ANG_SMALL, 60.) ;
// recupero le due curve di sincronizzazione
const ICurve* pSync1 = GetCurve( pGeomDB->GetGeoObj( nSync1Id)) ;
const ICurve* pSync2 = GetCurve( pGeomDB->GetGeoObj( nSync2Id)) ;
bool bOk = ( pSync1 != nullptr && pSync1->IsValid() &&
pSync2 != nullptr && pSync2->IsValid()) ;
// Recupero le due curve di bordo
const ICurve* pCrvEdge1 = GetCurve( pGeomDB->GetGeoObj( nBorder1Id)) ;
const ICurve* pCrvEdge2 = GetCurve( pGeomDB->GetGeoObj( nBorder2Id)) ;
bOk = bOk && ( pCrvEdge1 != nullptr && pCrvEdge1->IsValid()) ;
bOk = bOk && ( pCrvEdge2 != nullptr && pCrvEdge2->IsValid()) ;
// Calcolo le Curve di sincornizzazione Interpolate
BIPNTVECTOR vSyncPoints ;
bOk = bOk && GetTrimmingSyncInterpolation( pCrvEdge1, pCrvEdge2, pSync1, pSync2, dMyEdgeLinTol,
dMyEdgeAngTol, vSyncPoints) ;
if ( bOk && ! vSyncPoints.empty()) {
// Inserisco le curve di sincronizzazione nel DB
// [orientate da pCrvEdge1 a pCrvEdge2]
for ( int i = 0 ; bOk && i < ssize( vSyncPoints) ; ++ i) {
PtrOwner<ICurveLine> pSyncLine( CreateCurveLine()) ;
bOk = ( ! IsNull( pSyncLine) && pSyncLine->Set( vSyncPoints[i].first, vSyncPoints[i].second)) ;
if ( bOk) {
if ( pCrvEdge1->IsPointOn( vSyncPoints[i].second, dMyEdgeLinTol))
pSyncLine->Invert() ;
int nSyncId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSyncLine)) ;
bOk = ( nSyncId != CMD_ID_NULL) ;
if ( i == 0)
nFirstId = nSyncId ;
}
}
nCount = ssize( vSyncPoints) ;
}
ExeSetModified() ;
// Se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtTrimmingInterpolateSyncLines(" + ToString( nParentId) + "," +
ToString( nSync1Id) + "," +
ToString( nSync2Id) + "," +
ToString( nBorder1Id) + "," +
ToString( nBorder2Id) + "," +
ToString( dEdgeLinTol) + "," +
ToString( dEdgeAngTol) + ")" +
" -- bOk=" + ToString( bOk) +
" -- nFirstId=" + ToString( nFirstId) + " nCount=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
// ---------------------------------------------------------------------------
bool
ExeTrimmingGetSurfBzSyncPoints( int nParentId, int nEdge1Id, int nEdge2Id, double dLinTol,
BIN
View File
Binary file not shown.
+304 -121
View File
@@ -1213,146 +1213,329 @@ LuaReleaseMutex( lua_State* L)
//-------------------------------------------------------------------------------
const int MAX_CTRLS = IDC_TEXT8 -IDC_TEXT1 + 1 ;
const int OFFS_CTRLS = 40 ;
enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3} ;
enum TYPE_CTRLS { CTRL_NONE = 0, CTRL_CHECK = 1, CTRL_COMBO = 2, CTRL_EDIT = 3, CTRL_COLOR = 4} ;
static int s_nCtrls = 0 ;
static string s_sCaption ;
static string s_sText[MAX_CTRLS] ;
static string s_sEdit[MAX_CTRLS] ;
static int s_nType[MAX_CTRLS] ;
// preview statica per la selezione del colore
#ifndef IDC_STATIC_PREVIEW
#define IDC_STATIC_PREVIEW 41000
#endif
//-------------------------------------------------------------------------------
BOOL
CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
{
// variabili static locali per mantenere lo stato tra chiamate static per selezione colori
COLORREF g_customColors[16] = {0} ;
static HBRUSH g_hColorBrush[MAX_CTRLS] = {0} ;
static COLORREF g_selectedColor[MAX_CTRLS] = {0} ;
switch ( message) {
case WM_INITDIALOG :
{
// dati del dialogo
HWND hwndOwner = GetParent( hwndDlg) ;
if ( hwndOwner == nullptr)
hwndOwner = GetDesktopWindow() ;
RECT rcOwner, rcDlg ;
GetWindowRect( hwndOwner, &rcOwner) ;
GetWindowRect( hwndDlg, &rcDlg) ;
// determino la posizione dell'ultima riga di dati da visualizzare
HWND hwndLR = GetDlgItem( hwndDlg, IDC_TEXT1 + Clamp( s_nCtrls, 1, MAX_CTRLS) - 1) ;
RECT rcLR ;
GetWindowRect( hwndLR, &rcLR) ;
POINT ptLR{ rcLR.left, rcLR.top} ;
ScreenToClient( hwndDlg, &ptLR) ;
// centro e scalo il dialogo
int nNewH = rcLR.top - rcOwner.top + 2 * OFFS_CTRLS ; // non chiaro perchè va sottratto rcOwner.top ma funziona sempre
SetWindowPos( hwndDlg,
HWND_TOP,
( rcOwner.left + rcOwner.right - ( rcDlg.right - rcDlg.left)) / 2,
( rcOwner.top + rcOwner.bottom - nNewH) / 2,
( rcDlg.right - rcDlg.left),
nNewH,
0) ;
// riposiziono il bottone Ok
HWND hwndOk = GetDlgItem( hwndDlg, IDOK) ;
RECT rcOk ;
GetWindowRect( hwndOk, &rcOk) ;
POINT ptOk{ rcOk.left, rcOk.top} ;
ScreenToClient( hwndDlg, &ptOk) ;
SetWindowPos( hwndOk,
hwndDlg,
ptOk.x,
ptLR.y + OFFS_CTRLS,
0, 0,
SWP_NOSIZE | SWP_NOZORDER) ;
// riposiziono il bottone Cancel
HWND hwndCl = GetDlgItem( hwndDlg, IDCANCEL) ;
RECT rcCl ;
GetWindowRect( hwndCl, &rcCl) ;
POINT ptCl{ rcCl.left, rcCl.top} ;
ScreenToClient( hwndDlg, &ptCl) ;
SetWindowPos( hwndCl,
hwndDlg,
ptCl.x,
ptLR.y + OFFS_CTRLS,
0, 0,
SWP_NOSIZE | SWP_NOZORDER) ;
}
// assegno titolo del dialogo
SetWindowText( hwndDlg, stringtoW( s_sCaption)) ;
// assegno testi e valori di default e nascondo linee dei controlli non usati
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
if ( i < s_nCtrls) {
SetDlgItemText( hwndDlg, IDC_TEXT1 + i, stringtoW( s_sText[i])) ;
if ( s_sEdit[i].find( "CK:") == 0) {
bool bChecked = false ;
FromString( s_sEdit[i].substr( 3), bChecked) ;
CheckDlgButton( hwndDlg, IDC_CHECK1 + i, ( bChecked ? BST_CHECKED : BST_UNCHECKED)) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
s_nType[i] = CTRL_CHECK ;
}
else if ( s_sEdit[i].find( "CB:") == 0) {
string sList = s_sEdit[i].substr( 3) ;
STRVECTOR vsVal ;
Tokenize( sList, ",", vsVal) ;
int nSel = 0 ;
HWND hwndCBox = GetDlgItem( hwndDlg, IDC_COMBO1 + i) ;
for ( int j = 0 ; j < int( vsVal.size()) ; ++ j) {
string sItem ;
if ( vsVal[j][0] == '*') {
nSel = j ;
sItem = vsVal[j].substr( 1) ;
}
else
sItem = vsVal[j] ;
ComboBox_AddString( hwndCBox, stringtoW( sItem)) ;
case WM_INITDIALOG :
{
// colore di default
COLORREF defaultColor = RGB( 255, 0, 0) ;
// inizializzazione colori e brush
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
if ( g_hColorBrush[i]) {
DeleteObject( g_hColorBrush[i]) ;
g_hColorBrush[i] = NULL ;
}
g_selectedColor[i] = defaultColor ;
g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ;
}
// dati del dialogo
HWND hwndOwner = GetParent( hwndDlg) ;
if ( hwndOwner == nullptr)
hwndOwner = GetDesktopWindow() ;
RECT rcOwner, rcDlg ;
GetWindowRect( hwndOwner, &rcOwner) ;
GetWindowRect( hwndDlg, &rcDlg) ;
// determino la posizione dell'ultima riga di dati da visualizzare
HWND hwndLR = GetDlgItem( hwndDlg, IDC_TEXT1 + Clamp( s_nCtrls, 1, MAX_CTRLS) - 1) ;
RECT rcLR ;
GetWindowRect( hwndLR, &rcLR) ;
POINT ptLR{ rcLR.left, rcLR.top} ;
ScreenToClient( hwndDlg, &ptLR) ;
// centro e scalo il dialogo
int nNewH = rcLR.top - rcOwner.top + 2 * OFFS_CTRLS ; // non chiaro perchè va sottratto rcOwner.top ma funziona sempre
SetWindowPos( hwndDlg,
HWND_TOP,
( rcOwner.left + rcOwner.right - ( rcDlg.right - rcDlg.left)) / 2,
( rcOwner.top + rcOwner.bottom - nNewH) / 2,
( rcDlg.right - rcDlg.left),
nNewH,
0) ;
// riposiziono il bottone Ok
HWND hwndOk = GetDlgItem( hwndDlg, IDOK) ;
RECT rcOk ;
GetWindowRect( hwndOk, &rcOk) ;
POINT ptOk{ rcOk.left, rcOk.top} ;
ScreenToClient( hwndDlg, &ptOk) ;
SetWindowPos( hwndOk,
hwndDlg,
ptOk.x,
ptLR.y + OFFS_CTRLS,
0, 0,
SWP_NOSIZE | SWP_NOZORDER) ;
// riposiziono il bottone Cancel
HWND hwndCl = GetDlgItem( hwndDlg, IDCANCEL) ;
RECT rcCl ;
GetWindowRect( hwndCl, &rcCl) ;
POINT ptCl{ rcCl.left, rcCl.top} ;
ScreenToClient( hwndDlg, &ptCl) ;
SetWindowPos( hwndCl,
hwndDlg,
ptCl.x,
ptLR.y + OFFS_CTRLS,
0, 0,
SWP_NOSIZE | SWP_NOZORDER) ;
}
// assegno titolo del dialogo
SetWindowText( hwndDlg, stringtoW( s_sCaption)) ;
// assegno testi e valori di default e nascondo linee dei controlli non usati
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
if ( i < s_nCtrls) {
SetDlgItemText( hwndDlg, IDC_TEXT1 + i, stringtoW( s_sText[i])) ;
if ( s_sEdit[i].find( "CK:") == 0) {
bool bChecked = false ;
FromString( s_sEdit[i].substr( 3), bChecked) ;
CheckDlgButton( hwndDlg, IDC_CHECK1 + i, ( bChecked ? BST_CHECKED : BST_UNCHECKED)) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
s_nType[i] = CTRL_CHECK ;
}
else if ( s_sEdit[i].find( "CB:") == 0) {
string sList = s_sEdit[i].substr( 3) ;
STRVECTOR vsVal ;
Tokenize( sList, ",", vsVal) ;
int nSel = 0 ;
HWND hwndCBox = GetDlgItem( hwndDlg, IDC_COMBO1 + i) ;
for ( int j = 0 ; j < int( vsVal.size()) ; ++ j) {
string sItem ;
if ( vsVal[j][0] == '*') {
nSel = j ;
sItem = vsVal[j].substr( 1) ;
}
else
sItem = vsVal[j] ;
ComboBox_AddString( hwndCBox, stringtoW( sItem)) ;
}
ComboBox_SetCurSel( hwndCBox, nSel) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
s_nType[i] = CTRL_COMBO ;
}
else if ( s_sEdit[i].find( "CP:") == 0) {
string sVal = s_sEdit[i].substr( 3) ;
// recupero eventuale colore di default
if ( ! sVal.empty()) {
// rimuovo eventuale carattere di "#"
if ( sVal[0] == '#')
sVal.erase( 0, 1) ;
// il colore di base deve essere composto da esattamente 6 caratteri
if ( sVal.size() == 6) {
bool bOk = true ;
for ( char c : sVal) {
if ( ! isxdigit( static_cast<unsigned char>(c))) {
bOk = false;
break ;
}
}
if ( bOk) {
try {
unsigned long hex = stoul( sVal, nullptr, 16) ;
BYTE r = ( hex >> 16) & 0xFF ;
BYTE g = ( hex >> 8) & 0xFF ;
BYTE b = hex & 0xFF ;
g_selectedColor[i] = RGB( r, g, b) ;
} catch (...) {}
}
}
}
// nascondo qualsiasi tipo di componente ( per sicurezza)
HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT1 + i) ;
if ( hwndEdit)
ShowWindow( hwndEdit, SW_HIDE) ;
HWND hwndCombo = GetDlgItem( hwndDlg, IDC_COMBO1 + i) ;
if ( hwndCombo)
ShowWindow( hwndCombo, SW_HIDE) ;
HWND hwndChk = GetDlgItem( hwndDlg, IDC_CHECK1 + i) ;
if ( hwndChk)
ShowWindow( hwndChk, SW_HIDE) ;
// margini per dimensione del rettangolo preview pickColor
const int MARGIN_RIGHT = 8 ; // spazio tra preview e bordo destro dialog
const int PREVIEW_HEIGHT = 20 ; // altezza del rettangolo
const int PREVIEW_MIN_WIDTH = 40 ; // larghezza minima
// ottieni o crea la static preview (allargata fino al bordo destro del dialog)
HWND hwndPreview = GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + i) ;
RECT rcLabel ;
HWND hwndLabel = GetDlgItem( hwndDlg, IDC_TEXT1 + i) ;
RECT rcClient ; GetClientRect( hwndDlg, &rcClient) ; // coordinate client del dialog
if ( hwndLabel && GetWindowRect( hwndLabel, &rcLabel)) {
// converti rcLabel in coordinate client
POINT ptLabel = { rcLabel.right, rcLabel.top } ;
ScreenToClient( hwndDlg, &ptLabel) ;
int x = ptLabel.x + 8 ; // distanza dal label
int y = ptLabel.y ;
int width = rcClient.right - x - MARGIN_RIGHT ;
if ( width < PREVIEW_MIN_WIDTH)
width = PREVIEW_MIN_WIDTH ;
if ( ! hwndPreview) {
hwndPreview = CreateWindowEx(
0, L"STATIC", NULL,
WS_CHILD | WS_VISIBLE | SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER,
x, y, width, PREVIEW_HEIGHT,
hwndDlg, ( HMENU)( IDC_STATIC_PREVIEW + i),
GetModuleHandle( NULL), NULL) ;
}
else {
// aggiornamento posizione e dimensione se già esiste
LONG_PTR style = GetWindowLongPtr( hwndPreview, GWL_STYLE) ;
style |= SS_NOTIFY | SS_CENTERIMAGE | WS_BORDER ;
style &= ~SS_OWNERDRAW ;
SetWindowLongPtr( hwndPreview, GWL_STYLE, style) ;
SetWindowPos( hwndPreview, HWND_TOP, x, y, width, PREVIEW_HEIGHT, SWP_SHOWWINDOW | SWP_FRAMECHANGED) ;
}
// pulizia e aggiornamento brush colori
SetWindowText( hwndPreview, L"") ;
if ( g_hColorBrush[i]) {
DeleteObject( g_hColorBrush[i]) ;
g_hColorBrush[i] = NULL ;
}
g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ;
// ridisegno
InvalidateRect( hwndPreview, NULL, TRUE) ;
UpdateWindow( hwndPreview) ;
}
// pulizia elementi testuali
if ( hwndPreview)
SetWindowText( hwndPreview, L"") ;
if ( g_hColorBrush[i]) {
DeleteObject( g_hColorBrush[i]) ;
g_hColorBrush[i] = NULL ;
}
// creazione brush di colori
g_hColorBrush[i] = CreateSolidBrush( g_selectedColor[i]) ;
if ( hwndPreview) {
SetWindowPos( hwndPreview, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) ;
InvalidateRect( hwndPreview, NULL, TRUE) ;
UpdateWindow( hwndPreview) ;
}
s_nType[i] = CTRL_COLOR ;
}
else {
SetDlgItemText( hwndDlg, IDC_EDIT1 + i, stringtoW( s_sEdit[i])) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
s_nType[i] = CTRL_EDIT ;
}
ComboBox_SetCurSel( hwndCBox, nSel) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
s_nType[i] = CTRL_COMBO ;
}
else {
SetDlgItemText( hwndDlg, IDC_EDIT1 + i, stringtoW( s_sEdit[i])) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
s_nType[i] = CTRL_EDIT ;
ShowWindow( GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + i), SW_HIDE) ;
s_nType[i] = CTRL_NONE ;
}
}
else {
ShowWindow( GetDlgItem( hwndDlg, IDC_TEXT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_EDIT1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_COMBO1 + i), SW_HIDE) ;
ShowWindow( GetDlgItem( hwndDlg, IDC_CHECK1 + i), SW_HIDE) ;
s_nType[i] = CTRL_NONE ;
break ;
case WM_CTLCOLORSTATIC :
{
HDC hdcStatic = ( HDC)wParam ;
HWND hwndCtrl = ( HWND)lParam ;
int ctrlId = GetDlgCtrlID( hwndCtrl) ;
if ( ctrlId >= IDC_STATIC_PREVIEW && ctrlId < IDC_STATIC_PREVIEW + MAX_CTRLS) {
int idx = ctrlId - IDC_STATIC_PREVIEW ;
if ( g_hColorBrush[idx] == NULL)
g_hColorBrush[idx] = CreateSolidBrush( g_selectedColor[idx]) ;
SetBkMode( hdcStatic, OPAQUE) ;
SetBkColor( hdcStatic, g_selectedColor[idx]) ;
return ( INT_PTR)g_hColorBrush[idx] ;
}
}
case WM_COMMAND : {
int id = LOWORD( wParam) ;
int code = HIWORD( wParam) ;
// comando di Preview per brush di colori mediante click del mouse
if ( code == STN_CLICKED && id >= IDC_STATIC_PREVIEW && id < IDC_STATIC_PREVIEW + MAX_CTRLS) {
int idx = id - IDC_STATIC_PREVIEW ;
HWND hwndPreview = GetDlgItem( hwndDlg, IDC_STATIC_PREVIEW + idx) ;
if ( ! hwndPreview)
return TRUE ;
// apertura ChooseColor (usa hwndDlg come owner)
CHOOSECOLOR cc = {} ;
cc.lStructSize = sizeof( cc) ;
cc.hwndOwner = hwndDlg ;
cc.lpCustColors = g_customColors ;
cc.rgbResult = g_selectedColor[idx] ;
cc.Flags = CC_FULLOPEN | CC_RGBINIT ;
if ( ChooseColor( &cc)) {
g_selectedColor[idx] = cc.rgbResult ;
if ( g_hColorBrush[idx]) {
DeleteObject( g_hColorBrush[idx]) ;
g_hColorBrush[idx] = NULL ;
}
g_hColorBrush[idx] = CreateSolidBrush( g_selectedColor[idx]) ;
InvalidateRect(hwndPreview, NULL, TRUE) ;
UpdateWindow( hwndPreview) ;
}
return TRUE ;
}
switch ( LOWORD( wParam)) {
case IDOK :
for ( int i = 0 ; i < s_nCtrls ; ++ i) {
AtoWEX<128> wsEdit( "") ;
s_sEdit[i] = "" ;
switch ( s_nType[i]) {
case CTRL_CHECK :
s_sEdit[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK1 + i) == BST_CHECKED ? "1" : "0") ;
break ;
case CTRL_COMBO :
if ( GetDlgItemText( hwndDlg, IDC_COMBO1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit[i] = wstrztoA( wsEdit) ;
break ;
case CTRL_EDIT :
if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit[i] = wstrztoA( wsEdit) ;
break ;
case CTRL_COLOR :
{
COLORREF col = g_selectedColor[i] ;
BYTE r = GetRValue( col), g = GetGValue( col), b = GetBValue( col) ;
char buf[16] ;
sprintf_s( buf, sizeof( buf), "#%02X%02X%02X", r, g, b) ;
s_sEdit[i] = buf ;
break ;
}
}
}
[[fallthrough]] ;
case IDCANCEL : {
// pulizia brush colori
for ( int i = 0 ; i < MAX_CTRLS ; ++ i) {
if ( g_hColorBrush[i]) {
DeleteObject( g_hColorBrush[i]) ;
g_hColorBrush[i] = NULL ;
}
}
EndDialog( hwndDlg, wParam) ;
return TRUE ;
}
}
}
break ;
case WM_COMMAND :
switch ( LOWORD( wParam)) {
case IDOK :
for ( int i = 0 ; i < s_nCtrls ; ++ i) {
AtoWEX<128> wsEdit( "") ;
s_sEdit[i] = "" ;
switch ( s_nType[i]) {
case CTRL_CHECK :
s_sEdit[i] = ( IsDlgButtonChecked( hwndDlg, IDC_CHECK1 + i) == BST_CHECKED ? "1" : "0") ;
break ;
case CTRL_COMBO :
if ( GetDlgItemText( hwndDlg, IDC_COMBO1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit[i] = wstrztoA( wsEdit) ;
break ;
case CTRL_EDIT :
if ( GetDlgItemText( hwndDlg, IDC_EDIT1 + i, LPWSTR( wsEdit), 128) > 0)
s_sEdit[i] = wstrztoA( wsEdit) ;
break ;
}
}
[[fallthrough]] ;
case IDCANCEL :
EndDialog( hwndDlg, wParam) ;
return TRUE ;
}
}
return FALSE ;
}
}
return FALSE ;
}
//-------------------------------------------------------------------------------
static int
+32
View File
@@ -222,6 +222,37 @@ LuaTrimmingGetRuledBezier( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTrimmingInterpolateSyncLines( lua_State* L)
{
// 7 parametri : nParentId, nFirstSyncId, nSecondSyncId, nBorder1Id, nBorder2Id, dEdgeLinTol, dEdgeAngTol
int nParentId ;
LuaCheckParam( L, 1, nParentId) ;
int nSync1Id ;
LuaCheckParam( L, 2, nSync1Id) ;
int nSync2Id ;
LuaCheckParam( L, 3, nSync2Id) ;
int nBorder1Id ;
LuaCheckParam( L, 4, nBorder1Id) ;
int nBorder2Id ;
LuaCheckParam( L, 5, nBorder2Id) ;
double dEdgeLinTol ;
LuaCheckParam( L, 6, dEdgeLinTol) ;
double dEdgeAngTol ;
LuaCheckParam( L, 7, dEdgeAngTol) ;
LuaClearStack( L) ;
// Interpolo le curve di sincronizzazione
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
bool bOk = ExeTrimmingInterpolateSyncLines( nParentId, nSync1Id, nSync2Id, nBorder1Id,
nBorder2Id, dEdgeLinTol, dEdgeAngTol, nFirstId, nCount) ;
LuaSetParam( L, bOk) ;
LuaSetParam( L, nFirstId) ;
LuaSetParam( L, nCount) ;
return 3 ;
}
//-------------------------------------------------------------------------------
static int
LuaTrimmingGetSurfBzSyncPoints( lua_State* L)
@@ -269,6 +300,7 @@ LuaInstallTrimming( LuaMgr& luaMgr)
// --- Recupero Surf Bezier Ruled
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetRuledBezier", LuaTrimmingGetRuledBezier) ;
// --- Recupero linee di sincronizzazione
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingInterpolateSyncLines", LuaTrimmingInterpolateSyncLines) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimmingGetSurfBzSyncPoints", LuaTrimmingGetSurfBzSyncPoints) ;
return bOk ;
}