DataWindow :
- modifiche per uniformare struttura jwd con struttura del progetto - gestione numerazione delle aree - correzioni varie.
This commit is contained in:
+399
-402
@@ -28,6 +28,27 @@ local function AddInfo( nId, sInfo, nVal)
|
||||
EgtSetInfo( nId, sInfo, vInfo)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
local function CopyParentOutline( nAreaId, nParentAreaId)
|
||||
-- recupero outline del parent
|
||||
local nParentOutlineLayerId = EgtGetFirstNameInGroup( nParentAreaId, WIN_AREAOUTLINE)
|
||||
local vParentCrvs = EgtGetAllInGroup( nParentOutlineLayerId)
|
||||
-- creo outline per area corrente
|
||||
local nOutlineLayerId = EgtGroup( nAreaId)
|
||||
EgtSetName( nOutlineLayerId, WIN_AREAOUTLINE)
|
||||
-- copio le curve di outline del parent e setto le corrispondenze sou/child
|
||||
for i = 1, #vParentCrvs do
|
||||
local nOutlineId = EgtCopy( vParentCrvs[i], nOutlineLayerId)
|
||||
EgtSetInfo( nOutlineId, WIN_SOU, vParentCrvs[i])
|
||||
EgtSetInfo( vParentCrvs[i], WIN_CHILD, nOutlineId)
|
||||
end
|
||||
return nOutlineLayerId
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
------------------------------------ PROFILO -------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che importa il profilo
|
||||
function WinCreate.ImportProfile( sProfilePath)
|
||||
@@ -61,6 +82,8 @@ function WinCreate.ImportProfile( sProfilePath)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
------------------------------------- TELAIO -------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
@@ -79,7 +102,7 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- lato top inclinato
|
||||
-- lato top inclinato
|
||||
elseif nType == WIN_FRAME_TYPES.CHAMFER_SIDE then
|
||||
-- dHeight è l'altezza del lato sx, dVal è l'altezza del lato dx
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
@@ -91,7 +114,7 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- triangular arch
|
||||
-- triangular arch
|
||||
elseif nType == WIN_FRAME_TYPES.CHAMFER then
|
||||
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
@@ -105,7 +128,7 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- arco a tutto sesto
|
||||
-- arco a tutto sesto
|
||||
elseif nType == WIN_FRAME_TYPES.ROUND_ARC then
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
EgtSetName( nBottomId, WIN_BOTTOM)
|
||||
@@ -116,7 +139,7 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight - 0.5 * dWidth, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- arco ribassato
|
||||
-- arco ribassato
|
||||
elseif nType == WIN_FRAME_TYPES.SEGMENTAL_ARC then
|
||||
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
@@ -128,7 +151,7 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- arco a tutto sesto
|
||||
-- arco a tutto sesto
|
||||
elseif nType == WIN_FRAME_TYPES.POINTED_ARC then
|
||||
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
|
||||
-- verifico che le due altezze abbiano valori sensati per realizzare i due archi
|
||||
@@ -147,7 +170,7 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- triangolo
|
||||
-- triangolo
|
||||
elseif nType == WIN_FRAME_TYPES.TRG then
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
EgtSetName( nBottomId, WIN_BOTTOM)
|
||||
@@ -168,8 +191,8 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea il telaio a partire da una specifica geometria ( rettangolo, chamfer...)
|
||||
function WinCreate.CreateFrame( nType, vJoints, dWidth, dHeight, dHeight2)
|
||||
-- funzione che crea il telaio a partire da una specifica geometria ( rettangolo, chamfer...)
|
||||
function WinCreate.CreateFrame( nType, vJoints, dWidth, dHeight, dHeight2, nAreaNbr)
|
||||
|
||||
-- creo gruppo per telaio
|
||||
local nAreaId = EgtGroup( GDB_ID.ROOT)
|
||||
@@ -185,264 +208,108 @@ function WinCreate.CreateFrame( nType, vJoints, dWidth, dHeight, dHeight2)
|
||||
EgtSetInfo( nAreaId, WIN_FRAME_TYPE, nType)
|
||||
-- imposto tipo giunzioni
|
||||
EgtSetInfo( nOutlineLayerId, WIN_JOINTS, vJoints)
|
||||
|
||||
-- numerazione
|
||||
if nAreaNbr then
|
||||
EgtSetInfo( nAreaId, WIN_AREA_NBR, nAreaNbr)
|
||||
end
|
||||
|
||||
return nAreaId
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-------------------------------------- ANTA --------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che aggiunge una anta
|
||||
function WinCreate.AddSash( nAreaId, vJoints, nSashType, nOpeningType)
|
||||
function WinCreate.AddSash( nParentAreaId, vJoints, nOpeningType, nAreaNbr)
|
||||
|
||||
-- se già presente area errore
|
||||
if EgtGetFirstNameInGroup( nParentAreaId, WIN_AREA .. '*') then
|
||||
return
|
||||
end
|
||||
|
||||
-- creo nuova area
|
||||
local nSashAreaId = EgtGroup( nAreaId)
|
||||
EgtSetName( nSashAreaId, WIN_AREA .. '(' .. WIN_SASH .. ')')
|
||||
local nAreaId = EgtGroup( nParentAreaId)
|
||||
EgtSetName( nAreaId, 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
|
||||
EgtSetInfo( nAreaId, WIN_AREATYPE, WIN_AREATYPES.SASH)
|
||||
-- copio outline dall'area parent
|
||||
local nOutlineLayerId = CopyParentOutline( nAreaId, nParentAreaId)
|
||||
-- imposto tipo giunzioni
|
||||
EgtSetInfo( nAreaOutlineLayerId, WIN_JOINTS, vJoints)
|
||||
-- imposto tipo di anta e di apertura se presente
|
||||
if nSashType then
|
||||
EgtSetInfo( nSashAreaId, WIN_SASHTYPE, nSashType)
|
||||
end
|
||||
EgtSetInfo( nOutlineLayerId, WIN_JOINTS, vJoints)
|
||||
-- imposto apertura se presente
|
||||
if nOpeningType then
|
||||
EgtSetInfo( nSashAreaId, WIN_OPENING_TYPE, nOpeningType)
|
||||
EgtSetInfo( nAreaId, WIN_OPENING_TYPE, nOpeningType)
|
||||
end
|
||||
return nSashAreaId
|
||||
-- numerazione
|
||||
if nAreaNbr then
|
||||
EgtSetInfo( nAreaId, WIN_AREA_NBR, nAreaNbr)
|
||||
EgtSetInfo( nAreaId, WIN_SASH_NBR, 1)
|
||||
end
|
||||
return nAreaId
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che aggiunge un gruppo di ante
|
||||
function WinCreate.AddSashGroup( nParentAreaId, nMeasureType, vDimensions, vJoints, vSashTypes, vOpeningTypes, nAreaNbr, vSashNbrs)
|
||||
|
||||
-- se già presente sottoarea errore
|
||||
if EgtGetFirstNameInGroup( nParentAreaId, WIN_AREA .. '*') then
|
||||
return
|
||||
end
|
||||
|
||||
-- creo gli split di tipo french
|
||||
local vAreas = WinCreate.AddSplits( nParentAreaId, WIN_SPLITORIENTATION.VERTICAL, nMeasureType, vDimensions, true, nAreaNbr)
|
||||
|
||||
-- trasformo le aree risultanti ( che sono null) nelle aree dell'anta settando le info opportune
|
||||
for i = 1, #vAreas do
|
||||
EgtSetName( vAreas[i], EgtGetName( vAreas[i]) .. '(' .. WIN_SASH .. ')')
|
||||
EgtSetInfo( vAreas[i], WIN_AREATYPE, WIN_AREATYPES.SASH)
|
||||
local nOutlineLayId = EgtGetFirstNameInGroup( vAreas[i], WIN_AREAOUTLINE)
|
||||
EgtSetInfo( nOutlineLayId, WIN_JOINTS, vJoints)
|
||||
EgtSetInfo( vAreas[i], WIN_SASHTYPE, vSashTypes[i])
|
||||
EgtSetInfo( vAreas[i], WIN_OPENING_TYPE, vOpeningTypes[i])
|
||||
if vSashNbrs then
|
||||
EgtSetInfo( vAreas[i], WIN_SASH_NBR, vSashNbrs[i])
|
||||
end
|
||||
end
|
||||
return vAreas
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-------------------------------------- FILL --------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
-- 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)
|
||||
nAreaOutlineId = EgtGetNext( nAreaOutlineId)
|
||||
function WinCreate.AddFill( nParentAreaId, nFillType, nAreaNbr)
|
||||
|
||||
-- se area ha già sottoarea errore
|
||||
if EgtGetFirstNameInGroup( nParentAreaId, WIN_AREA .. '*') then
|
||||
return
|
||||
end
|
||||
-- rimuovo eventuali info di giunzioni
|
||||
EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINTS)
|
||||
|
||||
|
||||
local nAreaId = EgtGroup( nParentAreaId)
|
||||
EgtSetName( nAreaId, WIN_AREA .. '(' .. WIN_FILL .. ')')
|
||||
EgtSetInfo( nAreaId, WIN_AREATYPE, WIN_AREATYPES.FILL)
|
||||
-- copio outline dall'area parent
|
||||
CopyParentOutline( nAreaId, nParentAreaId)
|
||||
-- imposto tipo di fill
|
||||
EgtSetInfo( nFillAreaId, WIN_FILLTYPE, FillType)
|
||||
return nFillAreaId
|
||||
EgtSetInfo( nAreaId, WIN_FILLTYPE, nFillType)
|
||||
-- numerazione
|
||||
if nAreaNbr then
|
||||
EgtSetInfo( nAreaId, WIN_AREA_NBR, nAreaNbr)
|
||||
end
|
||||
|
||||
return nAreaId
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
------------------------------------- SPLIT --------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea un taglio split
|
||||
function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion, nSplitType)
|
||||
-- creo layer temporaneo per split
|
||||
local nTempSplitLayerId = EgtGroup( nAreaLayerId)
|
||||
-- recupero contorno area precedente
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
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
|
||||
if nCalcPosition > b3OutlineLayer:getDimX() - GEO.EPS_SMALL then
|
||||
EgtErase( nTempSplitLayerId)
|
||||
return
|
||||
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
|
||||
if nCalcPosition > b3OutlineLayer:getDimY() - GEO.EPS_SMALL then
|
||||
EgtErase( nTempSplitLayerId)
|
||||
return
|
||||
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
|
||||
local nCurrentResArea2 = nResArea2
|
||||
nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion, nSplitType)
|
||||
if not nResArea2 then
|
||||
table.insert( AreaList, nCurrentResArea2)
|
||||
break
|
||||
end
|
||||
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 - 1 do
|
||||
if nIndex > 1 then
|
||||
EgtSetInfo( nResArea2, WIN_PRJ_ORIGSPLIT, nAreaLayerId)
|
||||
end
|
||||
local nCurrentResArea2 = nResArea2
|
||||
nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, PositionList[nIndex], nProportion - dAddPosition, nSplitType)
|
||||
if not nResArea2 then
|
||||
table.insert( AreaList, nCurrentResArea2)
|
||||
break
|
||||
end
|
||||
table.insert( AreaList, nResArea1)
|
||||
if nIndex == #PositionList -1 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
|
||||
local nCurrentResArea2 = nResArea2
|
||||
nResArea1, nResArea2 = WinCreate.AddSplit( nResArea2, SplitType, MeasureType, EgtIf( nIndex == 1, PositionList[nIndex], PositionList[nIndex] / ( 1 - dAddPosition)), nProportion, nSplitType)
|
||||
if not nResArea2 then
|
||||
table.insert( AreaList, nCurrentResArea2)
|
||||
break
|
||||
end
|
||||
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 tagli split grid
|
||||
function WinCreate.AddGridSplits( nAreaLayerId, MeasureType, PositionListVert, PositionListHoriz, bStartVertical, nSplitType)
|
||||
local AreaResult = {}
|
||||
-- recupero contorno area precedente
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
-- calcolo numero parti totali nel caso di misura proporzionale
|
||||
local nProportionVert = 0
|
||||
local nProportionHoriz = 0
|
||||
if MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
for i = 1, #PositionListVert do
|
||||
nProportionVert = nProportionVert + PositionListVert[i]
|
||||
end
|
||||
for i = 1, #PositionListHoriz do
|
||||
nProportionHoriz = nProportionHoriz + PositionListHoriz[i]
|
||||
end
|
||||
end
|
||||
-- calcolo gli split nella direzione secondaria
|
||||
local PositionAbs = {}
|
||||
local PositionList = EgtIf( bStartVertical, PositionListHoriz, PositionListVert)
|
||||
local nProportion = EgtIf( bStartVertical, nProportionHoriz, nProportionVert)
|
||||
local dDim = EgtIf( bStartVertical, b3OutlineLayer:getDimY(), b3OutlineLayer:getDimX())
|
||||
for i = 1, #PositionList do
|
||||
if MeasureType == WIN_MEASURE.ABSOLUT then
|
||||
PositionAbs[i] = PositionList[i]
|
||||
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
PositionAbs[i] = dDim / nProportion * PositionList[i]
|
||||
elseif MeasureType == WIN_MEASURE.PERCENTAGE then
|
||||
PositionAbs[i] = dDim * PositionList[i]
|
||||
end
|
||||
end
|
||||
if bStartVertical then
|
||||
local AreaList = WinCreate.AddSplits( nAreaLayerId, WIN_SPLITORIENTATION.VERTICAL, MeasureType, PositionListVert, nProportionVert, nSplitType)
|
||||
for i = 1, #AreaList do
|
||||
local AreaTemp = WinCreate.AddSplits( AreaList[i], WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, PositionAbs, nProportionHoriz, nSplitType) or {}
|
||||
for j = 1, #AreaTemp do
|
||||
table.insert( AreaResult, AreaTemp[j])
|
||||
end
|
||||
end
|
||||
else
|
||||
local AreaList = WinCreate.AddSplits( nAreaLayerId, WIN_SPLITORIENTATION.HORIZONTAL, MeasureType, PositionListHoriz, nProportionHoriz, nSplitType)
|
||||
for i = 1, #AreaList do
|
||||
-- recupero contorno area corrente
|
||||
local nCurrentOutlineLayerId = EgtGetFirstNameInGroup( AreaList[i], WIN_AREAOUTLINE)
|
||||
local b3CurrentOutlineLayer = EgtGetBBox( nCurrentOutlineLayerId, GDB_BB.STANDARD)
|
||||
local dDiff = b3OutlineLayer:getMin():getX() - b3CurrentOutlineLayer:getMin():getX()
|
||||
if dDiff < - GEO.EPS_SMALL then
|
||||
local nFirstIndex = #PositionAbs + 1
|
||||
for k = 1, #PositionAbs do
|
||||
if PositionAbs[k] + dDiff > GEO.EPS_SMALL then
|
||||
PositionAbs[k] = PositionAbs[k] + dDiff
|
||||
nFirstIndex = k
|
||||
break
|
||||
elseif k ~= #PositionAbs then
|
||||
PositionAbs[k + 1] = PositionAbs[k] + PositionAbs[k + 1]
|
||||
end
|
||||
end
|
||||
for k = 1, nFirstIndex - 1 do
|
||||
table.remove( PositionAbs, 1)
|
||||
end
|
||||
end
|
||||
local AreaTemp = WinCreate.AddSplits( AreaList[i], WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, PositionAbs, nProportionVert, nSplitType) or {}
|
||||
for j = 1, #AreaTemp do
|
||||
table.insert( AreaResult, AreaTemp[j])
|
||||
end
|
||||
end
|
||||
end
|
||||
return AreaResult
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che assegna il nome alla curva di split nella sottoarea in base alla sua direzione
|
||||
local function SetSplitName( nSplitId)
|
||||
@@ -467,155 +334,21 @@ local function SetSplitName( nSplitId)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea le aree da un taglio split
|
||||
local function CreateAreaFromSplit( nAreaLayerId, nCompo, nSplitId, dPar1, dPar2, vOutlineCrvs)
|
||||
|
||||
-- creo layer per le due sottoaree
|
||||
local nArea1Id = EgtGroup( nAreaLayerId)
|
||||
EgtSetName( nArea1Id , WIN_AREA .. '1')
|
||||
EgtSetInfo( nArea1Id, WIN_AREATYPE, WIN_AREATYPES.NULL)
|
||||
local nArea1OutlineLayerId = EgtGroup( nArea1Id)
|
||||
EgtSetName( nArea1OutlineLayerId , WIN_AREAOUTLINE)
|
||||
local nArea2Id = EgtGroup( nAreaLayerId)
|
||||
EgtSetName( nArea2Id , WIN_AREA .. '2')
|
||||
EgtSetInfo( nArea2Id, WIN_AREATYPE, WIN_AREATYPES.NULL)
|
||||
local nArea2OutlineLayerId = EgtGroup( nArea2Id)
|
||||
EgtSetName( nArea2OutlineLayerId , WIN_AREAOUTLINE)
|
||||
|
||||
-- ad ogni sottoarea associo la porzione di curva composita corrispondente
|
||||
local nCrv1 = EgtCopyGlob( nCompo, nArea1OutlineLayerId)
|
||||
local nCrv2 = EgtCopyGlob( nCompo, nArea2OutlineLayerId)
|
||||
EgtTrimCurveStartEndAtParam( nCrv1, dPar2, dPar1)
|
||||
EgtTrimCurveStartEndAtParam( nCrv2, dPar1, dPar2)
|
||||
|
||||
-- copio curva di split
|
||||
local nSplitId1 = EgtCopyGlob( nSplitId, nArea1OutlineLayerId)
|
||||
local nSplitId2 = EgtCopyGlob( nSplitId, nArea2OutlineLayerId)
|
||||
-- verifico se necessaria inversione
|
||||
if AreSamePointApprox( EgtSP( nSplitId1), EgtSP( nCrv1)) then
|
||||
EgtInvertCurve( nSplitId1)
|
||||
end
|
||||
if AreSamePointApprox( EgtSP( nSplitId2), EgtSP( nCrv2)) then
|
||||
EgtInvertCurve( nSplitId2)
|
||||
end
|
||||
-- assegno il nome in base alla direzione
|
||||
SetSplitName( nSplitId1)
|
||||
SetSplitName( nSplitId2)
|
||||
-- assengo le info di source e child
|
||||
EgtSetInfo( nSplitId, WIN_CHILD, { nSplitId1, nSplitId2})
|
||||
EgtSetInfo( nSplitId1, WIN_SOU, nSplitId)
|
||||
EgtSetInfo( nSplitId2, WIN_SOU, nSplitId)
|
||||
|
||||
-- spezzo le curve composite per riottenere le curve originarie di partenza
|
||||
local nFirst1, nCnt1 = EgtExplodeCurveCompo( nCrv1)
|
||||
local nFirst2, nCnt2 = EgtExplodeCurveCompo( nCrv2)
|
||||
-- assegno nome e info
|
||||
local vCrvs = EgtTableFill( nFirst1, nCnt1)
|
||||
EgtTableAdd( vCrvs, nFirst2, nCnt2)
|
||||
for i = 1, #vCrvs do
|
||||
-- ricavo la curva di outline originale da cui deriva
|
||||
local ptM = EgtMP( vCrvs[i])
|
||||
for j = 1, #vOutlineCrvs do
|
||||
if EgtCurveParamAtPoint( vOutlineCrvs[j], ptM, 100 * GEO.EPS_SMALL) then
|
||||
-- ne prendo il nome
|
||||
EgtSetName( vCrvs[i], EgtGetName( vOutlineCrvs[j]))
|
||||
-- assegno le info di child e source
|
||||
EgtSetInfo( vCrvs[i], WIN_SOU, vOutlineCrvs[j])
|
||||
AddInfo( vOutlineCrvs[j], WIN_CHILD, vCrvs[i])
|
||||
break
|
||||
end
|
||||
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
|
||||
|
||||
return nArea1Id, nArea2Id
|
||||
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)
|
||||
-- assegno nome profilo
|
||||
EgtSetName( nSplitId, WIN_SPLIT)
|
||||
|
||||
-- verifico se devo impostare tipo di split ( solo se deriva da tipo frame)
|
||||
if nSplitType then
|
||||
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 then
|
||||
-- imposto tipo di split
|
||||
EgtSetInfo( nSplitLayerId, WIN_SPLITTYPE, nSplitType)
|
||||
end
|
||||
end
|
||||
|
||||
-- Ricerca delle intersezioni :
|
||||
-- creo una curva composita a partire da tutte le curve di outline
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
local vOutlineCrvs = EgtGetAllInGroup( nOutlineLayerId)
|
||||
local nCompo = EgtCurveCompo( nSplitLayerId, vOutlineCrvs, false)
|
||||
-- allungo curva split per cercare intersezioni
|
||||
-- funzione che taglia lo split con il bordo della regione
|
||||
local function AdjustSplitCurve( nSplitId, nCompo, vOutlineCrvs, nOutlineLayerId)
|
||||
|
||||
-- trimmo lo split a filo con l'outline
|
||||
EgtExtendCurveStartByLen( nSplitId, 10)
|
||||
EgtExtendCurveEndByLen( nSplitId, 10)
|
||||
-- trovo intersezioni tra composita e lo split
|
||||
local nFirst, nPntCnt, nCrvCnt = EgtCurveCurveInters( nCompo, nSplitId, nSplitLayerId)
|
||||
if nCrvCnt ~= 0 or nPntCnt ~= 2 then
|
||||
-- errore
|
||||
return
|
||||
end
|
||||
-- recupero i due punti di intersezione
|
||||
local pt1 = EgtSP( nFirst)
|
||||
local pt2 = EgtSP( nFirst + 1)
|
||||
EgtErase( { nFirst, nFirst + 1})
|
||||
|
||||
-- recupero i parametri di intersezione sulla curva di split
|
||||
local dSplitParS = EgtCurveParamAtPoint( nSplitId, pt1, 100 * GEO.EPS_SMALL)
|
||||
local dSplitParE = EgtCurveParamAtPoint( nSplitId, pt2, 100 * GEO.EPS_SMALL)
|
||||
-- recupero i parametri di intersezione sulla curva composita
|
||||
local dPar1 = EgtCurveParamAtPoint( nCompo, pt1, 100 * GEO.EPS_SMALL)
|
||||
local dPar2 = EgtCurveParamAtPoint( nCompo, pt2, 100 * GEO.EPS_SMALL)
|
||||
|
||||
-- ricavo i parametri di intersezione legati a start ed end dello split
|
||||
local dParCrvS = dPar1
|
||||
local dParCrvE = dPar2
|
||||
if dSplitParS > dSplitParE then
|
||||
dSplitParS, dSplitParE = dSplitParE, dSplitParS
|
||||
dParCrvS, dParCrvE = dParCrvE, dParCrvS
|
||||
end
|
||||
|
||||
-- taglio la curva di split nei punti di intersezione
|
||||
EgtTrimCurveStartEndAtParam( nSplitId, dSplitParS, dSplitParE)
|
||||
|
||||
-- setto info per intersezione start
|
||||
-- se il parametro è intero allora l'intersezione coinvolge due curve successive
|
||||
local ptS = EgtIP( nSplitId, nCompo, EgtSP( nSplitId))
|
||||
local ptE = EgtIP( nSplitId, nCompo, EgtEP( nSplitId))
|
||||
local dParS = EgtCurveParamAtPoint( nSplitId, ptS)
|
||||
local dParE = EgtCurveParamAtPoint( nSplitId, ptE)
|
||||
EgtTrimCurveStartEndAtParam( nSplitId, dParS, dParE)
|
||||
|
||||
-- recupero le curve con cui avviene l'intersezione e le salvo come info
|
||||
-- start
|
||||
local dParCrvS = EgtCurveParamAtPoint( nCompo, ptS)
|
||||
if abs( dParCrvS - ceil( dParCrvS)) < GEO.EPS_SMALL then
|
||||
local nCrv = vOutlineCrvs[ ceil( dParCrvS) + 1]
|
||||
local nOther = EgtGetPrev( nCrv) or EgtGetLastInGroup( nOutlineLayerId)
|
||||
@@ -629,8 +362,9 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
local nCrv = vOutlineCrvs[ floor( dParCrvS) + 1]
|
||||
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { nCrv})
|
||||
end
|
||||
|
||||
-- setto info per intersezione end
|
||||
|
||||
-- end
|
||||
local dParCrvE = EgtCurveParamAtPoint( nCompo, ptE)
|
||||
if abs( dParCrvE - ceil( dParCrvE)) < GEO.EPS_SMALL then
|
||||
local nCrv = vOutlineCrvs[ ceil( dParCrvE) + 1]
|
||||
local nOther = EgtGetPrev( nCrv) or EgtGetLastInGroup( nOutlineLayerId)
|
||||
@@ -643,24 +377,287 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
local nCrv = vOutlineCrvs[ floor( dParCrvE) + 1]
|
||||
EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, { nCrv})
|
||||
end
|
||||
|
||||
-- creo sottoaree
|
||||
local nArea1, nArea2 = CreateAreaFromSplit( nAreaLayerId, nCompo, nSplitId, dPar1, dPar2, vOutlineCrvs)
|
||||
|
||||
EgtErase( nCompo)
|
||||
|
||||
return nArea1, nArea2
|
||||
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea tagli split da curve generiche
|
||||
function WinCreate.AddGenSplits( nAreaLayerId, SplitList)
|
||||
for nIndex = 1, #SplitList do
|
||||
WinCreate.AddSplit( nAreaLayerId, SplitList[nIndex])
|
||||
-- funzione che restituisce il bordo delle due regioni definite da uno split
|
||||
local function GetBorderRegions( nSplitId, nCompo, nAreaId)
|
||||
|
||||
-- taglio il bordo in due in corrispondenza dello split
|
||||
local nCrv1 = EgtCopyGlob( nCompo, nAreaId)
|
||||
local nCrv2 = EgtCopyGlob( nCompo, nAreaId)
|
||||
local dPar1 = EgtCurveParamAtPoint( nCompo, EgtSP( nSplitId), 100 * GEO.EPS_SMALL)
|
||||
local dPar2 = EgtCurveParamAtPoint( nCompo, EgtEP( nSplitId), 100 * GEO.EPS_SMALL)
|
||||
EgtTrimCurveStartEndAtParam( nCrv1, dPar2, dPar1)
|
||||
EgtTrimCurveStartEndAtParam( nCrv2, dPar1, dPar2)
|
||||
|
||||
-- aggiungo la curva di split al bordo per chiuderlo orientandola opportunamente
|
||||
local nSplitId1 = EgtCopyGlob( nSplitId, nAreaId)
|
||||
if AreSamePointApprox( EgtSP( nSplitId1), EgtSP( nCrv1)) then
|
||||
EgtInvertCurve( nSplitId1)
|
||||
end
|
||||
EgtAddCurveCompoCurve( nCrv1, nSplitId1)
|
||||
local _, dParE1 = EgtCurveDomain( nCrv1)
|
||||
EgtCurveCompoSetTempProp( nCrv1, dParE1 - 1, nSplitId)
|
||||
|
||||
local nSplitId2 = EgtCopyGlob( nSplitId, nAreaId)
|
||||
if AreSamePointApprox( EgtSP( nSplitId2), EgtSP( nCrv2)) then
|
||||
EgtInvertCurve( nSplitId2)
|
||||
end
|
||||
EgtAddCurveCompoCurve( nCrv2, nSplitId2)
|
||||
local _, dParE2 = EgtCurveDomain( nCrv2)
|
||||
EgtCurveCompoSetTempProp( nCrv2, dParE2 - 1, nSplitId)
|
||||
|
||||
return nCrv1, nCrv2
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea le aree generate da una sequenza di curve di split
|
||||
local function CreateAreasFromSplits( nAreaId, vSplitCrvs)
|
||||
|
||||
local nGrpTmp = EgtGroup( nAreaId)
|
||||
|
||||
-- creo la curva composita dell'outline
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
|
||||
local vOutlineCrvs = EgtGetAllInGroup( nOutlineLayerId)
|
||||
local nCompo = EgtCurveCompo( nGrpTmp, vOutlineCrvs, false)
|
||||
for i = 1, #vOutlineCrvs do
|
||||
EgtCurveCompoSetTempProp( nCompo, i - 1, vOutlineCrvs[i])
|
||||
end
|
||||
|
||||
-- creo le curve associate ad ogni regione degli split
|
||||
local vBorders = {}
|
||||
local nCompoRef = nCompo
|
||||
for i = 1, #vSplitCrvs do
|
||||
|
||||
-- aggiusto lo split per averlo a filo con l'outline
|
||||
AdjustSplitCurve( vSplitCrvs[i], nCompo, vOutlineCrvs, nOutlineLayerId)
|
||||
|
||||
-- calcolo i bordi delle due regioni definite dallo split
|
||||
local nCrv1, nCrv2 = GetBorderRegions( vSplitCrvs[i], nCompoRef, nGrpTmp)
|
||||
table.insert( vBorders, nCrv1)
|
||||
-- il secondo bordo è quello da suddividere con lo split successivo ( se esiste)
|
||||
nCompoRef = nCrv2
|
||||
if i == #vSplitCrvs then
|
||||
table.insert( vBorders, nCrv2)
|
||||
end
|
||||
end
|
||||
|
||||
-- creo le sottoaree a partire dai contorni
|
||||
local vAreas = {}
|
||||
for i = 1, #vBorders do
|
||||
-- creo area
|
||||
local nSplitAreaId = EgtGroup( nAreaId)
|
||||
EgtSetName( nSplitAreaId , WIN_AREA .. tostring( i))
|
||||
EgtSetInfo( nSplitAreaId, WIN_AREATYPE, WIN_AREATYPES.NULL)
|
||||
vAreas[i] = nSplitAreaId
|
||||
|
||||
-- creo outline con la curva di bordo
|
||||
local nOutlineLayerId = EgtGroup( nSplitAreaId)
|
||||
EgtSetName( nOutlineLayerId, WIN_AREAOUTLINE)
|
||||
EgtRelocateGlob( vBorders[i], nOutlineLayerId)
|
||||
local vOrigCrvs = EgtCurveCompoGetTempProp( vBorders[i])
|
||||
local nFirst, nCnt = EgtExplodeCurveCompo( vBorders[i])
|
||||
|
||||
-- assegno nome e info a tutte le curve di bordo a partire dalla curva da cui derviano ( salvata nella temp prop della curva)
|
||||
for j = 0, nCnt - 1 do
|
||||
-- assegno le info di child e source
|
||||
EgtSetInfo( nFirst + j, WIN_SOU, vOrigCrvs[j+1])
|
||||
AddInfo( vOrigCrvs[j+1], WIN_CHILD, nFirst + j)
|
||||
-- assengo il nome : se deriva da outline lo copio, se deriva da split lo scelgo in base all'orientamento
|
||||
if EgtGetName( vOrigCrvs[j+1]) == WIN_SPLIT then
|
||||
SetSplitName( nFirst + j)
|
||||
else
|
||||
EgtSetName( nFirst + j, EgtGetName( vOrigCrvs[j+1]))
|
||||
end
|
||||
end
|
||||
|
||||
-- riordino le curve dell'outline per avere bottom come primo
|
||||
local nCrvId = EgtGetFirstInGroup( nOutlineLayerId)
|
||||
while EgtGetName( nCrvId) ~= WIN_BOTTOM do
|
||||
EgtRelocate( nCrvId, nOutlineLayerId)
|
||||
nCrvId = EgtGetFirstInGroup( nOutlineLayerId)
|
||||
end
|
||||
end
|
||||
|
||||
EgtErase( nGrpTmp)
|
||||
return vAreas
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
local function CalcSplitCurves( nLayerId, b3OutlineLayer, b3Limit, nSplitType, nMeasureType, PositionList)
|
||||
|
||||
local vSplitCurves = {}
|
||||
local nProportion = 0
|
||||
if nMeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
for i = 1, #PositionList do
|
||||
nProportion = nProportion + PositionList[i]
|
||||
end
|
||||
end
|
||||
local dCurrPosition = 0
|
||||
for i = 1, #PositionList do
|
||||
-- calcolo la posizione corrente
|
||||
dCurrPosition = dCurrPosition + PositionList[i]
|
||||
local dCalcPosition
|
||||
local nSplitCrv
|
||||
|
||||
if nSplitType == WIN_SPLITORIENTATION.VERTICAL then
|
||||
-- aree ordinate da sx a dx
|
||||
if nMeasureType == WIN_MEASURE.ABSOLUT then
|
||||
dCalcPosition = dCurrPosition
|
||||
elseif nMeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
dCalcPosition = b3OutlineLayer:getDimX() * dCurrPosition / nProportion
|
||||
elseif nMeasureType == WIN_MEASURE.PERCENTAGE then
|
||||
dCalcPosition = b3OutlineLayer:getDimX() * dCurrPosition
|
||||
end
|
||||
-- creo la linea se rientra nella regione limite
|
||||
local dX = b3OutlineLayer:getMin():getX() + dCalcPosition
|
||||
if dX > b3Limit:getMin():getX() + GEO.EPS_SMALL and dX < b3Limit:getMax():getX() - GEO.EPS_SMALL then
|
||||
nSplitCrv = EgtLinePVL( nLayerId, b3OutlineLayer:getMin() + X_AX() * dCalcPosition, Y_AX(), b3OutlineLayer:getDimY())
|
||||
end
|
||||
|
||||
elseif nSplitType == WIN_SPLITORIENTATION.HORIZONTAL then
|
||||
-- aree ordinate dall'alto al basso
|
||||
if nMeasureType == WIN_MEASURE.ABSOLUT then
|
||||
dCalcPosition = b3OutlineLayer:getDimY() - dCurrPosition
|
||||
elseif nMeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
dCalcPosition = b3OutlineLayer:getDimY() * ( 1 - dCurrPosition / nProportion)
|
||||
elseif nMeasureType == WIN_MEASURE.PERCENTAGE then
|
||||
dCalcPosition = b3OutlineLayer:getDimY() * ( 1 - dCurrPosition)
|
||||
end
|
||||
-- creo la linea se rientra nella regione limite
|
||||
local dY = b3OutlineLayer:getMin():getY() + dCalcPosition
|
||||
if dY > b3Limit:getMin():getY() + GEO.EPS_SMALL and dY < b3Limit:getMax():getY() - GEO.EPS_SMALL then
|
||||
nSplitCrv = EgtLinePVL( nLayerId, b3OutlineLayer:getMin() + Y_AX() * dCalcPosition, X_AX(), b3OutlineLayer:getDimX())
|
||||
end
|
||||
end
|
||||
|
||||
if nSplitCrv then
|
||||
EgtSetName( nSplitCrv, WIN_SPLIT)
|
||||
table.insert( vSplitCurves, nSplitCrv)
|
||||
end
|
||||
end
|
||||
|
||||
return vSplitCurves
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea tagli split multipli
|
||||
function WinCreate.AddSplits( nParentAreaId, nSplitType, nMeasureType, PositionList, bFrench, nAreaNbr)
|
||||
|
||||
-- se area ha già sottoarea errore
|
||||
if EgtGetFirstNameInGroup( nParentAreaId, WIN_AREA .. '*') then
|
||||
return
|
||||
end
|
||||
|
||||
-- creo area di split
|
||||
local nAreaId = EgtGroup( nParentAreaId)
|
||||
EgtSetInfo( nAreaId, WIN_AREATYPE, WIN_AREATYPES.SPLIT)
|
||||
EgtSetName( nAreaId, WIN_AREA .. '(' .. WIN_SPLIT .. ')')
|
||||
if nAreaNbr then
|
||||
EgtSetInfo( nAreaId, WIN_AREA_NBR, nAreaNbr)
|
||||
end
|
||||
|
||||
-- copio il contorno dall'area parent e setto opportune corrispondenze sou/child
|
||||
local nOutlineLayerId = CopyParentOutline( nAreaId, nParentAreaId)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
|
||||
-- creo layer per split
|
||||
local nSplitLayerId = EgtGroup( nAreaId)
|
||||
EgtSetName( nSplitLayerId, WIN_BASESPLIT)
|
||||
-- verifico se va impostato il tipo french
|
||||
if bFrench then
|
||||
EgtSetInfo( nSplitLayerId, WIN_SPLITTYPE, WIN_SPLITTYPES.FRENCH)
|
||||
end
|
||||
|
||||
-- creo le curve di split
|
||||
local vSplitCurves = CalcSplitCurves( nSplitLayerId, b3OutlineLayer, b3OutlineLayer, nSplitType, nMeasureType, PositionList)
|
||||
|
||||
-- se non ci sono curve valide cancello tutto ed esco
|
||||
if #vSplitCurves == 0 then
|
||||
EgtErase( nAreaId)
|
||||
return
|
||||
end
|
||||
|
||||
-- creo le aree generate dagli split
|
||||
local vAreas = CreateAreasFromSplits( nAreaId, vSplitCurves)
|
||||
return vAreas
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea tagli split grid
|
||||
function WinCreate.AddGridSplits( nParentAreaId, nMeasureType, PositionListVert, PositionListHoriz, bStartVertical, nAreaNbr)
|
||||
|
||||
local AreaResult = {}
|
||||
|
||||
-- se area ha già sottoarea errore
|
||||
if EgtGetFirstNameInGroup( nParentAreaId, WIN_AREA .. '*') then
|
||||
return
|
||||
end
|
||||
|
||||
-- creo area di split
|
||||
local nAreaId = EgtGroup( nParentAreaId)
|
||||
EgtSetInfo( nAreaId, WIN_AREATYPE, WIN_AREATYPES.SPLIT)
|
||||
EgtSetName( nAreaId, WIN_AREA .. '(' .. WIN_SPLIT .. ')')
|
||||
if nAreaNbr then
|
||||
EgtSetInfo( nAreaId, WIN_AREA_NBR, nAreaNbr)
|
||||
end
|
||||
|
||||
-- copio il contorno dall'area parent e setto opportune corrispondenze sou/child
|
||||
local nOutlineLayerId = CopyParentOutline( nAreaId, nParentAreaId)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
|
||||
-- creo layer per split
|
||||
local nSplitLayerId = EgtGroup( nAreaId)
|
||||
EgtSetName( nSplitLayerId, WIN_BASESPLIT)
|
||||
|
||||
-- stabilisco direzione principale e secondaria
|
||||
local PositionListMain, PositionListOther, nSplitOrientationMain, nSplitOrientationOther
|
||||
if bStartVertical then
|
||||
PositionListMain = PositionListVert
|
||||
PositionListOther = PositionListHoriz
|
||||
nSplitOrientationMain = WIN_SPLITORIENTATION.VERTICAL
|
||||
nSplitOrientationOther = WIN_SPLITORIENTATION.HORIZONTAL
|
||||
else
|
||||
PositionListMain = PositionListHoriz
|
||||
PositionListOther = PositionListVert
|
||||
nSplitOrientationMain = WIN_SPLITORIENTATION.HORIZONTAL
|
||||
nSplitOrientationOther = WIN_SPLITORIENTATION.VERTICAL
|
||||
end
|
||||
|
||||
-- calcolo la suddivisione nella direzione principale
|
||||
local vMainSplit = CalcSplitCurves( nSplitLayerId, b3OutlineLayer, b3OutlineLayer, nSplitOrientationMain, nMeasureType, PositionListMain)
|
||||
local vMainAreas = CreateAreasFromSplits( nAreaId, vMainSplit)
|
||||
|
||||
-- per ogni area della direzione principale calcolo la suddivisione nella direzione secondaria
|
||||
for i = 1, #vMainAreas do
|
||||
-- recupero outline per calcolare il limite delle curve di split
|
||||
local nAreaOutlineLayerId = EgtGetFirstNameInGroup( vMainAreas[i], WIN_AREAOUTLINE)
|
||||
local b3Limit = EgtGetBBox( nAreaOutlineLayerId, GDB_BB.STANDARD)
|
||||
|
||||
-- calcolo gli split nella direzione secondaria
|
||||
local vOtherSplit = CalcSplitCurves( nSplitLayerId, b3OutlineLayer, b3Limit, nSplitOrientationOther, nMeasureType, PositionListOther)
|
||||
if #vOtherSplit > 0 then
|
||||
local vNewAreas = CreateAreasFromSplits( vMainAreas[i], vOtherSplit)
|
||||
AreaResult = EgtJoinTables( AreaResult, vNewAreas)
|
||||
end
|
||||
end
|
||||
|
||||
-- sposto le aree secondarie nell'area di split e le rinomino
|
||||
for i = 1, #AreaResult do
|
||||
EgtRelocateGlob( AreaResult[i], nAreaId)
|
||||
EgtSetName( AreaResult[i], WIN_AREA .. EgtNumToString( i))
|
||||
end
|
||||
-- le aree dello split principale diventano aree virtuali ausiliarie per i conti
|
||||
for i = 1, #vMainAreas do
|
||||
EgtSetName( vMainAreas[i], WIN_VIRTUAL_AREA)
|
||||
end
|
||||
|
||||
return AreaResult
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
---------------------------------- BOTTOMRAIL ------------------------------------
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user