From 6c3b31ff7d7eedcebdf1db725200818d1a1604d0 Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Mon, 19 Dec 2016 19:08:57 +0000 Subject: [PATCH] EgtCAM5 : - Aggiunto bottone di scelta del file per il disegno utensile nel Db. - Aggiunto controllo per gestione RawPart in disposizione. - Piccoli miglioramenti enanched selection. --- EgtCAM5.vbproj | 10 +- MainWindow/MainWindow.xaml | 2 +- MainWindow/MainWindowViewModel.vb | 8 +- .../DispositionParameterExpanderView.xaml | 4 +- .../DispositionParameterExpanderViewModel.vb | 2 + .../DispositionUtility.vb | 0 .../RawPartOption/RawPartOptionView.xaml | 11 ++ .../RawPartOption/RawPartOptionView.xaml.vb | 3 + .../RawPartOption/RawPartOptionViewModel.vb | 46 +++++++ .../OperationExpanderViewModel.vb | 9 -- ProjectPage/ProjectViewModel.vb | 117 ++++++++++++++---- ToolsDbWindow/ToolTreeView.vb | 38 ++++++ ToolsDbWindow/ToolsDbView.xaml | 17 ++- 13 files changed, 222 insertions(+), 45 deletions(-) rename DispositionUtility.vb => ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionUtility.vb (100%) create mode 100644 ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml create mode 100644 ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml.vb create mode 100644 ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionViewModel.vb diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index 3dd58c1..1e6916a 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -192,6 +192,10 @@ FixtureParametersView.xaml + + RawPartOptionView.xaml + + @@ -268,7 +272,7 @@ - + ToolsDbView.xaml @@ -352,6 +356,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/MainWindow/MainWindow.xaml b/MainWindow/MainWindow.xaml index d7db726..b5b2d0a 100644 --- a/MainWindow/MainWindow.xaml +++ b/MainWindow/MainWindow.xaml @@ -33,7 +33,7 @@ - + diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb index 7f1eee8..e6905a2 100644 --- a/MainWindow/MainWindowViewModel.vb +++ b/MainWindow/MainWindowViewModel.vb @@ -80,7 +80,6 @@ Namespace EgtCAM5 Private m_bfirst As Boolean = True Public ReadOnly Property StatusBar As StatusBarView Get - Dim win As WindowCollection = Application.Current.Windows If m_bfirst Then m_bfirst = False m_StatusBar = New StatusBarView @@ -114,12 +113,7 @@ Namespace EgtCAM5 RegisterMyMessages() AddHandler Application.Current.MainWindow.KeyDown, AddressOf MainWindow_KeyDown - ' INITIALIZE GRAPHICS - 'TabList.Add(New ProjectViewModel) - 'TabList.Add(New ToolsDbViewModel) - 'TabList.Add(New MachiningsDbViewModel) - 'SelectedTab = TabList(0) - 'OnPropertyChanged("SelectedTab") + End Sub #End Region ' Constructor diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderView.xaml b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderView.xaml index ebfcba9..28be07e 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderView.xaml +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderView.xaml @@ -16,6 +16,8 @@ Style="{StaticResource ExpanderStyle}" Margin="0,1,0,1"> + + @@ -26,7 +28,7 @@ - + diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderViewModel.vb index 16459d9..65c8f6c 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderViewModel.vb +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionParameterExpanderViewModel.vb @@ -5,6 +5,8 @@ Namespace EgtCAM5 Public Class DispositionParameterExpanderViewModel Inherits ViewModelBase + + Public Enum ObjectType As Integer RAWPART = 1 PART = 2 diff --git a/DispositionUtility.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionUtility.vb similarity index 100% rename from DispositionUtility.vb rename to ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/DispositionUtility.vb diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml new file mode 100644 index 0000000..434eade --- /dev/null +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml.vb new file mode 100644 index 0000000..f95a626 --- /dev/null +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionView.xaml.vb @@ -0,0 +1,3 @@ +Public Class RawPartOptionView + +End Class diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionViewModel.vb new file mode 100644 index 0000000..0273703 --- /dev/null +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/DispositionParameterExpander/RawPartOption/RawPartOptionViewModel.vb @@ -0,0 +1,46 @@ +Imports EgtUILib + +Namespace EgtCAM5 + + Public Class RawPartOptionViewModel + Inherits ViewModelBase + + Private m_MoveWithFixture As Boolean = False + Public Property MoveWithFixture As Boolean + Get + Return m_MoveWithFixture + End Get + Set(value As Boolean) + If value <> m_MoveWithFixture Then + If value Then + ' Abilito la selezione di RawPart con autoselezione delle sue ventose + Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPARTWITHFIXTURE) + ' Seleziono le ventose associate ad uno dei grezzi selezionati + ' ciclo sui grezzi selezionati + Dim nSelRawPartId As Integer = EgtGetFirstSelectedObj() + While nSelRawPartId <> GDB_ID.NULL + ' seleziono i sottopezzi del grezzo + DispositionUtility.SelectRawPartFixture(nSelRawPartId) + nSelRawPartId = EgtGetNextSelectedObj() + End While + Else + ' Abilito la selezione di RawPart + Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPART) + ' ciclo sui grezzi selezionati + Dim nSelRawPartId As Integer = EgtGetFirstSelectedObj() + While nSelRawPartId <> GDB_ID.NULL + ' deseleziono i sottopezzi del grezzo + DispositionUtility.DeselectRawPartFixture(nSelRawPartId) + nSelRawPartId = EgtGetNextSelectedObj() + End While + End If + EgtDraw() + m_MoveWithFixture = value + OnPropertyChanged("MoveWithFixture") + End If + End Set + End Property + + End Class + +End Namespace \ No newline at end of file diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb index 8f15ef2..937b56e 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb @@ -6,15 +6,6 @@ Namespace EgtCAM5 Public Class OperationExpanderViewModel Inherits ViewModelBase - '' Variabili che indicano per ogni tipo di lavorazione quale geometria è selezionabile - 'Private m_SelGeomSawing As SceneSelModeOpt - 'Private m_SelGeomDrilling As SceneSelModeOpt - 'Private m_SelGeomMilling As SceneSelModeOpt - 'Private m_SelGeomPocketing As SceneSelModeOpt - 'Private m_SelGeomMortising As SceneSelModeOpt - 'Private m_SelGeomSawRoughing As SceneSelModeOpt - 'Private m_SelGeomSawFinishing As SceneSelModeOpt - ' Modalità di aggiunta attiva/disattiva Private m_NewMachining As Boolean = False diff --git a/ProjectPage/ProjectViewModel.vb b/ProjectPage/ProjectViewModel.vb index afc6376..ddc0fec 100644 --- a/ProjectPage/ProjectViewModel.vb +++ b/ProjectPage/ProjectViewModel.vb @@ -1028,6 +1028,18 @@ Namespace EgtCAM5 Dim SurfacesIdList As New List(Of Integer) Dim bEnhancedSelIsActive As Boolean = False Private Sub EnhancedMouseMoveScene(e As System.Windows.Forms.MouseEventArgs) + ' se un tasto di modifica è premuto + If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control OrElse (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse _ + (Keyboard.Modifiers And ModifierKeys.Alt) = ModifierKeys.Alt Then + ' verifico se c'è un elemento rimasto evidenziato + If nMarkedEntityId <> GDB_ID.NULL Then + ' lo deevidenzio + EgtResetMark(nMarkedEntityId) + nMarkedEntityId = GDB_ID.NULL + EgtDraw() + End If + Return + End If If bEnhancedSelecting Then Return bEnhancedSelecting = True ' recupero elementi presenti nel quadratino di selezione @@ -1036,6 +1048,10 @@ Namespace EgtCAM5 Dim nId As Integer = EgtGetFirstObjInSelWin() ' se esiste almeno un elemento nel quadratino di selezione Dim TempGroup As Integer + Dim vtZView As Vector3d + Dim vtYView As Vector3d + Dim vtXView As Vector3d + Dim frView As Frame3d If nId <> GDB_ID.NULL Then ' creo un gruppo temporaneo in cui mettere la proiezione sul piano della vista TempGroup = EgtCreateGroup(GDB_ID.ROOT) @@ -1045,6 +1061,14 @@ Namespace EgtCAM5 'EgtSetLevel(TempGroup, GDB_LV.USER) CurvesIdList.Clear() SurfacesIdList.Clear() + ' calcolo vettori e riferimento del punto di vista corrente + Dim dAngVertDeg As Double + Dim dAngOrizDeg As Double + EgtGetGenericView(dAngVertDeg, dAngOrizDeg) + vtZView = Vector3d.FromSpherical(1, dAngVertDeg, dAngOrizDeg) + EgtGetViewUp(vtYView) + vtXView = vtYView ^ vtZView + frView = New Frame3d(Point3d.ORIG, vtXView, vtYView, vtZView) Else If nMarkedEntityId <> GDB_ID.NULL Then EgtResetMark(nMarkedEntityId) @@ -1061,8 +1085,6 @@ Namespace EgtCAM5 Dim nCopyId As Integer = EgtCopyGlob(nId, TempGroup) EgtSetInfo(nCopyId, "OriginalId", nId) CurvesIdList.Add(nCopyId) - Case GDB_TY.SRF_FRGN, GDB_TY.SRF_MESH, GDB_TY.VOL_ZMAP - SurfacesIdList.Add(EgtCopyGlob(nId, TempGroup)) Case Else ' non faccio nulla End Select @@ -1077,21 +1099,22 @@ Namespace EgtCAM5 Dim dCurrDist As Double Dim dMinDist As Double ' proietto le curve sul piano di vista - Dim dAngVertDeg As Double - Dim dAngOrizDeg As Double - EgtGetGenericView(dAngVertDeg, dAngOrizDeg) - Dim vtZView As Vector3d = Vector3d.FromSpherical(1, dAngVertDeg, dAngOrizDeg) - Dim vtYView As Vector3d - EgtGetViewUp(vtYView) - Dim vtXView As Vector3d - vtXView = vtYView ^ vtZView - Dim frView As New Frame3d(Point3d.ORIG, vtXView, vtYView, vtZView) + 'Dim dAngVertDeg As Double + 'Dim dAngOrizDeg As Double + 'EgtGetGenericView(dAngVertDeg, dAngOrizDeg) + 'Dim vtZView As Vector3d = Vector3d.FromSpherical(1, dAngVertDeg, dAngOrizDeg) + 'Dim vtYView As Vector3d + 'EgtGetViewUp(vtYView) + 'Dim vtXView As Vector3d + 'vtXView = vtYView ^ vtZView + 'Dim frView As New Frame3d(Point3d.ORIG, vtXView, vtYView, vtZView) EgtScaleGroup(TempGroup, frView, 1, 1, 0) ' ciclo sulle proiezioni Dim bFirst As Boolean = True For Index = 0 To CurvesIdList.Count - 1 ' calcolo la distanza della curva dal punto di selezione per trovare quella a distanza minima - If EgtGetMinDistPntSidePointCurve(ptSel, CurvesIdList(Index), New Vector3d(-0.5, -0.5, 0.5), dCurrDist, New Point3d, New Integer) Then + If EgtGetMinDistPntSidePointCurve(ptSel, CurvesIdList(Index), vtZView, dCurrDist, New Point3d, New Integer) Then + EgtOutLog(CurvesIdList(Index) & " " & dCurrDist) If bFirst OrElse dCurrDist < dMinDist Then dMinDist = dCurrDist EgtGetInfo(CurvesIdList(Index), "OriginalId", ToMarkEntityId) @@ -1104,15 +1127,55 @@ Namespace EgtCAM5 EgtSetMark(ToMarkEntityId) nMarkedEntityId = ToMarkEntityId End If - ElseIf SurfacesIdList.Count > 0 Then - ToMarkEntityId = SurfacesIdList(0) - EgtSetMark(ToMarkEntityId) - nMarkedEntityId = ToMarkEntityId Else - EgtResetMark(nMarkedEntityId) - nMarkedEntityId = GDB_ID.NULL + + ' Verifico se sono presenti superfici nell'area di selezione + nId = EgtGetFirstObjInSelWin() + ' se ne esiste almeno una, creo il vettore normale + If nId <> GDB_ID.NULL Then + ' ciclo sugli elementi nell'area di selezione per crearne il bordo + While nId <> GDB_ID.NULL + ' li metto nelle due liste a seconda del tipo di entità + Select Case EgtGetType(nId) + Case GDB_TY.SRF_FRGN, GDB_TY.SRF_MESH, GDB_TY.VOL_ZMAP + Dim nCount As Integer = 0 + ' ne calcolo il contorno + Dim nSilhouetteId As Integer = EgtGetSurfTmSilhouette(nId, vtZView, TempGroup, GDB_RT.GLOB, nCount) + EgtSetInfo(nSilhouetteId, "OriginalId", nId) + + + SurfacesIdList.Add(nSilhouetteId) + Case Else + ' non faccio nulla + End Select + nId = EgtGetNextObjInSelWin() + End While + + End If + + If SurfacesIdList.Count > 0 Then + ' lo porto nel punto di vista + ' verifico se una di quelle prese è contenuta nelle altre + ' se si intersecano solamente calcolo il centro di ciascuna + ' e prendo quella con il centro più vicina al punto di selezione + + ' proietto i contorni sul piano di vista + EgtScaleGroup(TempGroup, frView, 1, 1, 0) + ' se sono contenuti uno nell'altro, seleziono quello contenuto, + ' altrimenti quello dietro + + EgtGetInfo(SurfacesIdList(0), "OriginalId", ToMarkEntityId) + If ToMarkEntityId <> nMarkedEntityId Then + EgtResetMark(nMarkedEntityId) + EgtSetMark(ToMarkEntityId) + nMarkedEntityId = ToMarkEntityId + End If + Else + EgtResetMark(nMarkedEntityId) + nMarkedEntityId = GDB_ID.NULL + End If End If - 'EgtSaveFile("c:\EgtData\Varie\Temp\ProveSelezione.nge", NGE.CMPTEXT) + EgtSaveFile("c:\EgtData\Varie\Temp\ProveSelezione.nge", NGE.CMPTEXT) ' cancello gruppo temporaneo EgtErase(TempGroup) EgtDraw() @@ -1131,7 +1194,9 @@ Namespace EgtCAM5 Private Sub OnMyMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_ProjectScene.OnMouseUpScene ' Se in modalità Draw esco If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then - EnhancedMouseUpScene(e) + If bEnhancedSelIsActive Then + EnhancedMouseUpScene(e) + End If Return End If ' Sono in modalità Machining @@ -1214,7 +1279,13 @@ Namespace EgtCAM5 ' Se oggetto già rifiutato non faccio le verifiche If Not bOk Then Return ' Se in modalità Draw accetto tutto - If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then Return + If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then + ' Se attiva enhanced selection rifiuto tutto + If bEnhancedSelIsActive Then + bOk = False + End If + Return + End If ' Sono in modalità Machining Select Case m_SceneSelType Case SceneSelTypeOpt.NULL @@ -1231,9 +1302,7 @@ Namespace EgtCAM5 End Sub Private Sub OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean) Handles m_ProjectScene.OnMouseSelectedObj - If Not bEnhancedSelIsActive Then - m_Controller.MouseSelectedObj(nId, bLast) - End If + m_Controller.MouseSelectedObj(nId, bLast) End Sub Private Sub OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer) Handles m_ProjectScene.OnMouseSelectedPart diff --git a/ToolsDbWindow/ToolTreeView.vb b/ToolsDbWindow/ToolTreeView.vb index 5975cf7..e847d7a 100644 --- a/ToolsDbWindow/ToolTreeView.vb +++ b/ToolsDbWindow/ToolTreeView.vb @@ -836,6 +836,9 @@ Public Class ToolTreeViewItem #End Region ' Tool Property + ' Definizione comandi + Private m_cmdOpenDrawFile As ICommand + #Region "Constructors" Sub New(Name As String) @@ -1482,6 +1485,41 @@ Public Class ToolTreeViewItem #End Region ' Validation +#Region "COMMANDS" + +#Region "OpenDrawFileCommand" + + ''' + ''' Returns a command that create a new tool. + ''' + Public ReadOnly Property OpenDrawFileCommand As ICommand + Get + If m_cmdOpenDrawFile Is Nothing Then + m_cmdOpenDrawFile = New Command(AddressOf OpenDrawFile) + End If + Return m_cmdOpenDrawFile + End Get + End Property + + ''' + ''' Creata the new tool. This method is invoked by the NewCommand. + ''' + Public Sub OpenDrawFile(ByVal param As Object) + Dim OpenFileDialog As New EgtWPFLib5.EgtOpenFileDialog + OpenFileDialog.Title = "Open draw file" + OpenFileDialog.Filter = "*.nge" + OpenFileDialog.Directory = IniFile.m_sCurrMachToolsDirPath + OpenFileDialog.FileName = m_Draw + If OpenFileDialog.ShowDialog <> True Then + Return + End If + Draw = Path.GetFileName(OpenFileDialog.FileName) + End Sub + +#End Region ' OpenDrawFileCommand + +#End Region ' Commands + End Class ''' diff --git a/ToolsDbWindow/ToolsDbView.xaml b/ToolsDbWindow/ToolsDbView.xaml index 9fc0a42..0f1e161 100644 --- a/ToolsDbWindow/ToolsDbView.xaml +++ b/ToolsDbWindow/ToolsDbView.xaml @@ -505,7 +505,12 @@ Visibility="{Binding Path=SelectedItem.Type, ElementName=ToolsTreeView, Converter={StaticResource ToolParamVisibilityConverter}, ConverterParameter={StaticResource Draw}}"/> - + + + + + - + +