diff --git a/EgtStoneLib/GenCalc.vb b/EgtStoneLib/EstCalc.vb
similarity index 92%
rename from EgtStoneLib/GenCalc.vb
rename to EgtStoneLib/EstCalc.vb
index 8fdacb6..42748cc 100644
--- a/EgtStoneLib/GenCalc.vb
+++ b/EgtStoneLib/EstCalc.vb
@@ -1,7 +1,9 @@
-Imports System.Globalization
+
+
+Imports System.Globalization
Imports EgtUILib
-Module GenCalc
+Module EstCalc
'--------------------------------------------------------------------------------------------------
Friend Function DoubleToString(ByVal dVal As Double, ByVal nNumDec As Integer) As String
@@ -56,13 +58,36 @@ Module GenCalc
Return m_ptRawMax
End Function
+ Private m_dRawLength As Double
+ Public Function GetRawLength() As Double
+ Return m_dRawLength
+ End Function
+
+ Private m_dRawWidth As Double
+ Public Function GetRawWidth() As Double
+ Return m_dRawWidth
+ End Function
+
+ Private m_dRawHeight As Double
+ Public Function GetRawHeight() As Double
+ Return m_dRawHeight
+ End Function
+
Public Sub UpdateRawPart()
' determino il grezzo (è il primo con fase 1)
m_nRawId = EgtGetFirstRawPart()
While m_nRawId <> GDB_ID.NULL And Not EgtVerifyRawPartPhase(m_nRawId, 1)
m_nRawId = EgtGetNextRawPart(m_nRawId)
End While
- GetRawBox(m_nRawId, m_ptRawMin, m_ptRawMax)
+ If GetRawBox(m_nRawId, m_ptRawMin, m_ptRawMax) Then
+ m_dRawLength = m_ptRawMax.x - m_ptRawMin.x
+ m_dRawWidth = m_ptRawMax.y - m_ptRawMin.y
+ m_dRawHeight = m_ptRawMax.z - m_ptRawMin.z
+ Else
+ m_dRawLength = 0
+ m_dRawWidth = 0
+ m_dRawHeight = 0
+ End If
End Sub
'--------------------------------------------------------------------------------------------------
diff --git a/EgtStoneLib/EstPhoto.vb b/EgtStoneLib/EstPhoto.vb
new file mode 100644
index 0000000..4b5fce4
--- /dev/null
+++ b/EgtStoneLib/EstPhoto.vb
@@ -0,0 +1,215 @@
+'----------------------------------------------------------------------------
+' EgalTech 2015-2017
+'----------------------------------------------------------------------------
+' File : GenPhoto.vb Data : 12.04.17 Versione : 1.8d1
+' Contenuto : Modulo gestione fotografie.
+' Ogni gruppo di lavoro può avere una sua foto della lastra.
+'
+'
+' Modifiche : 12.04.17 DS Creazione modulo.
+'
+'
+'----------------------------------------------------------------------------
+
+Imports System.IO
+Imports EgtUILib
+
+Module EstPhoto
+
+ Friend Function LoadPhoto(sPath As String) As Boolean
+ ' Verifico esistenza file immagine
+ If Not File.Exists(sPath) Then Return False
+ ' Leggo eventuale file dati aggiuntivi
+ Dim ptOri As New Point3d(0, 0, 0)
+ Dim ptCen As New Point3d(0, 0, 1)
+ Dim dMMxPixel As Double = 1
+ ReadAuxData(sPath, ptOri, ptCen, dMMxPixel)
+ ' Altezza eventuale tavola aggiuntiva
+ Dim dAddTable As Double = CurrentMachine.dAdditionalTable
+ ' Aggiusto dati per spessore grezzo
+ If Math.Abs(EstCalc.GetRawHeight() + dAddTable) > EPS_SMALL Then
+ ' Coefficiente di scalatura
+ Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
+ dMMxPixel *= dFsca
+ ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
+ ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
+ ptOri.z = EstCalc.GetRawHeight() + dAddTable
+ End If
+ ' Recupero origine della tavola e porto i punti in globale
+ Dim ptTab As Point3d
+ If Not EgtGetTableRef(1, ptTab) Then Return False
+ ptOri.ToGlob(New Frame3d(ptTab))
+ ptCen.ToGlob(New Frame3d(ptTab))
+ ' Recupero le dimensioni della tavola
+ Dim ptMin, ptMax As Point3d
+ If Not EgtGetTableArea(1, ptMin, ptMax) Then Return False
+ ' Elimino eventuale precedente foto
+ Dim nOldPhotoId = GetPhoto()
+ If nOldPhotoId <> GDB_ID.NULL Then EgtErase(nOldPhotoId)
+ ' Se non esiste il gruppo per le foto, lo creo
+ Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
+ If nPhGrpId = GDB_ID.NULL Then
+ nPhGrpId = EgtCreateGroup(GDB_ID.ROOT)
+ If nPhGrpId = GDB_ID.NULL Then Return False
+ EgtSetName(nPhGrpId, PHOTO_GRP)
+ End If
+ EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
+ ' Carico la fotografia
+ Return EgtAddPhoto(PHOTO_NAME, sPath, ptOri, ptCen, dMMxPixel, nPhGrpId, ptMin, ptMax) <> GDB_ID.NULL
+ End Function
+
+ Private Function ReadAuxData(sPath As String,
+ ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double) As Boolean
+ Dim sAuxPath As String = Path.ChangeExtension(sPath, ".txt")
+ Try
+ Dim sLine As String = String.Empty
+ Dim sr As StreamReader = New StreamReader(sAuxPath)
+ Do While sr.Peek() > -1
+ sLine = sr.ReadLine()
+ sLine = sLine.Replace(" ", "")
+ If sLine.StartsWith("X=") Then
+ StringToDouble(sLine.Substring(2), ptOri.x)
+ ElseIf sLine.StartsWith("Y=") Then
+ StringToDouble(sLine.Substring(2), ptOri.y)
+ ElseIf sLine.StartsWith("Z_Lastra=") Then
+ StringToDouble(sLine.Substring(9), ptOri.z)
+ ElseIf sLine.StartsWith("X_ScaleCenter=") Then
+ StringToDouble(sLine.Substring(14), ptCen.x)
+ ElseIf sLine.StartsWith("Y_ScaleCenter=") Then
+ StringToDouble(sLine.Substring(14), ptCen.y)
+ ElseIf sLine.StartsWith("Z_ScaleCenter=") Then
+ StringToDouble(sLine.Substring(14), ptCen.z)
+ ElseIf sLine.StartsWith("Pixelxmm=") Then
+ Dim dTmp As Double
+ StringToDouble(sLine.Substring(9), dTmp)
+ If dTmp > EPS_SMALL Then
+ dMMxPixel = 1 / dTmp
+ End If
+ End If
+ Loop
+ sr.Close()
+ Return True
+ Catch ex As Exception
+ EgtOutLog("LoadPhoto Error on auxfile : " & sAuxPath)
+ Return False
+ End Try
+ End Function
+
+ Public Function GetPhoto() As Integer
+ Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
+ Return EgtGetFirstNameInGroup(nPhGrpId, PHOTO_NAME)
+ End Function
+
+ Public Function GetPhotoTextureRef(ByRef refTxr As Frame3d) As Boolean
+ ' Recupero la foto
+ Dim nId As Integer = GetPhoto()
+ If nId = GDB_ID.NULL Then
+ Return False
+ End If
+ ' Recupero il riferimento in globale
+ Return EgtGetTextureFrame(nId, GDB_ID.ROOT, refTxr)
+ End Function
+
+ Public Function ShowPhoto(ByVal bShow As Boolean, Optional bDisableModified As Boolean = True) As Boolean
+ ' Recupero la foto
+ Dim nId As Integer = GetPhoto()
+ If nId = GDB_ID.NULL Then Return False
+ ' Se richiesto, disabilito impostazione modificato
+ Dim bOldEnMod As Boolean = False
+ If bDisableModified Then
+ bOldEnMod = EgtGetEnableModified()
+ If bOldEnMod Then EgtDisableModified()
+ End If
+ ' Ne cambio lo stato
+ Dim bOk As Boolean = EgtSetStatus(nId, If(bShow, GDB_ST.ON_, GDB_ST.OFF))
+ ' Se necessario, ripristino precedente impostazione modificato
+ If bOldEnMod Then EgtEnableModified()
+ Return bOk
+ End Function
+
+ Public Function UpdatePhoto() As Boolean
+ ' Verifico esistenza oggetto foto
+ Dim nPhotoId As Integer = GetPhoto()
+ If nPhotoId = GDB_ID.NULL Then Return False
+ ' Verifico esistenza texture della foto
+ Dim sPath As String = String.Empty
+ EgtGetPhotoPath(nPhotoId, sPath)
+ If Not File.Exists(sPath) Then Return False
+ ' Recupero i dati aggiuntivi della foto
+ Dim ptOri As New Point3d(0, 0, 0)
+ EgtGetPhotoOrigin(nPhotoId, ptOri)
+ Dim ptCen As New Point3d(0, 0, 1)
+ EgtGetPhotoCenter(nPhotoId, ptCen)
+ Dim dMMxPixel As Double = 1
+ EgtGetPhotoMMxPixel(nPhotoId, dMMxPixel)
+ ' Recupero origine della tavola
+ Dim ptTab As Point3d
+ If Not EgtGetTableRef(1, ptTab) Then Return False
+ ' Porto i punti in locale
+ ptOri.ToLoc(New Frame3d(ptTab))
+ ptCen.ToLoc(New Frame3d(ptTab))
+ ' Altezza eventuale tavola aggiuntiva
+ Dim dAddTable As Double = CurrentMachine.dAdditionalTable
+ ' Aggiusto dati per spessore grezzo (Coefficiente di scalatura)
+ Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
+ dMMxPixel *= dFsca
+ ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
+ ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
+ ptOri.z = EstCalc.GetRawHeight() + dAddTable
+ ' Porto i punti in globale
+ ptOri.ToGlob(New Frame3d(ptTab))
+ ptCen.ToGlob(New Frame3d(ptTab))
+ ' Recupero le dimensioni della tavola
+ Dim ptMin, ptMax As Point3d
+ If Not EgtGetTableArea(1, ptMin, ptMax) Then Return False
+ ' Elimino eventuale precedente foto
+ Dim nOldPhotoId = GetPhoto()
+ If nOldPhotoId <> GDB_ID.NULL Then EgtErase(nOldPhotoId)
+ ' Se non esiste il gruppo per le foto, lo creo
+ Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
+ If nPhGrpId = GDB_ID.NULL Then
+ nPhGrpId = EgtCreateGroup(GDB_ID.ROOT)
+ If nPhGrpId = GDB_ID.NULL Then Return False
+ EgtSetName(nPhGrpId, PHOTO_GRP)
+ End If
+ EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
+ ' Carico la fotografia
+ Return EgtAddPhoto(PHOTO_NAME, sPath, ptOri, ptCen, dMMxPixel, nPhGrpId, ptMin, ptMax) <> GDB_ID.NULL
+ End Function
+
+ Public Function UpdateContour() As Boolean
+ ' Verifico esistenza oggetto contorno
+ Dim nCrvId As Integer = GetContour()
+ If nCrvId = GDB_ID.NULL Then Return False
+ ' Verifico esistenza oggetto foto
+ Dim nPhotoId As Integer = GetPhoto()
+ If nPhotoId = GDB_ID.NULL Then Return False
+ ' Recupero centro della foto
+ Dim ptCen As New Point3d(0, 0, 1)
+ EgtGetPhotoCenter(nPhotoId, ptCen)
+ ' Recupero origine della tavola
+ Dim ptTab As Point3d
+ If Not EgtGetTableRef(1, ptTab) Then Return False
+ ' Altezza eventuale tavola aggiuntiva
+ Dim dAddTable As Double = CurrentMachine.dAdditionalTable
+ ' Recupero inizio contorno
+ Dim ptStart As Point3d
+ EgtStartPoint(nCrvId, GDB_ID.ROOT, ptStart)
+ ' Calcolo coefficiente di scalatura
+ Dim dFsca As Double = (ptCen.z - ptTab.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptStart.z)
+ ' Scalo opportunamente
+ EgtScale(nCrvId, New Frame3d(ptCen), dFsca, dFsca, 1, GDB_RT.GLOB)
+ ' Sposto in Z
+ Dim vtMove As New Vector3d(0, 0, ptTab.z + EstCalc.GetRawHeight() + dAddTable - ptStart.z)
+ EgtMove(nCrvId, vtMove, GDB_RT.GLOB)
+ Return True
+ End Function
+
+ Friend Function GetContour() As Integer
+ Dim nPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE)
+ Dim nLayerId As Integer = EgtGetFirstGroupInGroup(nPartId)
+ Dim nCrvId As Integer = EgtGetFirstInGroup(nLayerId)
+ Return nCrvId
+ End Function
+
+End Module
diff --git a/OmagOFFICE.vbproj b/OmagOFFICE.vbproj
index eb1477f..3feb6ca 100644
--- a/OmagOFFICE.vbproj
+++ b/OmagOFFICE.vbproj
@@ -142,7 +142,8 @@
-
+
+ MachinePanelV.xaml
diff --git a/OptionPanel/NestingTab/NestingTabVM.vb b/OptionPanel/NestingTab/NestingTabVM.vb
index 34c0b76..2f49716 100644
--- a/OptionPanel/NestingTab/NestingTabVM.vb
+++ b/OptionPanel/NestingTab/NestingTabVM.vb
@@ -141,7 +141,7 @@ Public Class NestingTabVM
Friend Function InitNesting() As Boolean
' aggiorno dati del grezzo
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
' calcolo valore di minima distanza (da spessore lama corrente)
Dim dSawThick As Double = 0
If EgtTdbSetCurrTool(CurrentMachine.sCurrSaw) AndAlso
@@ -243,7 +243,7 @@ Public Class NestingTabVM
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
End If
End If
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
@@ -285,7 +285,7 @@ Public Class NestingTabVM
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
End If
End If
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
@@ -327,7 +327,7 @@ Public Class NestingTabVM
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
End If
End If
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
@@ -369,7 +369,7 @@ Public Class NestingTabVM
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
End If
End If
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
@@ -395,7 +395,7 @@ Public Class NestingTabVM
Public Sub CClockwiseRot(ByVal param As Object)
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostV.OmagOFFICEScene.GetCtx())
RotateCluster(m_dRotationAngle)
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
@@ -421,7 +421,7 @@ Public Class NestingTabVM
Public Sub ClockwiseRot(ByVal param As Object)
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostV.OmagOFFICEScene.GetCtx())
RotateCluster(-m_dRotationAngle)
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
@@ -733,7 +733,7 @@ Public Class NestingTabVM
EgtMovePartToSnapPointOnCollision(nMoveId, m_bReducedCut, m_dSnapDist, bSnapMoved)
End If
End If
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
End If
EgtDraw()
' Eventuale notifica al VeinMatching
@@ -766,7 +766,7 @@ Public Class NestingTabVM
EnableReferenceRegion(False)
' Eseguo verifica
If EgtVerifyPart(nMoveId, m_bReducedCut) Then
- GenCalc.ResetOrderMachiningFlag()
+ EstCalc.ResetOrderMachiningFlag()
' Non superata riporto alla posizione iniziale
Else
EgtMove(nMoveId, -m_vtTotMove)
diff --git a/OptionPanel/OptionPanelVM.vb b/OptionPanel/OptionPanelVM.vb
index 0dab1eb..4a10f79 100644
--- a/OptionPanel/OptionPanelVM.vb
+++ b/OptionPanel/OptionPanelVM.vb
@@ -19,7 +19,7 @@
' Esco dallo stato corrente
Select Case m_SelItem
Case Tabs.RAWPART
- OmagOFFICEMap.refRawPartTabVM.CloseRawPart()
+ OmagOFFICEMap.refRawPartTabVM.ExitRawPart()
Case Tabs.NESTING
Case Tabs.MACHINING
Case Tabs.SIMUL
diff --git a/OptionPanel/RawPartTab/RawPartTabV.xaml b/OptionPanel/RawPartTab/RawPartTabV.xaml
index 40441c6..9730f65 100644
--- a/OptionPanel/RawPartTab/RawPartTabV.xaml
+++ b/OptionPanel/RawPartTab/RawPartTabV.xaml
@@ -3,7 +3,23 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtWpfLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
Margin="5,5,5,0">
-
+
+
+
+
+
+
+
+
+
+
+
+ Margin="0,0,0,5"
+ IsEnabled="{Binding TypeIsEnabled}"/>
+ Margin="13,0,5,5"
+ IsEnabled="{Binding LengthIsEnabled}" TextAlignment="Right"/>
+ Margin="13,0,5,5"
+ IsEnabled="{Binding WidthIsEnabled}" TextAlignment="Right"/>
+ Margin="13,0,5,5"
+ IsEnabled="{Binding HeightIsEnabled}" TextAlignment="Right"/>
+ Margin="13,0,5,5"
+ IsEnabled="{Binding OffsetXIsEnabled}" TextAlignment="Right"/>
+ Margin="13,0,5,5"
+ IsEnabled="{Binding OffsetYIsEnabled}" TextAlignment="Right"/>
+ Margin="13,0,5,5"
+ IsEnabled="{Binding KerfIsEnabled}" TextAlignment="Right"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
+
+
+
+
+
+
+
@@ -104,18 +111,10 @@
-
-
-
-
-
-
-
+ Visibility="{Binding ConfirmPhotoVisibility}"
+ Style="{StaticResource OptionPanel_Button}"
+ Margin="0,0,0,5"/>
diff --git a/OptionPanel/RawPartTab/RawPartTabVM.vb b/OptionPanel/RawPartTab/RawPartTabVM.vb
index 6603c96..ceeeca7 100644
--- a/OptionPanel/RawPartTab/RawPartTabVM.vb
+++ b/OptionPanel/RawPartTab/RawPartTabVM.vb
@@ -1,4 +1,5 @@
-Imports System.Collections.ObjectModel
+Imports System.IO
+Imports System.Collections.ObjectModel
Imports EgtWPFLib5
Imports EgtUILib
@@ -19,6 +20,14 @@ Public Class RawPartTabVM
Private m_ptPrev As Point3d
Private m_nDragEnt As Integer = -1
Private m_dDragPar As Double = 0
+ ' Modalità operazione su punti grezzo
+ Private m_nPtMode As PTMODE = PTMODE.MOVE
+ ' Modalità operazione su punti aree danneggiate
+ Private m_nPtDmgMode As DMGMODE = DMGMODE.NONE
+ ' Variabile che indica la zona danneggiata selezionata
+ Private m_nSelDmg As Integer
+ ' Layer per crocette temporanee
+ Private m_nTempLay As Integer = GDB_ID.NULL
' Costante minima dimensione del grezzo
Private Const MIN_RAW_DIM As Double = 10
@@ -26,10 +35,30 @@ Public Class RawPartTabVM
Private Const SAFE_RAW_DIST As Double = 5
' Costante raggio cerchietto
Private Const RAD_CIRCLE As Double = 30
-
+ ' Stati dialogo tipo contorno
Enum Type As Integer
- RECTANGLE
- BYPOINTS
+ RECTANGLE = 0
+ BY_POINTS = 1
+ FROM_PHOTO = 2
+ End Enum
+ ' Costanti modalità di creazione grezzo
+ Private Enum RAWMODE As Integer
+ RECTANGLE = 0
+ BY_POINTS = 1
+ FROM_PHOTO = 2
+ DAMAGED = 3
+ End Enum
+ ' Costanti modo operazione punti
+ Private Enum PTMODE
+ MOVE = 0
+ ADD = 1
+ REMOVE = 2
+ End Enum
+ ' Costanti modo operazione zone danneggiate
+ Private Enum DMGMODE
+ NONE = 0
+ ADD = 1
+ REMOVE = 2
End Enum
Private m_OutlineIsChecked As Boolean
@@ -40,24 +69,20 @@ Public Class RawPartTabVM
Set(value As Boolean)
If value <> m_OutlineIsChecked Then
m_OutlineIsChecked = value
+ RawModeView()
+ If m_OutlineIsChecked Then
+ UpdateCircles()
+ Else
+ m_SelType = Type.BY_POINTS
+ NotifyPropertyChanged("SelType")
+ RemoveCircles()
+ End If
+ EgtDraw()
NotifyPropertyChanged("OutlineIsChecked")
End If
End Set
End Property
- Private m_DAIsChecked As Boolean
- Public Property DAIsChecked As Boolean
- Get
- Return m_DAIsChecked
- End Get
- Set(value As Boolean)
- If value <> m_DAIsChecked Then
- m_DAIsChecked = value
- NotifyPropertyChanged("DAIsChecked")
- End If
- End Set
- End Property
-
Private m_TypeList As New List(Of String)
Public ReadOnly Property TypeList As List(Of String)
Get
@@ -72,14 +97,41 @@ Public Class RawPartTabVM
End Get
Set(value As Integer)
m_SelType = value
- NotifyPropertyChanged("SelType")
+ Select Case m_SelType
+ Case Type.RECTANGLE
+ RawModeView()
+ RemoveCircles()
+ UpdateRawPart()
+ Case Type.BY_POINTS
+ RawModeView()
+ UpdateCircles()
+ EgtDraw()
+ Case Type.FROM_PHOTO
+ RawModeView()
+ RemoveCircles()
+ ' CreateRawFromPhotoContour()
+ EgtDraw()
+ End Select
+ End Set
+ End Property
+
+ Private m_TypeIsEnabled As Boolean
+ Public Property TypeIsEnabled As Boolean
+ Get
+ Return m_TypeIsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_TypeIsEnabled Then
+ m_TypeIsEnabled = value
+ NotifyPropertyChanged("TypeIsEnabled")
+ End If
End Set
End Property
Private m_dLength As Double
Public Property Length As String
Get
- Return LenToString(m_dLength, 2)
+ Return LenToString(m_dLength, -2)
End Get
Set(value As String)
Dim dLength As Double = 0
@@ -104,10 +156,23 @@ Public Class RawPartTabVM
NotifyPropertyChanged("Length")
End Sub
+ Private m_LengthIsEnabled As Boolean
+ Public Property LengthIsEnabled As Boolean
+ Get
+ Return m_LengthIsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_LengthIsEnabled Then
+ m_LengthIsEnabled = value
+ NotifyPropertyChanged("LengthIsEnabled")
+ End If
+ End Set
+ End Property
+
Private m_dWidth As Double
Public Property Width As String
Get
- Return LenToString(m_dWidth, 2)
+ Return LenToString(m_dWidth, -2)
End Get
Set(value As String)
Dim dWidth As Double = 0
@@ -131,10 +196,23 @@ Public Class RawPartTabVM
NotifyPropertyChanged("Width")
End Sub
+ Private m_WidthIsEnabled As Boolean
+ Public Property WidthIsEnabled As Boolean
+ Get
+ Return m_WidthIsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_WidthIsEnabled Then
+ m_WidthIsEnabled = value
+ NotifyPropertyChanged("WidthIsEnabled")
+ End If
+ End Set
+ End Property
+
Private m_dHeight As Double
Public Property Height As String
Get
- Return LenToString(m_dHeight, 2)
+ Return LenToString(m_dHeight, -2)
End Get
Set(value As String)
Dim dHeight As Double = 0
@@ -155,10 +233,23 @@ Public Class RawPartTabVM
NotifyPropertyChanged("Height")
End Sub
+ Private m_HeightIsEnabled As Boolean
+ Public Property HeightIsEnabled As Boolean
+ Get
+ Return m_HeightIsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_HeightIsEnabled Then
+ m_HeightIsEnabled = value
+ NotifyPropertyChanged("HeightIsEnabled")
+ End If
+ End Set
+ End Property
+
Private m_dOffsetX As Double
Public Property OffsetX As String
Get
- Return LenToString(m_dOffsetX, 2)
+ Return LenToString(m_dOffsetX, -2)
End Get
Set(value As String)
Dim dOffsetX As Double = 0
@@ -186,10 +277,23 @@ Public Class RawPartTabVM
NotifyPropertyChanged("OffsetX")
End Sub
+ Private m_OffsetXIsEnabled As Boolean
+ Public Property OffsetXIsEnabled As Boolean
+ Get
+ Return m_OffsetXIsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_OffsetXIsEnabled Then
+ m_OffsetXIsEnabled = value
+ NotifyPropertyChanged("OffsetXIsEnabled")
+ End If
+ End Set
+ End Property
+
Private m_dOffsetY As Double
Public Property OffsetY As String
Get
- Return LenToString(m_dOffsetY, 2)
+ Return LenToString(m_dOffsetY, -2)
End Get
Set(value As String)
Dim dOffsetY As Double = 0
@@ -217,10 +321,23 @@ Public Class RawPartTabVM
NotifyPropertyChanged("OffsetY")
End Sub
+ Private m_OffsetYIsEnabled As Boolean
+ Public Property OffsetYIsEnabled As Boolean
+ Get
+ Return m_OffsetYIsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_OffsetYIsEnabled Then
+ m_OffsetYIsEnabled = value
+ NotifyPropertyChanged("OffsetYIsEnabled")
+ End If
+ End Set
+ End Property
+
Private m_dKerf As Double
Public Property Kerf As String
Get
- Return LenToString(m_dKerf, 2)
+ Return LenToString(m_dKerf, -2)
End Get
Set(value As String)
Dim dKerf As Double = -1
@@ -230,7 +347,7 @@ Public Class RawPartTabVM
If StringToLen(value, dKerf) And dKerf > dMinKerf - EPS_SMALL And dKerf < dMaxKerf + EPS_SMALL Then
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
m_dKerf = dKerf
- UpdateRawPart()
+ UpdateRawPartKerf()
ElseIf dKerf < dMinKerf Then
NotifyPropertyChanged("Kerf")
' Minimo kerf =
@@ -239,7 +356,7 @@ Public Class RawPartTabVM
Else
NotifyPropertyChanged("Kerf")
' Massimo kerf =
- Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 22) & " " &LenToString(dMaxKerf, 2)
+ Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 22) & " " & LenToString(dMaxKerf, 2)
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, True)
End If
End Set
@@ -249,6 +366,19 @@ Public Class RawPartTabVM
NotifyPropertyChanged("Kerf")
End Sub
+ Private m_KerfIsEnabled As Boolean
+ Public Property KerfIsEnabled As Boolean
+ Get
+ Return m_KerfIsEnabled
+ End Get
+ Set(value As Boolean)
+ If value <> m_KerfIsEnabled Then
+ m_KerfIsEnabled = value
+ NotifyPropertyChanged("KerfIsEnabled")
+ End If
+ End Set
+ End Property
+
Public ReadOnly Property MaterialList As ObservableCollection(Of Material)
Get
Return CurrentMachine.Materials
@@ -272,10 +402,26 @@ Public Class RawPartTabVM
Set(value As Boolean)
If value <> m_AddPoint Then
m_AddPoint = value
- If value Then
-
- NotifyPropertyChanged("AddPoint")
- End If
+ Select Case GetRawMode()
+ Case RAWMODE.BY_POINTS
+ m_RemovePoint = False
+ NotifyPropertyChanged("RemovePoint")
+ m_nPtMode = If(m_AddPoint, PTMODE.ADD, PTMODE.MOVE)
+ Case RAWMODE.DAMAGED
+ ' Verifico ci sia almeno una zona rovinata
+ If EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED) = GDB_ID.NULL Then
+ m_AddPoint = False
+ End If
+ m_RemovePoint = False
+ NotifyPropertyChanged("RemovePoint")
+ m_NewDA = False
+ NotifyPropertyChanged("NewDA")
+ m_DeleteDA = False
+ NotifyPropertyChanged("DeleteDA")
+ m_nPtMode = If(m_AddPoint, PTMODE.ADD, PTMODE.MOVE)
+ m_nPtDmgMode = DMGMODE.NONE
+ End Select
+ NotifyPropertyChanged("AddPoint")
End If
End Set
End Property
@@ -288,10 +434,26 @@ Public Class RawPartTabVM
Set(value As Boolean)
If value <> m_RemovePoint Then
m_RemovePoint = value
- If value Then
-
- NotifyPropertyChanged("RemovePoint")
- End If
+ Select GetRawMode()
+ Case RAWMODE.BY_POINTS
+ m_AddPoint = False
+ NotifyPropertyChanged("AddPoint")
+ m_nPtMode = If(m_RemovePoint, PTMODE.REMOVE, PTMODE.MOVE)
+ Case RAWMODE.DAMAGED
+ ' Verifico ci sia almeno una zona rovinata
+ If EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED) = GDB_ID.NULL Then
+ m_RemovePoint = False
+ End If
+ m_AddPoint = False
+ NotifyPropertyChanged("AddPoint")
+ m_NewDA = False
+ NotifyPropertyChanged("NewDA")
+ m_DeleteDA = False
+ NotifyPropertyChanged("DeleteDA")
+ m_nPtMode = If(m_RemovePoint, PTMODE.REMOVE, PTMODE.MOVE)
+ m_nPtDmgMode = DMGMODE.NONE
+ End Select
+ NotifyPropertyChanged("RemovePoint")
End If
End Set
End Property
@@ -317,26 +479,38 @@ Public Class RawPartTabVM
Set(value As Boolean)
If value <> m_NewDA Then
m_NewDA = value
- If value Then
-
- NotifyPropertyChanged("NewDA")
- End If
+ NotifyPropertyChanged("NewDA")
+ m_nPtDmgMode = If(m_NewDA, DMGMODE.ADD, DMGMODE.NONE)
+ m_DeleteDA = False
+ NotifyPropertyChanged("DeleteDA")
+ m_AddPoint = False
+ NotifyPropertyChanged("AddPoint")
+ m_RemovePoint = False
+ NotifyPropertyChanged("RemovePoint")
End If
End Set
End Property
Private m_DeleteDA As Boolean
- Public Property DleteDA As Boolean
+ Public Property DeleteDA As Boolean
Get
Return m_DeleteDA
End Get
Set(value As Boolean)
If value <> m_DeleteDA Then
m_DeleteDA = value
- If value Then
-
- NotifyPropertyChanged("DleteDA")
+ ' Verifico ci sia almeno una zona rovinata
+ If EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED) = GDB_ID.NULL Then
+ m_DeleteDA = False
End If
+ NotifyPropertyChanged("DeleteDA")
+ m_nPtDmgMode = If(m_DeleteDA, DMGMODE.REMOVE, DMGMODE.NONE)
+ m_NewDA = False
+ NotifyPropertyChanged("NewDA")
+ m_AddPoint = False
+ NotifyPropertyChanged("AddPoint")
+ m_RemovePoint = False
+ NotifyPropertyChanged("RemovePoint")
End If
End Set
End Property
@@ -354,6 +528,20 @@ Public Class RawPartTabVM
End Set
End Property
+ Private m_ConfirmPhotoVisibility As Visibility
+ Public Property ConfirmPhotoVisibility As Visibility
+ Get
+ Return m_ConfirmPhotoVisibility
+ End Get
+ Set(value As Visibility)
+ If value <> m_ConfirmPhotoVisibility Then
+ m_ConfirmPhotoVisibility = value
+ NotifyPropertyChanged("ConfirmPhotoVisibility")
+ End If
+ End Set
+ End Property
+
+
#Region "Messages"
Public ReadOnly Property OutlineMsg As String
@@ -428,12 +616,6 @@ Public Class RawPartTabVM
End Get
End Property
- Public ReadOnly Property ClosePathMsg As String
- Get
- Return EgtMsg(MSG_RAWPARTPAGEUC + 31)
- End Get
- End Property
-
Public ReadOnly Property NewMsg As String
Get
Return EgtMsg(MSG_RAWPARTPAGEUC + 11)
@@ -504,7 +686,7 @@ Public Class RawPartTabVM
End If
End If
' Assegno identificativo del grezzo
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
' Parcheggio pezzi presenti nel grezzo
Dim nPartId As Integer = EgtGetFirstPartInRawPart(GetRawId())
While nPartId <> GDB_ID.NULL
@@ -518,7 +700,7 @@ Public Class RawPartTabVM
' Cancello tutte le lavorazioni
EraseMachinings(GDB_ID.NULL)
' Visualizzo eventuale foto
- ' m_MainWindow.m_CurrentProjectPageUC.ShowPhoto(True)
+ ShowPhoto(True)
Dim bHeightModified As Boolean = False
' Se esiste già il grezzo...
If GetRawId() <> GDB_ID.NULL Then
@@ -536,7 +718,7 @@ Public Class RawPartTabVM
SetOffsetX(ptRawMin.x - m_ptTableMin.x + m_dKerf)
SetOffsetY(ptRawMin.y - m_ptTableMin.y + m_dKerf)
' aggiorno l'apparenza del grezzo
- 'AdjustRawPartOnStart()
+ AdjustRawPartOnStart()
' Altrimenti lo definisco
Else
' Leggo da Ini gli ultimi valori
@@ -549,32 +731,37 @@ Public Class RawPartTabVM
' Richiedo ricalcolo quota eventuale foto
bHeightModified = True
End If
- '' Creo layer temporaneo per crocette
- 'm_nTempLay = EgtCreateGroup(GDB_ID.ROOT)
- 'EgtSetLevel(m_nTempLay, GDB_LV.TEMP)
+ ' Creo layer temporaneo per crocette
+ m_nTempLay = EgtCreateGroup(GDB_ID.ROOT)
+ EgtSetLevel(m_nTempLay, GDB_LV.TEMP)
' Determino modalità di definizione
OutlineIsChecked = True
If EgtExistsInfo(GetRawId(), KEY_RAWBYPOINTS) Then
- SelType = Type.BYPOINTS
+ m_SelType = Type.BY_POINTS
+ NotifyPropertyChanged("SelType")
PointsVisibility = Visibility.Visible
- ' CloseBtn.Visibility = Windows.Visibility.Hidden
- ' ' Visualizzo crocette
- ' UpdateCircles()
- ' EgtZoom(ZM.ALL)
+ ' Visualizzo crocette
+ UpdateCircles()
+ EgtZoom(ZM.ALL)
Else
- SelType = Type.RECTANGLE
+ m_SelType = Type.RECTANGLE
+ NotifyPropertyChanged("SelType")
PointsVisibility = Visibility.Collapsed
UpdateRawPart(bHeightModified)
End If
DAVisibility = Visibility.Collapsed
' Imposto il materiale corrente nella combobox
NotifyPropertyChanged("SelMaterial")
- 'MaterialsCmbx.SelectedItem = m_CurrentMachine.CurrMat
Return True
End Function
- Friend Function CloseRawPart() As Boolean
+ Friend Function ExitRawPart() As Boolean
+
+ ' Sistemo il grezzo
+ AdjustRawPartOnExit()
+ ' Rimuovo layer temporaneo per crocette
+ EgtErase(m_nTempLay)
' Salvo nel file Ini le dimensioni del grezzo (sempre in mm)
WriteMainPrivateProfileString(S_RAWPART, K_RAWLENGTH, DoubleToString(m_dLength, 2))
WriteMainPrivateProfileString(S_RAWPART, K_RAWWIDTH, DoubleToString(m_dWidth, 2))
@@ -585,21 +772,92 @@ Public Class RawPartTabVM
Return True
End Function
+ Private Function GetRawMode() As RAWMODE
+ Select Case m_SelType
+ Case Type.RECTANGLE
+ Return RAWMODE.RECTANGLE
+ Case Type.BY_POINTS
+ If m_OutlineIsChecked Then
+ Return RAWMODE.BY_POINTS
+ Else
+ Return RAWMODE.DAMAGED
+ End If
+ Case Type.FROM_PHOTO
+ Return RAWMODE.FROM_PHOTO
+ End Select
+
+ End Function
+
+ Private Sub RawModeView()
+ Select Case GetRawMode()
+ Case RAWMODE.RECTANGLE
+ TypeIsEnabled = True
+ LengthIsEnabled = True
+ WidthIsEnabled = True
+ HeightIsEnabled = True
+ OffsetXIsEnabled = True
+ OffsetYIsEnabled = True
+ KerfIsEnabled = True
+ ' Nascondo bottoni per disegno
+ PointsVisibility = Visibility.Collapsed
+ ' Disattivo bottoni zone rovinate e conferma contorno da foto
+ DAVisibility = Visibility.Collapsed
+ ConfirmPhotoVisibility = Visibility.Collapsed
+ Case RAWMODE.BY_POINTS
+ TypeIsEnabled = True
+ LengthIsEnabled = False
+ WidthIsEnabled = False
+ HeightIsEnabled = False
+ OffsetXIsEnabled = False
+ OffsetYIsEnabled = False
+ KerfIsEnabled = True
+ ' Visualizzo bottoni per disegno
+ PointsVisibility = Visibility.Visible
+ ' Disattivo bottoni zone rovinate e conferma contorno da foto
+ DAVisibility = Visibility.Collapsed
+ ConfirmPhotoVisibility = Visibility.Collapsed
+ Case RAWMODE.DAMAGED
+ TypeIsEnabled = False
+ LengthIsEnabled = False
+ WidthIsEnabled = False
+ HeightIsEnabled = False
+ OffsetXIsEnabled = False
+ OffsetYIsEnabled = False
+ KerfIsEnabled = False
+ ' Visualizzo bottoni per disegno
+ PointsVisibility = Visibility.Visible
+ ' Attivo bottoni zone rovinate
+ DAVisibility = Visibility.Visible
+ ' Disattivo bottone conferma contorno da foto
+ ConfirmPhotoVisibility = Visibility.Collapsed
+ Case RAWMODE.FROM_PHOTO
+ TypeIsEnabled = True
+ LengthIsEnabled = False
+ WidthIsEnabled = False
+ HeightIsEnabled = True
+ OffsetXIsEnabled = False
+ OffsetYIsEnabled = False
+ KerfIsEnabled = True
+ ' Nascondo bottoni per punti e zone rovinate
+ PointsVisibility = Visibility.Collapsed
+ DAVisibility = Visibility.Collapsed
+ ' Visualizzo bottone conferma contorno da foto
+ ConfirmPhotoVisibility = Visibility.Visible
+ End Select
+ End Sub
+
Private Sub UpdateRawPart(Optional bHeightModified As Boolean = False)
' Se cambiato spessore e c'è foto, aggiorno quota fotografia
- 'If bHeightModified And m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then
- ' ' Aggiorno spessore in progetto corrente
- ' m_CurrProjPage.m_dRawHeight = m_RawHeight
- ' m_CurrProjPage.UpdateHeightTxBx()
- ' ' Ricarico fotografia
- ' m_CurrProjPage.UpdatePhoto()
- ' ' Aggiorno eventuale contorno da foto
- ' m_CurrProjPage.UpdateContour()
- 'End If
+ If bHeightModified And GetPhoto() <> GDB_ID.NULL Then
+ ' Ricarico fotografia
+ UpdatePhoto()
+ ' Aggiorno eventuale contorno da foto
+ UpdateContour()
+ End If
' Recupero il colore (con la foto lo rendo molto più trasparente)
Dim Col = m_RawCol
' in presenza di foto rendo molto più trasparente
- 'If m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then Col.A = 20
+ If GetPhoto() <> GDB_ID.NULL Then Col.A = 20
' Se non esiste già il grezzo e richiesto, lo inserisco
Dim nRawId As Integer = GetRawId()
If nRawId = GDB_ID.NULL And m_dHeight > EPS_SMALL Then
@@ -611,13 +869,14 @@ Public Class RawPartTabVM
Else
EgtModifyRawPart(nRawId, Point3d.ORIG(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight, Col)
End If
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
' Se non cancellato
If m_dHeight > EPS_SMALL Then
AdjustRawPartKerf()
' Sistemo la posizione
Dim ptRef As New Point3d(m_dOffsetX - m_dKerf, m_dOffsetY - m_dKerf, CurrentMachine.dAdditionalTable)
If EgtMoveToCornerRawPart(GetRawId(), ptRef, MCH_CR.BL) Then
+ EstCalc.UpdateRawPart()
'OkBtn.IsEnabled = True
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
Else
@@ -674,41 +933,217 @@ Public Class RawPartTabVM
EgtMove(nKerfId, New Vector3d(0, 0, m_dHeight - dKerfHeight))
End If
End If
- GenCalc.UpdateRawPart()
- ' Aggiorno spessore in progetto corrente
- ' !!! DA FARE !!!
+ EstCalc.UpdateRawPart()
' Se c'è foto, aggiorno quota fotografia
- 'If m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then
- ' ' Ricarico fotografia
- ' m_CurrProjPage.UpdatePhoto()
- ' ' Aggiorno eventuale contorno da foto
- ' m_CurrProjPage.UpdateContour()
- 'End If
+ If GetPhoto() <> GDB_ID.NULL Then
+ ' Ricarico fotografia
+ UpdatePhoto()
+ ' Aggiorno eventuale contorno da foto
+ UpdateContour()
+ End If
' Aggiorno visualizzazione
EgtZoom(ZM.ALL)
End Sub
+ Private Sub UpdateRawPartKerf()
+ ' Se non c'è il grezzo, esco
+ If GetRawId() = GDB_ID.NULL Then Return
+ ' Recupero percorso di contorno kerf
+ Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
+ ' Recupero colore grezzo ( in presenza di foto rendo molto più trasparente)
+ Dim Col = m_RawCol
+ If GetPhoto() <> GDB_ID.NULL Then Col.A = 20
+ ' Aggiorno il grezzo
+ EgtModifyRawPart(GetRawId(), nKerfId, m_dKerf, m_ptTableMin.z, m_dHeight, Col)
+ ' Salvo il nuovo valore (sempre in mm)
+ EgtSetInfo(GetRawId(), KEY_KERF, m_dKerf)
+ ' Aggiorno dimensioni e posizione grezzo
+ UpdateRawXYData()
+ ' Aggiorno visualizzazione
+ EgtZoom(ZM.ALL)
+ End Sub
+
+ Private Sub UpdateRawXYData()
+ ' Aggiorno i dati del grezzo
+ EstCalc.UpdateRawPart()
+ ' Aggiorno dimensioni grezzo nel piano XY
+ If GetRawId() <> GDB_ID.NULL Then
+ ' aggiorno dati grezzo
+ m_dLength = EstCalc.GetRawLength() - 2 * m_dKerf
+ m_dWidth = EstCalc.GetRawWidth() - 2 * m_dKerf
+ m_dOffsetX = EstCalc.GetRawPtMin().x + m_dKerf - m_ptTableMin.x
+ m_dOffsetY = EstCalc.GetRawPtMin().y + m_dKerf - m_ptTableMin.y
+ ' Assegno dati grezzo rettangolare ai textbox
+ NotifyPropertyChanged("Length")
+ NotifyPropertyChanged("Width")
+ NotifyPropertyChanged("OffsetX")
+ NotifyPropertyChanged("OffsetY")
+ End If
+ ' Aggiorno la posizione del grezzo
+ Dim ptRef As New Point3d(m_dOffsetX - m_dKerf, m_dOffsetY - m_dKerf, CurrentMachine.dAdditionalTable)
+ If EgtMoveToCornerRawPart(GetRawId(), ptRef, MCH_CR.BL) Then
+ EstCalc.UpdateRawPart()
+ 'OkBtn.IsEnabled = True
+ OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
+ Else
+ 'OkBtn.IsEnabled = False
+ Dim sMsg As String = "Errore nella posizione o dimensione del grezzo"
+ OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, True)
+ End If
+ End Sub
+
+ Private Sub AdjustRawPartOnStart()
+ ' Se non c'è la foto va già bene così
+ If GetPhoto() = GDB_ID.NULL Then Return
+
+ ' Disabilito impostazione modificato
+ Dim bOldEnMod = EgtGetEnableModified()
+ If bOldEnMod Then EgtDisableModified()
+ ' Disabilito la texture sul grezzo
+ Dim nSolidId = EgtGetFirstNameInGroup(GetRawId(), NAME_RAW_SOLID)
+ EgtRemoveTextureData(nSolidId)
+ ' Sistemo il colore
+ Dim Col = m_RawCol
+ Col.A = 20
+ EgtSetColor(nSolidId, Col, True)
+ ' Ripristino precedente impostazione modificato
+ If bOldEnMod Then EgtEnableModified()
+ End Sub
+
+ Private Sub AdjustRawPartOnExit()
+ ' Se non c'è il grezzo, esco
+ If GetRawId() = GDB_ID.NULL Then Return
+
+ ' Disabilito impostazione modificato
+ Dim bOldEnMod = EgtGetEnableModified()
+ If bOldEnMod Then EgtDisableModified()
+ ' Salvo la modalità di definizione
+ If SelType = Type.RECTANGLE Then
+ EgtRemoveInfo(GetRawId(), KEY_RAWBYPOINTS)
+ Else
+ EgtSetInfo(GetRawId(), KEY_RAWBYPOINTS, 1)
+ End If
+ ' Verifico senso antiorario della curva di kerf
+ Dim nKerfId = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
+ Dim dArea As Double
+ If EgtCurveAreaXY(nKerfId, dArea) AndAlso dArea < 0 Then
+ EgtInvertCurve(nKerfId)
+ End If
+ ' Elimino regioni per nesting
+ RemoveNestRegions()
+ ' Se c'è la foto devo sistemare
+ If GetPhoto() <> GDB_ID.NULL Then
+ ' Carico la texture della foto sul grezzo
+ Dim nSolidId = EgtGetFirstNameInGroup(GetRawId(), NAME_RAW_SOLID)
+ EgtSetTextureName(nSolidId, PHOTO_NAME)
+ ' Sistemo il riferimento della texture
+ Dim refTxr As New Frame3d
+ GetPhotoTextureRef(refTxr)
+ EgtSetTextureFrame(nSolidId, refTxr, GDB_RT.GLOB)
+ ' Sistemo il colore
+ Dim colWhite As New Color3d(255, 255, 255, 100)
+ EgtSetColor(nSolidId, colWhite)
+ ' Anche per il contorno
+ Dim nOutlineId = EgtGetFirstNameInGroup(GetRawId(), NAME_RAW_OUTLINE)
+ EgtSetColor(nOutlineId, colWhite)
+ EgtSetStatus(nOutlineId, GDB_ST.OFF)
+ ' Nascondo la foto
+ ShowPhoto(False)
+ End If
+ ' Ripristino precedente impostazione modificato
+ If bOldEnMod Then EgtEnableModified()
+ End Sub
+
+ Private Function RemoveNestRegions() As Boolean
+ ' Cancello eventuale vecchia regione fuori kerf per nesting
+ EgtErase(EgtGetFirstNameInGroup(GetRawId(), NAME_OUTKERF_REG))
+ ' Cancello eventuale vecchia regione di riferimento per nesting
+ EgtErase(EgtGetFirstNameInGroup(GetRawId(), NAME_REF_REG))
+ ' Cancello eventuali vecchie regioni aree rovinate per nesting
+ Dim nId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED_REG)
+ While nId <> GDB_ID.NULL
+ EgtErase(nId)
+ nId = EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED_REG)
+ End While
+ Return True
+ End Function
+
+ Private Sub AddNewDamagedArea()
+ ' Creo triangolo che abbia il punto selezionato come centro (lato 100mm)
+ ' calcolo punto in basso a sinistra
+ Dim ptBottomLeft As Point3d = New Point3d(m_ptPrev.x - 50,
+ m_ptPrev.y - (100 / 6 * Math.Sqrt(3)),
+ m_ptTableMin.z + CurrentMachine.dAdditionalTable + m_dHeight)
+ Dim vtRight As Vector3d = New Vector3d(100, 0, 0)
+ ' creo lato base
+ Dim nBaseId As Integer = EgtCreateLine(GetRawId(), ptBottomLeft, ptBottomLeft + vtRight, GDB_RT.GLOB)
+ ' calcolo vertice superiore del triangolo
+ Dim vtTop As New Vector3d(vtRight)
+ vtTop.Rotate(Vector3d.Z_AX, 60)
+ ' creo lati inclinati
+ Dim nCat1 As Integer = EgtCreateLine(GetRawId(), ptBottomLeft + vtRight, ptBottomLeft + vtTop, GDB_RT.GLOB)
+ Dim nCAt2 As Integer = EgtCreateLine(GetRawId(), ptBottomLeft + vtTop, ptBottomLeft, GDB_RT.GLOB)
+ ' Creo contorno zona rovinata
+ Dim nDmgId As Integer = EgtCreateCurveCompoByChain(GetRawId(), 3, {nBaseId, nCat1, nCAt2}, ptBottomLeft, True)
+ ' Assegno il nome alla CCompo creata
+ EgtSetName(nDmgId, NAME_DAMAGED)
+ ' e il colore
+ EgtSetColor(nDmgId, m_KerfCol)
+ ' Imposto come area danneggiata corrente
+ m_nSelDmg = nDmgId
+ ' Disabilito modalità aggiungi zona rovinata
+ m_nPtDmgMode = DMGMODE.NONE
+ End Sub
+
+ Private Sub RemoveDamagedArea()
+ ' Elimino area rovinata selezionata
+ EgtErase(m_nSelDmg)
+ ' Dichiaro zona danneggiata non selezionata
+ m_nSelDmg = GDB_ID.NULL
+ ' Disabilito modalità rimuovi zona rovinata
+ m_nPtDmgMode = DMGMODE.NONE
+ End Sub
+
+ Private Sub UpdateCircles()
+ ' Elimino vecchi punti finali
+ EgtEmptyGroup(m_nTempLay)
+ ' Identificativo curva
+ Dim nId As Integer = GDB_ID.NULL
+ If GetRawMode() = RAWMODE.BY_POINTS Then
+ nId = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
+ ElseIf GetRawMode() = RAWMODE.DAMAGED Then
+ nId = m_nSelDmg
+ End If
+ ' Verifico validità curva
+ If nId = GDB_ID.NULL Then Return
+ ' riferimento globale della stessa
+ Dim frRef As New Frame3d
+ EgtGetGlobFrame(nId, frRef)
+ ' Recupero i punti finali delle diverse entità componenti
+ Dim dU As Double = 1
+ Dim ptP As Point3d
+ While EgtAtParamPoint(nId, dU, ptP)
+ ptP.ToGlob(frRef)
+ CreateCircle(m_nTempLay, ptP)
+ dU += 1
+ End While
+ End Sub
+
+ Private Sub RemoveCircles()
+ EgtEmptyGroup(m_nTempLay)
+ End Sub
+
+ Private Function CreateCircle(nLayerId As Integer, ptP As Point3d) As Boolean
+ ' Aggiungo cerchio
+ Dim nCircId As Integer = EgtCreateCircle(nLayerId, ptP, RAD_CIRCLE)
+ EgtSetColor(nCircId, New Color3d(255, 0, 0))
+ Return True
+ End Function
+
#End Region ' METHODS
#Region "COMMANDS"
-#Region "ClosePathCommand"
-
- Public ReadOnly Property ClosePathCommand As ICommand
- Get
- If m_cmdClosePath Is Nothing Then
- m_cmdClosePath = New Command(AddressOf ClosePath)
- End If
- Return m_cmdClosePath
- End Get
- End Property
-
- Public Sub ClosePath(ByVal param As Object)
-
- End Sub
-
-#End Region ' ClosePathCommand
-
#Region "PhotoCommand"
Public ReadOnly Property PhotoCommand As ICommand
@@ -721,7 +1156,19 @@ Public Class RawPartTabVM
End Property
Public Sub Photo(ByVal param As Object)
-
+ ' Apro dialogo per scelta immagine
+ Dim PhotoDlg As New Microsoft.Win32.OpenFileDialog
+ PhotoDlg.Title = "Open"
+ PhotoDlg.Filter = "Image file(*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp"
+ PhotoDlg.FilterIndex = 1
+ GetMainPrivateProfileString(S_GENERAL, K_IMAGEDIR, "", PhotoDlg.InitialDirectory)
+ If Not PhotoDlg.ShowDialog Then Return
+ Dim sPhoto As String = PhotoDlg.FileName
+ ' Salvo nuovo direttorio corrente per immagini
+ WriteMainPrivateProfileString(S_GENERAL, K_IMAGEDIR, Path.GetDirectoryName(sPhoto))
+ ' Carico immagine
+ EstPhoto.LoadPhoto(sPhoto)
+ EgtZoom(ZM.ALL)
End Sub
#End Region ' PhotoCommand
@@ -764,8 +1211,8 @@ Public Class RawPartTabVM
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
m_nDragEnt = -1
m_dDragPar = -1
- ElseIf sName = NAME_KERF Then
- ' And (m_ActiveRawMode = RAWMODE.RECTANGLE Or m_ActiveRawMode = RAWMODE.BY_POINTS) Then
+ ElseIf sName = NAME_KERF And
+ (GetRawMode() = RAWMODE.RECTANGLE Or GetRawMode() = RAWMODE.BY_POINTS) Then
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
Dim dDist, dU As Double
If Not EgtGetMinDistPointCurve(m_ptPrev.Loc(nKerfId), nKerfId, dDist, dU) Then
@@ -775,27 +1222,123 @@ Public Class RawPartTabVM
m_dDragPar = dU
' Privilegio il kerf, pertanto esco
Exit While
- 'ElseIf sName = NAME_DAMAGED And m_ActiveRawMode = RAWMODE.DAMAGED Then
- ' m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
- ' Dim dDist, dU As Double
- ' If Not EgtGetMinDistPointCurve(m_ptPrev.Loc(nSelId), nSelId, dDist, dU) Then
- ' m_bDrag = False
- ' End If
- ' m_nDragEnt = CInt(Math.Ceiling(dU))
- ' m_dDragPar = dU
- ' m_nSelDmg = nSelId
- ' ' Aggiorno cerchi
- ' UpdateCircles()
- ' EgtDraw()
- ' ' Privilegio l'area danneggiata, pertanto esco
- ' Exit While
+ ElseIf sName = NAME_DAMAGED And GetRawMode() = RAWMODE.DAMAGED Then
+ m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
+ Dim dDist, dU As Double
+ If Not EgtGetMinDistPointCurve(m_ptPrev.Loc(nSelId), nSelId, dDist, dU) Then
+ m_bDrag = False
+ End If
+ m_nDragEnt = CInt(Math.Ceiling(dU))
+ m_dDragPar = dU
+ m_nSelDmg = nSelId
+ ' Aggiorno cerchi
+ UpdateCircles()
+ EgtDraw()
+ ' Privilegio l'area danneggiata, pertanto esco
+ Exit While
End If
nSelId = EgtGetNextObjInSelWin()
End While
' se drag e modalità punti
- ' ...
+ If m_bDrag And GetRawMode() = RAWMODE.BY_POINTS Then
+ ' se aggiungi punto
+ If m_nPtMode = PTMODE.ADD Then
+ If EgtAddCurveCompoJoint(nKerfId, m_dDragPar) Then m_dDragPar = Math.Ceiling(m_dDragPar)
+ ' il grezzo non è cambiato, perchè il nuovo punto è sulla vecchia linea
+ m_AddPoint = False
+ NotifyPropertyChanged("AddPoint")
+ m_nPtMode = PTMODE.MOVE
+ ' Aggiorno cerchi
+ UpdateCircles()
+ EgtDraw()
+ ' altrimenti
+ Else
+ ' verifico di essere abbastanza vicino ad un estremo
+ Dim ptJoint As Point3d
+ If Not EgtAtParamPoint(nKerfId, Math.Round(m_dDragPar), GDB_ID.ROOT, ptJoint) OrElse
+ Point3d.SqDistXY(ptJoint, m_ptPrev) > RAD_CIRCLE * RAD_CIRCLE Then
+ m_bDrag = False
+ End If
+ ' se rimuovi
+ If m_bDrag And m_nPtMode = PTMODE.REMOVE Then
+ ' ci devono essere almeno 4 punti
+ If EgtGetCurveCompoJointCount(nKerfId) >= 4 Then
+ EgtRemoveCurveCompoJoint(nKerfId, CInt(m_dDragPar))
+ ' Aggiorno il solido del grezzo, l'ingombro e la posizione
+ UpdateRawPartKerf()
+ ' Aggiorno cerchi
+ UpdateCircles()
+ EgtDraw()
+ End If
+ m_RemovePoint = False
+ NotifyPropertyChanged("RemovePoint")
+ m_nPtMode = PTMODE.MOVE
+ m_bDrag = False
+ End If
+ End If
' se drag e modalità zona danneggiata
- ' ...
+ ElseIf m_bDrag And GetRawMode() = RAWMODE.DAMAGED Then
+ ' se aggiungi zona rovinata
+ If m_nPtDmgMode = DMGMODE.ADD Then
+ AddNewDamagedArea()
+ ' Aggiorno
+ m_NewDA = False
+ NotifyPropertyChanged("NewDA")
+ UpdateCircles()
+ EgtDraw()
+ ' se rimuovi zona rovinata
+ ElseIf m_nPtDmgMode = DMGMODE.REMOVE Then
+ ' Verifico di essere sulla zona danneggiata
+ Dim ptNear As Point3d
+ If EgtAtParamPoint(m_nSelDmg, m_dDragPar, GDB_ID.ROOT, ptNear) And
+ Point3d.SqDistXY(ptNear, m_ptPrev) <= RAD_CIRCLE * RAD_CIRCLE Then
+ RemoveDamagedArea()
+ ' Aggiorno
+ m_DeleteDA = False
+ NotifyPropertyChanged("DeleteDA")
+ End If
+ ' Aggiorno cerchi
+ UpdateCircles()
+ EgtDraw()
+ ' altrimenti eventuali operazioni di punto
+ Else
+ ' se aggiungi punto
+ If m_nPtMode = PTMODE.ADD Then
+ If EgtAddCurveCompoJoint(m_nSelDmg, m_dDragPar) Then m_dDragPar = Math.Ceiling(m_dDragPar)
+ ' il grezzo non è cambiato, perchè il nuovo punto è sulla vecchia linea
+ m_AddPoint = False
+ NotifyPropertyChanged("AddPoint")
+ m_nPtMode = PTMODE.MOVE
+ ' Aggiorno cerchi
+ UpdateCircles()
+ EgtDraw()
+ ' altrimenti
+ Else
+ ' verifico di essere abbastanza vicino ad un estremo
+ Dim ptJoint As Point3d
+ If Not EgtAtParamPoint(m_nSelDmg, Math.Round(m_dDragPar), GDB_ID.ROOT, ptJoint) OrElse
+ Point3d.SqDistXY(ptJoint, m_ptPrev) > RAD_CIRCLE * RAD_CIRCLE Then
+ m_bDrag = False
+ End If
+ ' se rimuovi
+ If m_bDrag And m_nPtMode = PTMODE.REMOVE Then
+ ' ci devono essere almeno 4 punti
+ If EgtGetCurveCompoJointCount(m_nSelDmg) >= 4 Then
+ EgtRemoveCurveCompoJoint(m_nSelDmg, CInt(m_dDragPar))
+ ' aggiorno il solido del grezzo, l'ingombro e la posizione
+ UpdateRawPartKerf()
+ ' Aggiorno cerchi
+ UpdateCircles()
+ EgtDraw()
+ End If
+ m_RemovePoint = False
+ NotifyPropertyChanged("RemovePoint")
+ m_nPtMode = PTMODE.MOVE
+ m_bDrag = False
+ End If
+ End If
+ End If
+ End If
End Sub
Friend Sub OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
@@ -805,14 +1348,14 @@ Public Class RawPartTabVM
Dim ptCurr As Point3d
EgtUnProjectPoint(e.Location, ptCurr)
' Eseguo modifica
- 'Select Case m_ActiveRawMode
- ' Case RAWMODE.RECTANGLE
- ModifyRectangle(ptCurr)
- ' Case RAWMODE.BY_POINTS
- ' ModifyGeneric(ptCurr)
- ' Case RAWMODE.DAMAGED
- ' ModifyDamaged(ptCurr)
- 'End Select
+ Select GetRawMode()
+ Case RAWMODE.RECTANGLE
+ ModifyRectangle(ptCurr)
+ Case RAWMODE.BY_POINTS
+ ModifyGeneric(ptCurr)
+ Case RAWMODE.DAMAGED
+ ModifyDamaged(ptCurr)
+ End Select
' Aggiorno il punto precedente
m_ptPrev = ptCurr
End Sub
@@ -825,7 +1368,7 @@ Public Class RawPartTabVM
vtMove.z = 0
' Muovo il grezzo
If EgtMoveRawPart(GetRawId(), vtMove) Then
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
EgtDraw()
' Aggiorno gli offset
m_dOffsetX += vtMove.x
@@ -840,11 +1383,11 @@ Public Class RawPartTabVM
m_dWidth -= dDelta
m_dOffsetY += dDelta
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
AdjustRawPartKerf()
Dim vtMove As New Vector3d(0, dDelta, 0)
EgtMoveRawPart(GetRawId(), vtMove)
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
EgtDraw()
NotifyPropertyChanged("Width")
NotifyPropertyChanged("OffsetY")
@@ -856,7 +1399,7 @@ Public Class RawPartTabVM
m_dOffsetX + m_dLength + dDelta + m_dKerf < m_dTableLength Then
m_dLength += dDelta
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
AdjustRawPartKerf()
EgtDraw()
NotifyPropertyChanged("Length")
@@ -868,7 +1411,7 @@ Public Class RawPartTabVM
m_dOffsetY + m_dWidth + dDelta + m_dKerf < m_dTableWidth Then
m_dWidth += dDelta
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
AdjustRawPartKerf()
EgtDraw()
NotifyPropertyChanged("Width")
@@ -880,11 +1423,11 @@ Public Class RawPartTabVM
m_dLength -= dDelta
m_dOffsetX += dDelta
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
AdjustRawPartKerf()
Dim vtMove As New Vector3d(dDelta, 0, 0)
EgtMoveRawPart(GetRawId(), vtMove)
- GenCalc.UpdateRawPart()
+ EstCalc.UpdateRawPart()
EgtDraw()
NotifyPropertyChanged("Length")
NotifyPropertyChanged("OffsetX")
@@ -892,6 +1435,57 @@ Public Class RawPartTabVM
End If
End Sub
+ Private Sub ModifyGeneric(ptCurr As Point3d)
+ ' Se non selezionata entità del kerf, esco
+ If m_nDragEnt = -1 Then Return
+ ' Limito il punto a stare nella tavola con franco pari al kerf
+ If ptCurr.x < m_ptTableMin.x + m_dKerf Then ptCurr.x = m_ptTableMin.x + m_dKerf + SAFE_RAW_DIST
+ If ptCurr.y < m_ptTableMin.y + m_dKerf Then ptCurr.y = m_ptTableMin.y + m_dKerf + SAFE_RAW_DIST
+ If ptCurr.x > m_ptTableMin.x + m_dTableLength - m_dKerf Then ptCurr.x = m_ptTableMin.x + m_dTableLength - m_dKerf - SAFE_RAW_DIST
+ If ptCurr.y > m_ptTableMin.y + m_dTableWidth - m_dKerf Then ptCurr.y = m_ptTableMin.y + m_dTableWidth - m_dKerf - SAFE_RAW_DIST
+ ' Identificativo curva di kerf
+ Dim nKerfId = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
+ ' Identifico il punto
+ Dim nU As Integer = CInt(m_dDragPar)
+ ' Aggiusto Z punto movimentato (è in globale)
+ ptCurr.z = m_ptTableMin.z + CurrentMachine.dAdditionalTable + m_dHeight
+ ' Sposto il punto
+ If Not EgtModifyCurveCompoJoint(nKerfId, nU, ptCurr, GDB_RT.GLOB) Then Return
+ ' Aggiorno il grezzo, l'ingombro e la posizione
+ UpdateRawPartKerf()
+ ' Salvo il valore del kerf (sempre in mm)
+ EgtSetInfo(GetRawId(), KEY_KERF, m_dKerf)
+ ' Aggiorno cerchi
+ UpdateCircles()
+ ' Aggiorno visualizzazione
+ EgtDraw()
+ End Sub
+
+ Private Sub ModifyDamaged(ptCurr As Point3d)
+ ' Se non selezionata entità, esco
+ If m_nDragEnt = -1 Then Return
+ ' Recupero Id kerf
+ Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
+ ' Limito il punto a stare nel kerf
+ Dim ptLocCurr As Point3d = ptCurr.Loc(nKerfId)
+ Dim dMinDist As Double
+ Dim ptLocMin As Point3d
+ Dim nSide As Integer
+ If EgtGetMinDistPntSidePointCurve(ptLocCurr, nKerfId, Vector3d.Z_AX, dMinDist, ptLocMin, nSide) And nSide = +1 Then
+ ptCurr = ptLocMin.Glob(nKerfId)
+ End If
+ ' Identifico il punto
+ Dim nU As Integer = CInt(m_dDragPar)
+ ' Aggiusto Z punto movimentato (è in globale)
+ ptCurr.z = m_ptTableMin.z + CurrentMachine.dAdditionalTable + m_dHeight
+ ' Sposto il punto
+ If Not EgtModifyCurveCompoJoint(m_nSelDmg, nU, ptCurr, GDB_RT.GLOB) Then Return
+ ' Aggiorno cerchi
+ UpdateCircles()
+ ' Aggiorno visualizzazione
+ EgtDraw()
+ End Sub
+
Friend Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Disabilito modalità drag
m_bDrag = False
diff --git a/Utility/OmagOFFICEDictionary.xaml b/Utility/OmagOFFICEDictionary.xaml
index bf521e4..333f6e3 100644
--- a/Utility/OmagOFFICEDictionary.xaml
+++ b/Utility/OmagOFFICEDictionary.xaml
@@ -148,7 +148,7 @@
-
+