519 lines
23 KiB
Lua
519 lines
23 KiB
Lua
--
|
|
-- EEEEEEEEEE GGGGGG TTTTTTTTTTTTTT
|
|
-- EEEEEEEEEE GGGGGGGGGG TTTTTTTTTTTTTT
|
|
-- EEEE GGGG GGGG TTTT
|
|
-- EEEE GGGG TTTT
|
|
-- EEEEEEE GGGG GGGGGGG TTTT
|
|
-- EEEEEEE GGGG GGGGGGG TTTT
|
|
-- EEEE GGGG GGGG TTTT
|
|
-- EEEE GGGG GGGG TTTT
|
|
-- EEEEEEEEEE GGGGGGGGGG TTTT
|
|
-- EEEEEEEEEE GGGGGG TTTT
|
|
--
|
|
-- by Egalware s.r.l.
|
|
-- Window project software by Egalware s.r.l. 2023/05/02
|
|
|
|
-- Tabella per definizione modulo
|
|
local WinCreate = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
require( 'WinConst')
|
|
|
|
-- funzioni
|
|
|
|
local function AddInfo( nId, sInfo, nVal)
|
|
local vInfo = EgtGetInfo( nId, sInfo, 'vi') or {}
|
|
table.insert( vInfo, nVal)
|
|
EgtSetInfo( nId, sInfo, vInfo)
|
|
end
|
|
|
|
-- funzione che importa il profilo
|
|
function WinCreate.ImportProfile( sProfilePath)
|
|
-- verifico esistenza file
|
|
if not EgtExistsFile( sProfilePath) then
|
|
EgtOutLog( 'File del profilo non trovato! ' .. sProfilePath)
|
|
EgtOutText( 'File del profilo non trovato! ' .. sProfilePath)
|
|
EgtPause(5000)
|
|
return false
|
|
end
|
|
-- creo gruppo per il profilo
|
|
local nProfileId = EgtGroup( GDB_ID.ROOT)
|
|
EgtSetName( nProfileId, WIN_PROFILE)
|
|
-- importo profilo prescelto
|
|
local bOk = EgtInsertFile( sProfilePath)
|
|
-- recupero gruppi importati e li sposto nel gruppo profilo
|
|
local nGroupId = EgtGetFirstInGroup( GDB_ID.ROOT)
|
|
while nGroupId do
|
|
if nGroupId ~= nProfileId then
|
|
local nCurrId = nGroupId
|
|
nGroupId = EgtGetNext( nGroupId)
|
|
EgtRelocateGlob( nCurrId, nProfileId)
|
|
EgtSetStatus( nCurrId, GDB_ST.OFF)
|
|
else
|
|
nGroupId = EgtGetNext( nGroupId)
|
|
end
|
|
end
|
|
-- riporto path nel Part del profilo
|
|
EgtSetInfo( nProfileId, WIN_PROFILEPATH, sProfilePath)
|
|
return true
|
|
end
|
|
|
|
-- funzione che crea il buco rettangolare per la finestra
|
|
function WinCreate.CreateFrame( dWidth, dHeight, nJointBL, nJointBR, nJointTR, nJointTL)
|
|
-- creo gruppo per telaio
|
|
local nFrameAreaId = EgtGroup( GDB_ID.ROOT)
|
|
EgtSetName( nFrameAreaId, WIN_AREA .. '(' .. WIN_FRAME .. ')')
|
|
-- imposto il tipo
|
|
EgtSetInfo( nFrameAreaId, WIN_AREATYPE, WIN_AREATYPES.FRAME)
|
|
local nAreaOutlineLayerId = EgtGroup( nFrameAreaId)
|
|
EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE)
|
|
EgtSetStatus( nAreaOutlineLayerId, GDB_ST.OFF)
|
|
-- disegno outline
|
|
local nFrameBottomId = EgtLine( nAreaOutlineLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
|
|
EgtSetName( nFrameBottomId, WIN_BOTTOM)
|
|
local nFrameRightId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
|
|
EgtSetName( nFrameRightId, WIN_RIGHT)
|
|
local nFrameTopId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0))
|
|
EgtSetName( nFrameTopId, WIN_TOP)
|
|
local nFrameLeftId = EgtLine( nAreaOutlineLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
|
|
EgtSetName( nFrameLeftId, WIN_LEFT)
|
|
-- imposto tipo giunzioni
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BL, nJointBL)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BR, nJointBR)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TL, nJointTL)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TR, nJointTR)
|
|
return nFrameAreaId
|
|
end
|
|
-- funzione che crea il buco per la finestra
|
|
function WinCreate.CreateGenFrame( nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId, nJointBL, nJointBR, nJointTR, nJointTL)
|
|
-- creo gruppo per telaio
|
|
local nFrameAreaId = EgtGroup( GDB_ID.ROOT)
|
|
EgtSetName( nFrameAreaId, WIN_AREA .. '(' .. WIN_FRAME .. ')')
|
|
-- imposto il tipo
|
|
EgtSetInfo( nFrameAreaId, WIN_AREATYPE, WIN_AREATYPES.FRAME)
|
|
local nAreaOutlineLayerId = EgtGroup( nFrameAreaId)
|
|
EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE)
|
|
-- disegno outline
|
|
EgtRelocateGlob( nFrameBottomId, nAreaOutlineLayerId)
|
|
EgtSetName( nFrameBottomId, WIN_BOTTOM)
|
|
EgtRelocateGlob( nFrameRightId, nAreaOutlineLayerId)
|
|
EgtSetName( nFrameRightId, WIN_RIGHT)
|
|
EgtRelocateGlob( nFrameTopId, nAreaOutlineLayerId)
|
|
EgtSetName( nFrameTopId, WIN_TOP)
|
|
EgtRelocateGlob( nFrameLeftId, nAreaOutlineLayerId)
|
|
EgtSetName( nFrameLeftId, WIN_LEFT)
|
|
-- imposto tipo giunzioni
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BL, nJointBL)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BR, nJointBR)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TL, nJointTL)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TR, nJointTR)
|
|
return nFrameAreaId
|
|
end
|
|
|
|
-- -- funzione che crea il telaio a partire dal buco
|
|
-- function WinCreate.CreateFrameOnHole( nHoleLayerId, dWidth, dHeight)
|
|
-- local nAreaOutlineLayerId = EgtGroup( nHoleLayerId)
|
|
-- EgtSetName( nAreaOutlineLayerId, WIN_OUTLINE)
|
|
-- -- disegno outline
|
|
-- local nHoleBottomId = EgtLine( nAreaOutlineLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
|
|
-- EgtSetName( nHoleBottomId, WIN_BOTTOM)
|
|
-- local nHoleRightId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
|
|
-- EgtSetName( nHoleRightId, WIN_RIGHT)
|
|
-- local nHoleTopId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0))
|
|
-- EgtSetName( nHoleTopId, WIN_TOP)
|
|
-- local nHoleLeftId = EgtLine( nAreaOutlineLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
|
|
-- EgtSetName( nHoleLeftId, WIN_LEFT)
|
|
-- end
|
|
|
|
-- funzione che aggiunge una anta
|
|
function WinCreate.AddSash( nAreaId, nJointBL, nJointBR, nJointTR, nJointTL, nSashType)
|
|
-- creo nuova area
|
|
local nSashAreaId = EgtGroup( nAreaId)
|
|
EgtSetName( nSashAreaId, WIN_AREA .. '(' .. WIN_SASH .. ')')
|
|
-- imposto il tipo
|
|
EgtSetInfo( nSashAreaId, WIN_AREATYPE, WIN_AREATYPES.SASH)
|
|
-- recupero outline area precedente
|
|
local nPrevAreaOutlineId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
|
|
-- lo copio per outline area dell'anta
|
|
local nAreaOutlineLayerId = EgtGroup( nSashAreaId)
|
|
EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE)
|
|
local nAreaOutlineId = EgtGetFirstInGroup( nPrevAreaOutlineId)
|
|
while nAreaOutlineId do
|
|
local nOutlineId = EgtCopy( nAreaOutlineId, nAreaOutlineLayerId)
|
|
EgtSetInfo( nOutlineId, WIN_SOU, nAreaOutlineId)
|
|
EgtRemoveInfo( nOutlineId, WIN_CHILD)
|
|
AddInfo( nAreaOutlineId, WIN_CHILD, nOutlineId)
|
|
nAreaOutlineId = EgtGetNext( nAreaOutlineId)
|
|
end
|
|
-- imposto tipo giunzioni
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BL, nJointBL)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BR, nJointBR)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TL, nJointTL)
|
|
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TR, nJointTR)
|
|
-- imposto tipo di anta se presente
|
|
if nSashType then
|
|
EgtSetInfo( nSashAreaId, WIN_SASHTYPE, nSashType)
|
|
end
|
|
return nSashAreaId
|
|
end
|
|
|
|
-- funzione che aggiunge un riempimento
|
|
function WinCreate.AddFill( nAreaId, FillType)
|
|
-- creo nuova area
|
|
local nFillAreaId = EgtGroup( nAreaId)
|
|
EgtSetName( nFillAreaId, WIN_AREA .. '(' .. WIN_FILL .. ')')
|
|
-- imposto il tipo
|
|
EgtSetInfo( nFillAreaId, WIN_AREATYPE, WIN_AREATYPES.FILL)
|
|
-- recupero outline area precedente
|
|
local nPrevAreaOutlineId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
|
|
-- lo copio per outline area del riempimento
|
|
local nAreaOutlineLayerId = EgtGroup( nFillAreaId)
|
|
EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE)
|
|
local nAreaOutlineId = EgtGetFirstInGroup( nPrevAreaOutlineId)
|
|
while nAreaOutlineId do
|
|
local nOutlineId = EgtCopy( nAreaOutlineId, nAreaOutlineLayerId)
|
|
EgtSetInfo( nOutlineId, WIN_SOU, nAreaOutlineId)
|
|
EgtRemoveInfo( nOutlineId, WIN_CHILD)
|
|
AddInfo( nAreaOutlineId, WIN_CHILD, nOutlineId)
|
|
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BL)
|
|
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BR)
|
|
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TL)
|
|
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TR)
|
|
nAreaOutlineId = EgtGetNext( nAreaOutlineId)
|
|
end
|
|
-- imposto tipo di fill
|
|
EgtSetInfo( nFillAreaId, WIN_FILLTYPE, FillType)
|
|
return nFillAreaId
|
|
end
|
|
|
|
-- funzione che crea un taglio split
|
|
function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion, nSplitType)
|
|
-- creo layer temporaneo per split
|
|
local nTempSplitLayerId = EgtGroup( nAreaLayerId)
|
|
EgtSetName( nTempSplitLayerId, WIN_TEMPSPLIT)
|
|
-- recupero contorno area precedente
|
|
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
|
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
|
local OutlineIds = {}
|
|
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
|
while nOutlineId do
|
|
local sName = EgtGetName( nOutlineId)
|
|
table.insert( OutlineIds, nOutlineId)
|
|
nOutlineId = EgtGetNext( nOutlineId)
|
|
end
|
|
local nTotSplitId
|
|
if SplitType == WIN_SPLITORIENTATION.VERTICAL then
|
|
-- creo linea
|
|
local nCalcPosition = 0
|
|
if MeasureType == WIN_MEASURE.ABSOLUT then
|
|
nCalcPosition = nPosition
|
|
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
|
nCalcPosition = b3OutlineLayer:getDimX() / nProportion * nPosition
|
|
elseif MeasureType == WIN_MEASURE.PERCENTAGE then
|
|
nCalcPosition = b3OutlineLayer:getDimX() * nPosition
|
|
end
|
|
nTotSplitId = EgtLine( nTempSplitLayerId, b3OutlineLayer:getMin() + X_AX() * nCalcPosition, b3OutlineLayer:getMin() + X_AX() * nCalcPosition + Y_AX() * b3OutlineLayer:getDimY())
|
|
elseif SplitType == WIN_SPLITORIENTATION.HORIZONTAL then
|
|
-- creo linea
|
|
local nCalcPosition = 0
|
|
if MeasureType == WIN_MEASURE.ABSOLUT then
|
|
nCalcPosition = nPosition
|
|
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
|
nCalcPosition = b3OutlineLayer:getDimY() / nProportion * nPosition
|
|
elseif MeasureType == WIN_MEASURE.PERCENTAGE then
|
|
nCalcPosition = b3OutlineLayer:getDimY() * nPosition
|
|
end
|
|
nTotSplitId = EgtLine( nTempSplitLayerId, b3OutlineLayer:getMin() + Y_AX() * nCalcPosition, b3OutlineLayer:getMin() + Y_AX() * nCalcPosition + X_AX() * b3OutlineLayer:getDimX())
|
|
end
|
|
-- calcolo split
|
|
local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaLayerId, nTotSplitId, nSplitType)
|
|
EgtErase( nTempSplitLayerId)
|
|
return nArea1Id, nArea2Id
|
|
end
|
|
|
|
-- funzione che crea tagli split multipli
|
|
function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList, nProportion, nSplitType)
|
|
local AreaList = {}
|
|
if MeasureType == WIN_MEASURE.ABSOLUT then
|
|
local nResArea1
|
|
local nResArea2 = nAreaLayerId
|
|
for nIndex = 1, #PositionList do
|
|
if nIndex > 1 then
|
|
EgtSetInfo( nResArea2, WIN_PRJ_ORIGSPLIT, nAreaLayerId)
|
|
end
|
|
nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion, nSplitType)
|
|
table.insert( AreaList, nResArea1)
|
|
if nIndex == #PositionList then
|
|
table.insert( AreaList, nResArea2)
|
|
end
|
|
end
|
|
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
|
local nResArea1
|
|
local nResArea2 = nAreaLayerId
|
|
local dAddPosition = 0
|
|
for nIndex = 1, #PositionList do
|
|
if nIndex > 1 then
|
|
EgtSetInfo( nResArea2, WIN_PRJ_ORIGSPLIT, nAreaLayerId)
|
|
end
|
|
nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion - dAddPosition, nSplitType)
|
|
table.insert( AreaList, nResArea1)
|
|
if nIndex == #PositionList then
|
|
table.insert( AreaList, nResArea2)
|
|
end
|
|
dAddPosition = dAddPosition + PositionList[nIndex]
|
|
end
|
|
elseif MeasureType == WIN_MEASURE.PERCENTAGE then
|
|
local nResArea1
|
|
local nResArea2 = nAreaLayerId
|
|
local dAddPosition = 0
|
|
local sChildAreas = ''
|
|
for nIndex = 1, #PositionList do
|
|
if nIndex > 1 then
|
|
EgtSetInfo( nResArea2, WIN_PRJ_ORIGSPLIT, nAreaLayerId)
|
|
sChildAreas = sChildAreas .. nResArea2 .. EgtIf( nIndex < #PositionList, ',', '')
|
|
end
|
|
nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, EgtIf( nIndex == 1, PositionList[nIndex], PositionList[nIndex] / ( 1 - dAddPosition)), nProportion, nSplitType)
|
|
table.insert( AreaList, nResArea1)
|
|
if nIndex == #PositionList then
|
|
table.insert( AreaList, nResArea2)
|
|
end
|
|
dAddPosition = dAddPosition + PositionList[nIndex]
|
|
end
|
|
EgtSetInfo( nAreaLayerId, 'ChildSplit', sChildAreas)
|
|
end
|
|
return AreaList
|
|
end
|
|
|
|
-- funzione che crea un taglio split da una curva generica
|
|
function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
|
-- se area nulla diventa di tipo split
|
|
local nAreaType = EgtGetInfo( nAreaLayerId, WIN_AREATYPE, 'i')
|
|
if nAreaType == WIN_AREATYPES.NULL then
|
|
EgtSetInfo( nAreaLayerId, WIN_AREATYPE, WIN_AREATYPES.SPLIT)
|
|
end
|
|
-- creo layer per split
|
|
local nSplitLayerId = EgtGroup( nAreaLayerId)
|
|
EgtSetName( nSplitLayerId, WIN_BASESPLIT)
|
|
-- sposto curva split nel layer
|
|
EgtRelocateGlob( nSplitId, nSplitLayerId)
|
|
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
|
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
|
-- allungo curva split per cercare intersezioni
|
|
EgtExtendCurveStartByLen( nSplitId, 10)
|
|
EgtExtendCurveEndByLen( nSplitId, 10)
|
|
-- recupero lista intersezioni
|
|
local OutlineInters = {}
|
|
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
|
while nOutlineId do
|
|
local sName = EgtGetName( nOutlineId)
|
|
-- verifico se ci siano intersezioni con questo outline
|
|
local ptInters = EgtIP( nSplitId, nOutlineId, EgtSP( nSplitId))
|
|
if ptInters then
|
|
table.insert( OutlineInters, { Id = nOutlineId, IntersPoint = ptInters})
|
|
end
|
|
nOutlineId = EgtGetNext( nOutlineId)
|
|
end
|
|
local ptStartSplit = EgtSP( nSplitId)
|
|
local ptEndSplit = EgtEP( nSplitId)
|
|
local StartInters
|
|
local EndInters
|
|
for nIndex = 1, #OutlineInters do
|
|
local CurrOutInters = OutlineInters[nIndex]
|
|
CurrOutInters.StartDistance = (CurrOutInters.IntersPoint - ptStartSplit):sqlen()
|
|
CurrOutInters.EndDistance = (CurrOutInters.IntersPoint - ptEndSplit):sqlen()
|
|
if not StartInters or CurrOutInters.StartDistance < StartInters.StartDistance then
|
|
StartInters = CurrOutInters
|
|
end
|
|
if not EndInters or CurrOutInters.EndDistance < EndInters.EndDistance then
|
|
EndInters = CurrOutInters
|
|
end
|
|
end
|
|
-- accorcio la curva split su intersezione outline
|
|
local dStartSplitInters = EgtCurveParamAtPoint( nSplitId, StartInters.IntersPoint)
|
|
EgtTrimCurveStartAtParam( nSplitId, dStartSplitInters)
|
|
local dEndSplitInters = EgtCurveParamAtPoint( nSplitId, EndInters.IntersPoint)
|
|
EgtTrimCurveEndAtParam( nSplitId, dEndSplitInters)
|
|
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, StartInters.Id)
|
|
EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, EndInters.Id)
|
|
-- assegno nome profilo
|
|
EgtSetName( nSplitId, WIN_SPLIT)
|
|
-- creo aree
|
|
local nArea1Id, nArea2Id = WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId)
|
|
-- verifico se discende da Frame
|
|
local nParentAreaId = nAreaLayerId
|
|
local nParentAreaType = nAreaType
|
|
-- recupero parent fino a trovare frame o sash
|
|
while nParentAreaType ~= WIN_AREATYPES.FRAME and nParentAreaType ~= WIN_AREATYPES.SASH do
|
|
nParentAreaId = EgtGetParent( nParentAreaId)
|
|
nParentAreaType = EgtGetInfo( nParentAreaId, WIN_AREATYPE, 'i')
|
|
end
|
|
if nParentAreaType == WIN_AREATYPES.FRAME and nSplitType then
|
|
-- imposto tipo di split
|
|
EgtSetInfo( nSplitLayerId, WIN_SPLITTYPE, nSplitType)
|
|
-- EgtSetInfo( nSplitLayerId, WIN_SPLITTYPE, EgtIf( not nSplitType, WIN_SPLITTYPES.MULLION, nSplitType))
|
|
end
|
|
return nArea1Id, nArea2Id
|
|
end
|
|
|
|
-- funzione che crea tagli split da curve generiche
|
|
function WinCreate.AddGenSplits( nAreaLayerId, SplitList)
|
|
for nIndex = 1, #SplitList do
|
|
WinCreate.AddSplit( nAreaLayerId, SplitList[nIndex])
|
|
end
|
|
end
|
|
|
|
-- funzione che crea le aree da un taglio split
|
|
function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId)
|
|
-- creo layer per le due aree
|
|
local nArea1Id = EgtGroup( nAreaLayerId)
|
|
EgtSetName( nArea1Id , WIN_AREA1)
|
|
EgtSetInfo( nArea1Id, WIN_AREATYPE, WIN_AREATYPES.NULL)
|
|
local nArea1OutlineLayerId = EgtGroup( nArea1Id)
|
|
EgtSetName( nArea1OutlineLayerId , WIN_AREAOUTLINE)
|
|
local nArea2Id = EgtGroup( nAreaLayerId)
|
|
EgtSetName( nArea2Id , WIN_AREA2)
|
|
EgtSetInfo( nArea2Id, WIN_AREATYPE, WIN_AREATYPES.NULL)
|
|
local nArea2OutlineLayerId = EgtGroup( nArea2Id)
|
|
EgtSetName( nArea2OutlineLayerId , WIN_AREAOUTLINE)
|
|
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
|
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
|
local nInters = 0
|
|
while nOutlineId and nInters ~= 3 do
|
|
local sName = EgtGetName( nOutlineId)
|
|
-- calcolo intersezioni con questo outline
|
|
local ptInters = EgtIP( nSplitId, nOutlineId, EgtSP( nSplitId))
|
|
if ptInters then
|
|
if nInters == 0 then
|
|
-- trovato primo punto di intersezione - inizio area 2
|
|
nInters = 1
|
|
local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId)
|
|
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
|
|
EgtRemoveInfo( nCopyId, WIN_CHILD)
|
|
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
|
|
local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
|
EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam)
|
|
elseif nInters == 1 then
|
|
-- trovato secondo punto di intersezione - fine area 2
|
|
nInters = 2
|
|
local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId)
|
|
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
|
|
EgtRemoveInfo( nCopyId, WIN_CHILD)
|
|
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
|
|
local dEndIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
|
EgtTrimCurveEndAtParam( nCopyId, dEndIntersParam)
|
|
-- copio anche split
|
|
local nSplitCopyId = EgtCopy( nSplitId, nArea2OutlineLayerId)
|
|
EgtSetInfo( nSplitCopyId, WIN_SOU, nSplitId)
|
|
EgtRemoveInfo( nSplitCopyId, WIN_CHILD)
|
|
AddInfo( nSplitId, WIN_CHILD, nSplitCopyId)
|
|
EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_STARTINTERS)
|
|
EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_ENDINTERS)
|
|
if not AreSamePointExact( EgtEP( nCopyId), EgtSP( nSplitCopyId)) then
|
|
EgtInvertCurve( nSplitCopyId)
|
|
end
|
|
-- verifico direzione per dare nome
|
|
local vtMedia = ( ( EgtEV( nSplitCopyId) - EgtSV( nSplitCopyId)) / 2)
|
|
if not vtMedia:normalize() then
|
|
vtMedia = EgtSV( nSplitCopyId)
|
|
end
|
|
if abs( vtMedia:getX()) > abs( vtMedia:getY()) then
|
|
EgtSetName( nSplitCopyId, WIN_BOTTOM)
|
|
else
|
|
EgtSetName( nSplitCopyId, WIN_LEFT)
|
|
end
|
|
-- inizio area 1
|
|
nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId)
|
|
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
|
|
EgtRemoveInfo( nCopyId, WIN_CHILD)
|
|
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
|
|
local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
|
EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam)
|
|
elseif nInters == 2 then
|
|
-- trovato secondo punto di intersezione - fine area 1
|
|
nInters = 3
|
|
local nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId)
|
|
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
|
|
EgtRemoveInfo( nCopyId, WIN_CHILD)
|
|
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
|
|
local dEndIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
|
EgtTrimCurveEndAtParam( nCopyId, dEndIntersParam)
|
|
-- copio anche split
|
|
local nSplitCopyId = EgtCopy( nSplitId, nArea1OutlineLayerId)
|
|
EgtRemoveName( nSplitCopyId)
|
|
EgtSetInfo( nSplitCopyId, WIN_SOU, nSplitId)
|
|
EgtRemoveInfo( nSplitCopyId, WIN_CHILD)
|
|
AddInfo( nSplitId, WIN_CHILD, nSplitCopyId)
|
|
EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_STARTINTERS)
|
|
EgtRemoveInfo( nSplitCopyId, WIN_SPLIT_ENDINTERS)
|
|
if not AreSamePointExact( EgtEP( nCopyId), EgtSP( nSplitCopyId)) then
|
|
EgtInvertCurve( nSplitCopyId)
|
|
end
|
|
-- verifico direzione per dare nome
|
|
local vtMedia = ( ( EgtEV( nSplitCopyId) - EgtSV( nSplitCopyId)) / 2)
|
|
if not vtMedia:normalize() then
|
|
vtMedia = EgtSV( nSplitCopyId)
|
|
end
|
|
if abs( vtMedia:getX()) > abs( vtMedia:getY()) then
|
|
EgtSetName( nSplitCopyId, WIN_TOP)
|
|
else
|
|
EgtSetName( nSplitCopyId, WIN_RIGHT)
|
|
end
|
|
end
|
|
elseif nInters == 1 then
|
|
-- copio nel profilo 2
|
|
local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId)
|
|
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
|
|
EgtRemoveInfo( nCopyId, WIN_CHILD)
|
|
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
|
|
elseif nInters == 2 then
|
|
-- copio nel profilo 1
|
|
local nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId)
|
|
EgtSetInfo( nCopyId, WIN_SOU, nOutlineId)
|
|
EgtRemoveInfo( nCopyId, WIN_CHILD)
|
|
AddInfo( nOutlineId, WIN_CHILD, nCopyId)
|
|
end
|
|
-- aggiorno indice
|
|
nOutlineId = EgtGetNext( nOutlineId)
|
|
-- se arrivato alla fine riparto
|
|
if not nOutlineId then
|
|
nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
|
end
|
|
end
|
|
-- scorro pezzi del primo e secondo outline per avere bottom come primo
|
|
local nFirstInAreaId = EgtGetFirstInGroup( nArea1OutlineLayerId)
|
|
local sFirstInAreaName = EgtGetName( nFirstInAreaId)
|
|
while sFirstInAreaName ~= WIN_BOTTOM do
|
|
EgtRelocate( nFirstInAreaId, nArea1OutlineLayerId)
|
|
nFirstInAreaId = EgtGetFirstInGroup( nArea1OutlineLayerId)
|
|
sFirstInAreaName = EgtGetName( nFirstInAreaId)
|
|
end
|
|
nFirstInAreaId = EgtGetFirstInGroup( nArea2OutlineLayerId)
|
|
sFirstInAreaName = EgtGetName( nFirstInAreaId)
|
|
while sFirstInAreaName ~= WIN_BOTTOM do
|
|
EgtRelocate( nFirstInAreaId, nArea2OutlineLayerId)
|
|
nFirstInAreaId = EgtGetFirstInGroup( nArea2OutlineLayerId)
|
|
sFirstInAreaName = EgtGetName( nFirstInAreaId)
|
|
end
|
|
-- error('qqq')
|
|
return nArea1Id, nArea2Id
|
|
end
|
|
|
|
-- funzione che aggiunge uno zoccolo
|
|
function WinCreate.AddBottomRail( nAreaId)
|
|
local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i')
|
|
if nAreaType == WIN_AREATYPES.FRAME then
|
|
-- recupero l'outline bottom
|
|
local nBaseOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
|
|
-- local nBottomOutlineId = EgtGetFirstNameInGroup( nBaseOutlineLayerId, WIN_BOTTOM)
|
|
EgtSetInfo( nBaseOutlineLayerId, WIN_BOTTOMRAIL, 1)
|
|
end
|
|
end
|
|
|
|
function WinCreate.AddHardware( nFrameId, sFavourite)
|
|
EgtSetInfo( nFrameId, WIN_HDW_FAVOURITE, sFavourite )
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
return WinCreate
|