Merge branch 'main' of https://gitlab.steamware.net/egalware-cadcam/lua/egwwindowlua
This commit is contained in:
@@ -140,6 +140,7 @@ WIN_SELECTION = 'Selection'
|
||||
WIN_SPLITSELECTION = 'SplitSelection'
|
||||
WIN_SASH_OPENING = 'Opening'
|
||||
WIN_AUX = 'Aux'
|
||||
WIN_PREVIEW = 'Preview'
|
||||
|
||||
WIN_BOTTOM = 'Bottom'
|
||||
WIN_BOTTOMRAIL = 'BottomRail'
|
||||
@@ -310,6 +311,7 @@ WIN_JOINT_BR = 'JointBR'
|
||||
WIN_JOINT_TL = 'JointTL'
|
||||
WIN_JOINT_TR = 'JointTR'
|
||||
WIN_STARTJOINT = 'StartJoint'
|
||||
WIN_ENDJOINT = 'EndJoint'
|
||||
|
||||
-- tipi di giunzioni
|
||||
WIN_JNT = {
|
||||
|
||||
@@ -37,6 +37,11 @@ function WinCalculate.SetSimplifiedSolid( bValue)
|
||||
s_bSimplSolid = bValue
|
||||
end
|
||||
|
||||
local s_bCalcPreview = false
|
||||
function WinCalculate.SetCalcPreview( bValue)
|
||||
s_bCalcPreview = bValue
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- funzione che copia la info di chiave sInfo da nSou a nDest
|
||||
local function CopyInfo( nDest, nSou, sInfo, Default)
|
||||
@@ -133,6 +138,8 @@ end
|
||||
-- ne estende/taglia i contorni per ottenere una curva chiusa continua
|
||||
local function TrimAndOrientOrderedCurves( vCrvs, bOrient)
|
||||
|
||||
|
||||
EgtSaveFile( "C:\\Users\\sara.perdoncin\\Desktop\\Prova.nge")
|
||||
local IntersCurveList = {}
|
||||
local LastCurveInters
|
||||
-- ciclo sulle curve per ottenere lista intersezioni
|
||||
@@ -603,6 +610,8 @@ local function CalcProfileType( nAreaId)
|
||||
elseif nAreaType == WIN_AREATYPES.SASH then
|
||||
-- verifico tipologia di anta ( battente, ricevente, alzante scorrevole)
|
||||
local nSashType = EgtGetInfo( nAreaId, WIN_SASHTYPE, 'i') or WIN_SASHTYPES.NULL
|
||||
-- verifico se bottomrail
|
||||
local nBottomRail = EgtGetInfo( nAreaId, WIN_BOTTOMRAIL, 'i') or 0
|
||||
-- imposto profili sash
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
|
||||
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
||||
@@ -612,8 +621,6 @@ local function CalcProfileType( nAreaId)
|
||||
-- se non è definita tipologia
|
||||
if nSashType == WIN_SASHTYPES.NULL then
|
||||
if sName == WIN_BOTTOM then
|
||||
-- verifico se bottomrail
|
||||
local nBottomRail = EgtGetInfo( nAreaId, WIN_BOTTOMRAIL, 'i') or 0
|
||||
if nBottomRail == 0 then
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_FRAME_BOTTOM)
|
||||
else
|
||||
@@ -712,7 +719,12 @@ local function CalcProfileType( nAreaId)
|
||||
-- b) standard
|
||||
else
|
||||
if sName == WIN_BOTTOM then
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_FRAME_BOTTOM)
|
||||
-- verifico se bottomrail
|
||||
if nBottomRail == 0 then
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_FRAME_BOTTOM)
|
||||
else
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_RAIL_BOTTOM)
|
||||
end
|
||||
else
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_FRAME_TOP)
|
||||
end
|
||||
@@ -1210,7 +1222,7 @@ end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- funzione che crea la superficie corrispondente al Geo di un pezzo gestendo i casi di autointersezione
|
||||
local function CreateGeoArea( nGeoLayId, nDestLayId)
|
||||
local function CreateGeoArea( nGeoLayId, nDestLayId, bKeepBorder)
|
||||
|
||||
-- recupero le curve left e right e verifico se hanno orientamento coerente ( quindi non generano autointersezioni)
|
||||
local bAutointers = false
|
||||
@@ -1256,7 +1268,9 @@ local function CreateGeoArea( nGeoLayId, nDestLayId)
|
||||
end
|
||||
|
||||
local nArea = EgtSurfFlatRegion( nDestLayId, nCompoId)
|
||||
EgtErase( nCompoId)
|
||||
if not bKeepBorder then
|
||||
EgtErase( nCompoId)
|
||||
end
|
||||
|
||||
return nArea
|
||||
end
|
||||
@@ -1494,6 +1508,9 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineCrvNbr, nOutlineLayerI
|
||||
-- creo layer per ingombro
|
||||
local nGeoLayerId = EgtGroup( nPartId)
|
||||
EgtSetName( nGeoLayerId, WIN_GEO)
|
||||
if s_bCalcPreview then
|
||||
EgtSetStatus( nGeoLayerId, GDB_ST.OFF)
|
||||
end
|
||||
|
||||
-- recupero outline precedenti e successivi ( solo nel caso di split possono essere più di uno)
|
||||
local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId)
|
||||
@@ -1544,10 +1561,11 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineCrvNbr, nOutlineLayerI
|
||||
nEndPartJointType = WIN_JNT.FULL
|
||||
end
|
||||
|
||||
-- salvo il valore di start joint su outline per calcolo dowels
|
||||
-- salvo il valore dei joints su outline
|
||||
-- se bottomrail è sicuramente short quindi non salvo il valore che sovrascriverebbe quello del pezzo bottom ( che potrebbe essere short o full)
|
||||
if nProfileType ~= WIN_PRF.BOTTOMRAIL and nProfileType ~= WIN_PRF.BOTTOMRAIL_FINAL then
|
||||
EgtSetInfo( nOutlineId, WIN_STARTJOINT, nStartPartJointType)
|
||||
EgtSetInfo( nOutlineId, WIN_ENDJOINT, nEndPartJointType)
|
||||
end
|
||||
|
||||
-- creo il gruppo con i profili del pezzo
|
||||
@@ -2013,7 +2031,7 @@ local function CalcProfilingProcessings( nPartId, nOutlineId)
|
||||
|
||||
-- recupero il geo e creo la superficie associata per limitare le lavorazioni
|
||||
local nGeoLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO)
|
||||
local nSurfGeo = CreateGeoArea( nGeoLayerId, nProcLayerId)
|
||||
local nSurfGeo = CreateGeoArea( nGeoLayerId, nProcLayerId, false)
|
||||
EgtSurfFrOffset( nSurfGeo, 50 * GEO.EPS_SMALL)
|
||||
|
||||
-- recupero il gruppo dei profili
|
||||
@@ -2536,6 +2554,167 @@ end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
--------------------------------- PREVIEW ----------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
local function CalcBottomRailPreview( nPreviewGrp, nOutlineId, nProfileGrp)
|
||||
|
||||
local nBottomRail = EgtGetInfo( nOutlineId, WIN_BOTTOMRAIL, 'i') or 0
|
||||
if nBottomRail == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local nGrp = EgtGroup( nPreviewGrp)
|
||||
|
||||
-- costruisco box complessivo degli zoccoli
|
||||
local nProfileId = EgtGetFirstNameInGroup( nProfileGrp, WIN_PRF_MAIN)
|
||||
local b3Profile = GetProfileLocalBox( nProfileId)
|
||||
local nOutId = EgtCopyGlob( nOutlineId, nGrp)
|
||||
EgtOffsetCurve( nOutId, b3Profile:getMin():getX())
|
||||
|
||||
local vNextOutlines = EgtGetInfo( nOutlineId, WIN_NEXT_OUTLINES, 'vi')
|
||||
local vEndProfiles = EgtGetNameInGroup( nProfileGrp, WIN_PRF_END)
|
||||
local nRightId = EgtCopyGlob( vNextOutlines[1], nGrp)
|
||||
local b3ProfileEnd = GetProfileLocalBox( vEndProfiles[1])
|
||||
EgtOffsetCurve( nRightId, b3ProfileEnd:getMin():getX())
|
||||
|
||||
local nInId = EgtCopyGlob( nOutlineId, nGrp)
|
||||
local dDelta1 = EgtGetInfo( nProfileId, WIN_RAILDELTA .. '1', 'd')
|
||||
local dDelta2 = EgtGetInfo( nProfileId, WIN_RAILDELTA .. '2', 'd')
|
||||
local dOffs = dDelta1 + ( nBottomRail - 1) * dDelta2
|
||||
local nProfileLayer = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_PROFILE)
|
||||
local nAreaLayer = EgtGetParent( EgtGetParent( nOutlineId))
|
||||
local nAreaType = EgtGetInfo( nAreaLayer, WIN_AREATYPE, 'i')
|
||||
local nFrameProfileLayer = EgtGetFirstNameInGroup( nProfileLayer, EgtIf( nAreaType == WIN_AREATYPES.FRAME, WIN_FRAME, WIN_SASH))
|
||||
local nBottomRailProfile = EgtGetFirstNameInGroup( nFrameProfileLayer, WIN_FILL_RAIL)
|
||||
local b3ProfileRail = GetProfileLocalBox( nBottomRailProfile)
|
||||
EgtOffsetCurve( nInId, - dOffs + b3ProfileRail:getMin():getX())
|
||||
|
||||
local vPrevOutlines = EgtGetInfo( nOutlineId, WIN_PREV_OUTLINES, 'vi')
|
||||
local vStartProfiles = EgtGetNameInGroup( nProfileGrp, WIN_PRF_START)
|
||||
local nLeftId = EgtCopyGlob( vPrevOutlines[1], nGrp)
|
||||
local b3ProfileStart = GetProfileLocalBox( vStartProfiles[1])
|
||||
EgtOffsetCurve( nLeftId, b3ProfileStart:getMin():getX())
|
||||
|
||||
TrimAndOrientOrderedCurves( EgtGetAllInGroup( nGrp), true)
|
||||
|
||||
-- creo il bordo e la regione
|
||||
local nAreaId = CreateGeoArea( nGrp, nPreviewGrp, true)
|
||||
local nCrvId = EgtGetPrev( nAreaId or GDB_ID.NULL) or GDB_ID.NULL
|
||||
EgtSetColor( nCrvId, EgtStdColor( 'BLACK'))
|
||||
|
||||
-- creo linee di divisione tra gli zoccoli
|
||||
if nBottomRail > 1 then
|
||||
local dLen = EgtCurveLength( nOutId)
|
||||
local dStep = 1 / nBottomRail
|
||||
for i = 1, nBottomRail - 1 do
|
||||
local pt = EgtUP( nLeftId, i * dStep)
|
||||
local nCrvId = EgtLinePVL( nPreviewGrp, pt, X_AX(), dLen)
|
||||
EgtSetColor( nCrvId, EgtStdColor( 'BLACK'))
|
||||
end
|
||||
end
|
||||
EgtErase( nGrp)
|
||||
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
local function CalcPreview( nPartId, nOutlineId)
|
||||
|
||||
-- creo gruppo per la preview
|
||||
local nPreviewGrp = EgtGroup( nPartId)
|
||||
EgtSetName( nPreviewGrp, WIN_PREVIEW)
|
||||
local nGrpTmp = EgtGroup( nPreviewGrp)
|
||||
|
||||
local nGeoGrp = EgtGetFirstNameInGroup( nPartId, WIN_GEO)
|
||||
local nProfileGrp = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE)
|
||||
|
||||
-- curva out
|
||||
-- è il geo out tranne nel caso di sash active/inactive per le quali considero l'outline per evitare sovrapposizioni
|
||||
local nBaseOutlineId = EgtGetInfo( nOutlineId, WIN_COPY, 'i')
|
||||
local bOnSplit = EgtGetInfo( nBaseOutlineId, WIN_CRV_ON_FRENCH_SPLIT, 'b')
|
||||
if bOnSplit then
|
||||
local nCrv = EgtCopyGlob( nOutlineId, nGrpTmp)
|
||||
EgtSetName( nCrv, WIN_GEO_OUT) -- setto il nome per la funzione CreateGeoArea
|
||||
else
|
||||
local nGeoOut = EgtGetFirstNameInGroup( nGeoGrp, WIN_GEO_OUT)
|
||||
EgtCopyGlob( nGeoOut, nGrpTmp)
|
||||
end
|
||||
|
||||
-- curva right
|
||||
local nEndJoint = EgtGetInfo( nOutlineId, WIN_ENDJOINT, 'i')
|
||||
if nEndJoint == WIN_PART_JNT.SHORT then
|
||||
-- se giunzione short per evitare sovrapposizioni devo fermarla al box del pezzo adiacente
|
||||
local vNextOutlines = EgtGetInfo( nOutlineId, WIN_NEXT_OUTLINES, 'vi')
|
||||
local vEndProfiles = EgtGetNameInGroup( nProfileGrp, WIN_PRF_END)
|
||||
for i = 1, #vNextOutlines do
|
||||
local nCrv = EgtCopyGlob( vNextOutlines[i], nGrpTmp)
|
||||
local b3Profile = GetProfileLocalBox( vEndProfiles[i])
|
||||
local dOffs = b3Profile:getMin():getX()
|
||||
EgtOffsetCurve( nCrv, dOffs)
|
||||
EgtSetName( nCrv, WIN_RIGHT)
|
||||
end
|
||||
else
|
||||
-- altrimenti posso utilizzare la curva del geo
|
||||
local vGeoRight = EgtGetNameInGroup( nGeoGrp, WIN_RIGHT)
|
||||
for i = 1, #vGeoRight do
|
||||
EgtCopyGlob( vGeoRight[i], nGrpTmp)
|
||||
end
|
||||
end
|
||||
|
||||
-- curva in
|
||||
local nGeoIn = EgtGetFirstNameInGroup( nGeoGrp, WIN_GEO_IN)
|
||||
EgtCopyGlob( nGeoIn, nGrpTmp)
|
||||
|
||||
-- curva left
|
||||
local nStartJoint = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i')
|
||||
if nStartJoint == WIN_PART_JNT.SHORT then
|
||||
local vPrevOutlines = EgtGetInfo( nOutlineId, WIN_PREV_OUTLINES, 'vi')
|
||||
local vStartProfiles = EgtGetNameInGroup( nProfileGrp, WIN_PRF_START)
|
||||
for i = 1, #vPrevOutlines do
|
||||
local nCrv = EgtCopyGlob( vPrevOutlines[i], nGrpTmp)
|
||||
local b3Profile = GetProfileLocalBox( vStartProfiles[i])
|
||||
local dOffs = b3Profile:getMin():getX()
|
||||
EgtOffsetCurve( nCrv, dOffs)
|
||||
EgtSetName( nCrv, WIN_LEFT)
|
||||
end
|
||||
else
|
||||
local vGeoLeft = EgtGetNameInGroup( nGeoGrp, WIN_LEFT)
|
||||
for i = 1, #vGeoLeft do
|
||||
EgtCopyGlob( vGeoLeft[i], nGrpTmp)
|
||||
end
|
||||
end
|
||||
|
||||
-- eventuale trim delle curve se non ho considerato tutte le curve del geo
|
||||
if nStartJoint == WIN_PART_JNT.SHORT or nEndJoint == WIN_PART_JNT.SHORT or bOnSplit then
|
||||
TrimAndOrientOrderedCurves( EgtGetAllInGroup( nGrpTmp), true)
|
||||
end
|
||||
|
||||
-- creo il bordo e la regione
|
||||
local nAreaId = CreateGeoArea( nGrpTmp, nPreviewGrp, true)
|
||||
local nCrvId = EgtGetPrev( nAreaId or GDB_ID.NULL) or GDB_ID.NULL
|
||||
EgtSetColor( nCrvId, EgtStdColor( 'BLACK'))
|
||||
EgtErase( nGrpTmp)
|
||||
|
||||
-- se bottom aggiungo anche eventuale preview del bottomrail
|
||||
if EgtGetName( nOutlineId) == WIN_BOTTOM then
|
||||
CalcBottomRailPreview( nPreviewGrp, nOutlineId, nProfileGrp)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
local function CalcFillPreview( nPartId, nOutlineLayerId)
|
||||
-- creo layer per preview
|
||||
local nGrp = EgtGroup( nPartId)
|
||||
EgtSetName( nGrp, WIN_PREVIEW)
|
||||
-- creo compo di outline
|
||||
local vOutlineList = EgtGetAllInGroup( nOutlineLayerId)
|
||||
local nCompoOutlineId = EgtCurveCompoByChain( nGrp, vOutlineList, EgtSP( vOutlineList[1]), false)
|
||||
-- creo area
|
||||
local nSurfId = EgtSurfFlatRegion( nGrp, {nCompoOutlineId})
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
---------------------------------- DOWELS ----------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
@@ -2974,7 +3153,7 @@ local function CalcSplitDowels( nSplitId, vOutlines, bStartOrEnd)
|
||||
|
||||
-- creo la superficie di test per verificare se dowel interno al pezzo
|
||||
local nSplitGeo = EgtGetFirstNameInGroup( nSplitPart, WIN_GEO)
|
||||
local nSplitSurf = CreateGeoArea( nSplitGeo, nSplitLayerId)
|
||||
local nSplitSurf = CreateGeoArea( nSplitGeo, nSplitLayerId, false)
|
||||
|
||||
local ptRef = EgtIf( bStartOrEnd, EgtSP( nSplitId), EgtEP( nSplitId))
|
||||
|
||||
@@ -3068,7 +3247,7 @@ local function CalcSplitDowels( nSplitId, vOutlines, bStartOrEnd)
|
||||
|
||||
-- creo la superficie di test per verificare se dowel interno al pezzo
|
||||
local nGeo = EgtGetFirstNameInGroup( nPartId, WIN_GEO)
|
||||
local nSurf = CreateGeoArea( nGeo, nLayerId)
|
||||
local nSurf = CreateGeoArea( nGeo, nLayerId, false)
|
||||
|
||||
-- aggiungo i dowels
|
||||
local vDowels = EgtGetNameInGroup( nSplitProfile, WIN_DOWEL .. '*') or {}
|
||||
@@ -3519,6 +3698,10 @@ local function CreatePartFromOutline( nAreaLayerId, sName, nOutlineId, nOutlineC
|
||||
CalcProfilingProcessings( nPartId, nOutlineId)
|
||||
-- calcolo il georaw per automatismo lavorazioni
|
||||
CalcGeoRaw( nPartId)
|
||||
-- disegno preview 2D del pezzo
|
||||
if s_bCalcPreview and not nBottomRail then
|
||||
CalcPreview( nPartId, nOutlineId)
|
||||
end
|
||||
-- disegno solido
|
||||
if s_bCalcSolid then
|
||||
CalcSolid( nPartId, nOutlineId)
|
||||
@@ -3544,6 +3727,10 @@ local function CreatePartFromOutline( nAreaLayerId, sName, nOutlineId, nOutlineC
|
||||
|
||||
-- disegno ingombro
|
||||
local nGeoLayerId = CalcFillGeo( nPartId, nOutlineLayerId)
|
||||
-- disegno preview 2D
|
||||
if s_bCalcPreview then
|
||||
CalcFillPreview( nPartId, nOutlineLayerId)
|
||||
end
|
||||
-- disegno solido
|
||||
if s_bCalcSolid then
|
||||
CalcFillSolid( nPartId, nOutlineLayerId, nGeoLayerId)
|
||||
@@ -3594,7 +3781,7 @@ local function CalculateAreaParts( nAreaId)
|
||||
EgtSetName( nSelectionLayerId, WIN_SPLITSELECTION)
|
||||
EgtSetStatus( nSelectionLayerId, GDB_ST.OFF)
|
||||
local nSplitPartGeoId = EgtGetFirstNameInGroup( nSplitPartId, WIN_GEO)
|
||||
local nSelectionArea = CreateGeoArea( nSplitPartGeoId, nSelectionLayerId)
|
||||
local nSelectionArea = CreateGeoArea( nSplitPartGeoId, nSelectionLayerId, false)
|
||||
EgtSetColor( nSelectionArea, 'YELLOW')
|
||||
EgtSetAlpha( nSelectionArea, 10)
|
||||
EgtMove( nSelectionArea, 10 * Z_AX())
|
||||
|
||||
@@ -196,6 +196,12 @@ local function WinCalculate_SetSimplifiedSolid()
|
||||
end
|
||||
_G.WinCalculate_SetSimplifiedSolid = WinCalculate_SetSimplifiedSolid
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
local function WinCalculate_SetCalcPreview()
|
||||
WinCalculate.SetCalcPreview( WDG.VALUE)
|
||||
end
|
||||
_G.WinCalculate_SetCalcPreview = WinCalculate_SetCalcPreview
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
local function WinCalculate_CreatePartFromArea()
|
||||
WinCalculate.CreatePartFromArea( WDG.FRAMEID)
|
||||
|
||||
Reference in New Issue
Block a user