From 3bf44d444dd39b451a760277b6d62cd5afa425c8 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 26 Jan 2015 07:55:00 +0000 Subject: [PATCH] TestEIn 1.6a4 : - sistemata gestione multi istanze (per log e registrazione comandi lua) - aggiornamento comandi per modifiche a EgtInterface. --- AboutBox1.Designer.vb | 7 +- AboutBox1.vb | 3 + Controller.vb | 112 ++++++++++++------------- EgtInterface.vb | 162 +++++++++++++++++++++---------------- Form1.vb | 43 ++++++++-- My Project/AssemblyInfo.vb | 4 +- 6 files changed, 191 insertions(+), 140 deletions(-) diff --git a/AboutBox1.Designer.vb b/AboutBox1.Designer.vb index d090d90..f8cb119 100644 --- a/AboutBox1.Designer.vb +++ b/AboutBox1.Designer.vb @@ -57,7 +57,7 @@ Partial Class AboutBox1 ' 'LabelCompanyName ' - Me.LabelCompanyName.Location = New System.Drawing.Point(108, 77) + Me.LabelCompanyName.Location = New System.Drawing.Point(108, 78) Me.LabelCompanyName.Margin = New System.Windows.Forms.Padding(6, 0, 3, 0) Me.LabelCompanyName.MaximumSize = New System.Drawing.Size(152, 17) Me.LabelCompanyName.MinimumSize = New System.Drawing.Size(152, 17) @@ -81,7 +81,7 @@ Partial Class AboutBox1 ' 'LabelVersion ' - Me.LabelVersion.Location = New System.Drawing.Point(108, 41) + Me.LabelVersion.Location = New System.Drawing.Point(108, 40) Me.LabelVersion.Margin = New System.Windows.Forms.Padding(6, 0, 3, 0) Me.LabelVersion.MaximumSize = New System.Drawing.Size(152, 17) Me.LabelVersion.MinimumSize = New System.Drawing.Size(152, 17) @@ -93,7 +93,7 @@ Partial Class AboutBox1 ' 'LabelProductName ' - Me.LabelProductName.Location = New System.Drawing.Point(108, 23) + Me.LabelProductName.Location = New System.Drawing.Point(108, 21) Me.LabelProductName.Margin = New System.Windows.Forms.Padding(6, 0, 3, 0) Me.LabelProductName.MaximumSize = New System.Drawing.Size(152, 17) Me.LabelProductName.MinimumSize = New System.Drawing.Size(152, 17) @@ -136,7 +136,6 @@ Partial Class AboutBox1 Me.ShowInTaskbar = False Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "AboutBox1" - Me.TopMost = True CType(Me.LogoPictureBox, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() diff --git a/AboutBox1.vb b/AboutBox1.vb index 7dd7889..ba6a3d1 100644 --- a/AboutBox1.vb +++ b/AboutBox1.vb @@ -17,6 +17,9 @@ Public NotInheritable Class AboutBox1 Me.LabelCopyright.Text = My.Application.Info.Copyright Me.LabelCompanyName.Text = My.Application.Info.CompanyName Dim sbInfo As New System.Text.StringBuilder + sbInfo.Append("User " & SystemInformation.UserName & + "\" & SystemInformation.ComputerName & + " Inst=" & Form1.GetInstance() & vbCrLf) sbInfo.Append("ExeRoot " & Form1.GetExeRoot() & vbCrLf) sbInfo.Append("DataRoot " & Form1.GetDataRoot() & vbCrLf) Dim sTemp As String = String.Empty diff --git a/Controller.vb b/Controller.vb index 6345b12..dde29df 100644 --- a/Controller.vb +++ b/Controller.vb @@ -1023,7 +1023,7 @@ Public Class Controller End If EnableCommandLog() ' inserisco un nuovo gruppo (layer) sotto il pezzo corrente - Dim nIdNewLayer As Integer = EgtCreateGroup(m_nCurrPart) + Dim nIdNewLayer As Integer = EgtCreateGroup(m_nCurrPart, Frame3d.GLOB(), REF_TY.GRID) DisableCommandLog() ' se ok, salvo nuova situazione If nIdNewLayer <> GDB_ID.NULL Then @@ -1515,7 +1515,7 @@ Public Class Controller If nId = GDB_ID.NULL Then EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, REF_TY.GLOB) Else - EgtModifyCurveEndPoint(nId, m_ptLast) + EgtModifyCurveEndPoint(nId, m_ptLast, REF_TY.GLOB) End If ' altrimenti, uno dei punti tangente o normale Else @@ -1598,7 +1598,7 @@ Public Class Controller EgtCreateCurveLinePVL(m_Scene.GetDragGroup(), m_ptP1, vtDirS, m_dAux, REF_TY.GLOB) Else Dim ptP2 As Point3d = m_ptP1 + vtDirS * m_dAux - EgtModifyCurveEndPoint(nId, ptP2) + EgtModifyCurveEndPoint(nId, ptP2, REF_TY.GLOB) End If EgtDraw() ElseIf m_nStep = 3 Then ' inserimento lunghezza @@ -1660,7 +1660,7 @@ Public Class Controller If nId = GDB_ID.NULL Then EgtCreateCurveCircleCPN(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, EgtGetGridVersZ(), REF_TY.GLOB) Else - EgtModifyCurveCircleCPN(nId, m_ptLast) + EgtModifyCurveCircleCPN(nId, m_ptLast, REF_TY.GLOB) End If EgtDraw() End If @@ -1787,7 +1787,7 @@ Public Class Controller If nId = GDB_ID.NULL Then EgtCreateCurveArcC2PN(m_Scene.GetDragGroup(), m_ptP1, m_ptP2, m_ptLast, EgtGetGridVersZ(), REF_TY.GLOB) Else - EgtModifyCurveArcC2PN(nId, m_ptLast) + EgtModifyCurveArcC2PN(nId, m_ptLast, REF_TY.GLOB) End If EgtDraw() End If @@ -1866,7 +1866,7 @@ Public Class Controller EgtCreateCurveArc3P(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, m_ptP2, REF_TY.GLOB) Else ' se modifica arco 3P impossibile, provo con una retta - If (Not EgtModifyCurveArc3P(nId, m_ptLast) AndAlso + If (Not EgtModifyCurveArc3P(nId, m_ptLast, REF_TY.GLOB) AndAlso (m_ptLast - m_ptP1) * (m_ptP2 - m_ptLast) > EPS_ZERO) Then EgtErase(nId) EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptP2, REF_TY.GLOB) @@ -1944,7 +1944,7 @@ Public Class Controller EgtCreateCurveLinePVL(m_Scene.GetDragGroup(), m_ptP1, vtDirS, m_dAux, REF_TY.GLOB) Else Dim ptP2 As Point3d = m_ptP1 + vtDirS * m_dAux - EgtModifyCurveEndPoint(nId, ptP2) + EgtModifyCurveEndPoint(nId, ptP2, REF_TY.GLOB) End If EgtDraw() ElseIf m_nStep = 3 Then @@ -2639,7 +2639,7 @@ Public Class Controller ' eseguo estensione sull'estremo più vicino al punto di selezione Dim nId As Integer = EgtGetLastSelectedObj() EnableCommandLog() - EgtTrimExtendCurveByLen(nId, m_dLast, m_ptP1.Loc(nId)) + EgtTrimExtendCurveByLen(nId, m_dLast, m_ptP1.Loc(GDB_ID.GRID), REF_TY.GRID) DisableCommandLog() EgtUnselectableRemove(nId) ' reset stato scena @@ -2666,7 +2666,7 @@ Public Class Controller Dim dAddLen As Double = IIf(bSpecial, EXTEND_ADD, 0) ' eseguo trim/estensione sull'estremo più vicino al punto di selezione Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup()) - EgtTrimExtendCurveByLen(nId, m_dLast + dAddLen, m_ptP1) + EgtTrimExtendCurveByLen(nId, m_dLast + dAddLen, m_ptP1, REF_TY.GLOB) EgtDraw() End If Return False @@ -2713,7 +2713,7 @@ Public Class Controller ' eseguo spezzatura Dim nId As Integer = EgtGetLastSelectedObj() EnableCommandLog() - EgtSplitCurveAtPoint(nId, m_ptLast.Loc(nId)) + EgtSplitCurveAtPoint(nId, m_ptLast.Loc(GDB_ID.GRID), REF_TY.GRID) DisableCommandLog() ' reset stato scena m_Scene.ResetStatus() @@ -2749,7 +2749,7 @@ Public Class Controller End While ' creo la curva composita (concatenando le curve selezionate) EnableCommandLog() - EgtCreateCurveCompoByChain(GetCurrLayer(), nCrvNum, nCrvIds, New Point3d, True) + EgtCreateCurveCompoByChain(GetCurrLayer(), nCrvNum, nCrvIds, New Point3d, True, REF_TY.GRID) DisableCommandLog() ' reset stato scena m_Scene.ResetStatus() @@ -2815,12 +2815,7 @@ Public Class Controller EnableCommandLog() ' se richiesto, imposto direzione estrusione If m_bLast Then - Dim vtExtr = EgtGetGridVersZ() - Dim nId As Integer = EgtGetFirstSelectedObj() - While nId <> GDB_ID.NULL - EgtModifyCurveExtrusion(nId, vtExtr.Loc(nId)) - nId = EgtGetNextSelectedObj() - End While + EgtModifyCurveExtrusion(GDB_ID.SEL, Vector3d.Z_AX, REF_TY.GRID) End If ' eseguo impostazione spessore curve selezionate EgtModifyCurveThickness(GDB_ID.SEL, m_dLast) @@ -2839,23 +2834,24 @@ Public Class Controller Private Sub DragSetCurveThickness() If m_nStep = 1 Then - ' imposto direzione estrusione - Dim vtExtr = EgtGetGridVersZ() - Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup()) - While nId <> GDB_ID.NULL - If m_bLast Then - EgtModifyCurveExtrusion(nId, vtExtr.Loc(nId)) - Else + ' imposto direzione estrusione da Z griglia + If m_bLast Then + EgtModifyCurveExtrusion(m_Scene.GetDragGroup(), EgtGetGridVersZ(), REF_TY.GLOB) + ' ripristino direzione estrusione originale + Else + ' ogni entità deve riprendere la sua propria estrusione originale + Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup()) + While nId <> GDB_ID.NULL Dim nOrigId As Integer Dim vtOrigExtr As Vector3d If EgtGetInfo(nId, "Id", nOrigId) And EgtCurveExtrusion(nOrigId, vtOrigExtr) Then - EgtModifyCurveExtrusion(nId, vtOrigExtr.Glob(nOrigId)) + EgtModifyCurveExtrusion(nId, vtOrigExtr.Glob(nOrigId), REF_TY.GLOB) End If - End If - nId = EgtGetNext(nId) - End While + nId = EgtGetNext(nId) + End While + End If ' eseguo impostazione spessore curve selezionate - EgtModifyCurveThickness(GDB_ID.SEL, m_dLast) + EgtModifyCurveThickness(m_Scene.GetDragGroup(), m_dLast) EgtDraw() End If End Sub @@ -2904,12 +2900,12 @@ Public Class Controller Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer()) - EgtMoveGlob(nCopyId, (m_ptLast - m_ptP1)) + EgtMove(nCopyId, (m_ptLast - m_ptP1).Loc(GDB_ID.GRID), REF_TY.GRID) nId = EgtGetNextSelectedObj() End While ' eseguo movimento Else - EgtMoveGlob(GDB_ID.SEL, (m_ptLast - m_ptP1)) + EgtMove(GDB_ID.SEL, (m_ptLast - m_ptP1).Loc(GDB_ID.GRID), REF_TY.GRID) End If DisableCommandLog() EgtDraw() @@ -2928,7 +2924,7 @@ Public Class Controller ' ripristino lo stato iniziale EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB) ' eseguo tutto il movimento - EgtMoveGlob(m_Scene.GetDragGroup(), (m_ptLast - m_ptP1)) + EgtMove(m_Scene.GetDragGroup(), (m_ptLast - m_ptP1), REF_TY.GLOB) EgtSetGeoLine(m_ptP1, m_ptLast) EgtDraw() End If @@ -2973,12 +2969,12 @@ Public Class Controller Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer()) - EgtRotateGlob(nCopyId, m_ptP1, EgtGetGridVersZ(), dAngRotDeg) + EgtRotate(nCopyId, m_ptP1.Loc(GDB_ID.GRID), Vector3d.Z_AX, dAngRotDeg, REF_TY.GRID) nId = EgtGetNextSelectedObj() End While ' eseguo rotazione Else - EgtRotateGlob(GDB_ID.SEL, m_ptP1, EgtGetGridVersZ(), dAngRotDeg) + EgtRotate(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), Vector3d.Z_AX, dAngRotDeg, REF_TY.GRID) End If DisableCommandLog() EgtDraw() @@ -3004,7 +3000,7 @@ Public Class Controller Dim dAngRotDeg As Double = 0 Dim bDet As Boolean = True EgtGetVectorRotation((m_ptP2 - m_ptP1), (m_ptLast - m_ptP1), EgtGetGridVersZ(), dAngRotDeg, bDet) - EgtRotateGlob(m_Scene.GetDragGroup(), m_ptP1, EgtGetGridVersZ(), dAngRotDeg) + EgtRotate(m_Scene.GetDragGroup(), m_ptP1, EgtGetGridVersZ(), dAngRotDeg, REF_TY.GLOB) EgtDraw() End If End Sub @@ -3047,12 +3043,12 @@ Public Class Controller Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer()) - EgtRotateGlob(nCopyId, m_ptP1, VtAx, m_dLast) + EgtRotate(nCopyId, m_ptP1.Loc(GDB_ID.GRID), VtAx.Loc(GDB_ID.GRID), m_dLast, REF_TY.GRID) nId = EgtGetNextSelectedObj() End While ' eseguo rotazione Else - EgtRotateGlob(GDB_ID.SEL, m_ptP1, VtAx, m_dLast) + EgtRotate(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), VtAx.Loc(GDB_ID.GRID), m_dLast, REF_TY.GRID) End If DisableCommandLog() EgtDraw() @@ -3076,7 +3072,7 @@ Public Class Controller EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB) ' eseguo rotazione Dim VtAx As Vector3d = m_ptP2 - m_ptP1 - EgtRotateGlob(m_Scene.GetDragGroup(), m_ptP1, VtAx, m_dLast) + EgtRotate(m_Scene.GetDragGroup(), m_ptP1, VtAx, m_dLast, REF_TY.GLOB) EgtDraw() End If End Sub @@ -3113,12 +3109,12 @@ Public Class Controller Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer()) - EgtMirrorGlob(nCopyId, m_ptP1, VtNorm) + EgtMirror(nCopyId, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), REF_TY.GRID) nId = EgtGetNextSelectedObj() End While ' eseguo mirror Else - EgtMirrorGlob(GDB_ID.SEL, m_ptP1, VtNorm) + EgtMirror(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), REF_TY.GRID) End If DisableCommandLog() End If @@ -3140,12 +3136,12 @@ Public Class Controller ' ripristino lo stato iniziale, tramite annullo mirror precedente Dim VtNorm As Vector3d = (m_ptP2 - m_ptP1) ^ EgtGetGridVersZ() If VtNorm.Len > EPS_SMALL Then - EgtMirrorGlob(m_Scene.GetDragGroup(), m_ptP1, VtNorm) + EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, REF_TY.GLOB) End If ' eseguo mirror VtNorm = (m_ptLast - m_ptP1) ^ EgtGetGridVersZ() If VtNorm.Len > EPS_SMALL Then - EgtMirrorGlob(m_Scene.GetDragGroup(), m_ptP1, VtNorm) + EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, REF_TY.GLOB) End If ' salvo il punto m_ptP2 = m_ptLast @@ -3192,12 +3188,12 @@ Public Class Controller Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer()) - EgtMirrorGlob(nCopyId, m_ptP1, VtNorm) + EgtMirror(nCopyId, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), REF_TY.GRID) nId = EgtGetNextSelectedObj() End While ' eseguo mirror Else - EgtMirrorGlob(GDB_ID.SEL, m_ptP1, VtNorm) + EgtMirror(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), REF_TY.GRID) End If DisableCommandLog() End If @@ -3223,12 +3219,12 @@ Public Class Controller ' ripristino lo stato iniziale, tramite annullo mirror precedente Dim VtNorm As Vector3d = (m_ptP3 - m_ptP1) ^ (m_ptP2 - m_ptP1) If VtNorm.Len > EPS_SMALL Then - EgtMirrorGlob(m_Scene.GetDragGroup(), m_ptP1, VtNorm) + EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, REF_TY.GLOB) End If ' eseguo mirror VtNorm = (m_ptLast - m_ptP1) ^ (m_ptP2 - m_ptP1) If VtNorm.Len > EPS_SMALL Then - EgtMirrorGlob(m_Scene.GetDragGroup(), m_ptP1, VtNorm) + EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, REF_TY.GLOB) End If ' salvo il punto m_ptP3 = m_ptLast @@ -3260,21 +3256,18 @@ Public Class Controller SetInputBoxDouble(m_dLast) Case 2 m_Scene.ResetStatus(False) - ' calcolo parametri di scalatura - Dim frScale As New Frame3d(EgtGetGridFrame()) - frScale.ChangeOrigin(m_ptP1) EnableCommandLog() ' eseguo copia e scalatura If m_bLast Then Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer()) - EgtScaleGlob(nCopyId, frScale, m_dLast, m_dLast, m_dLast) + EgtScale(nCopyId, New Frame3d(m_ptP1), m_dLast, m_dLast, m_dLast, REF_TY.GRID) nId = EgtGetNextSelectedObj() End While ' eseguo scalatura Else - EgtScaleGlob(GDB_ID.SEL, frScale, m_dLast, m_dLast, m_dLast) + EgtScale(GDB_ID.SEL, New Frame3d(m_ptP1), m_dLast, m_dLast, m_dLast, REF_TY.GRID) End If DisableCommandLog() EgtDraw() @@ -3299,7 +3292,7 @@ Public Class Controller frScale.ChangeOrigin(m_ptP1) Dim dScale As Double = m_dLast / m_dPrev ' eseguo scalatura - EgtScaleGlob(m_Scene.GetDragGroup(), frScale, dScale, dScale, dScale) + EgtScale(m_Scene.GetDragGroup(), frScale, dScale, dScale, dScale, REF_TY.GLOB) m_dPrev = m_dLast EgtDraw() End If @@ -3334,21 +3327,18 @@ Public Class Controller SetInputBox3Double(m_d3Last) Case 2 m_Scene.ResetStatus(False) - ' calcolo parametri di scalatura - Dim frScale As New Frame3d(EgtGetGridFrame()) - frScale.ChangeOrigin(m_ptP1) EnableCommandLog() ' eseguo copia e scalatura If m_bLast Then Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer()) - EgtScaleGlob(nCopyId, frScale, m_d3Last(0), m_d3Last(1), m_d3Last(2)) + EgtScale(nCopyId, New Frame3d(m_ptP1), m_d3Last(0), m_d3Last(1), m_d3Last(2), REF_TY.GRID) nId = EgtGetNextSelectedObj() End While ' eseguo scalatura Else - EgtScaleGlob(GDB_ID.SEL, frScale, m_d3Last(0), m_d3Last(1), m_d3Last(2)) + EgtScale(GDB_ID.SEL, New Frame3d(m_ptP1), m_d3Last(0), m_d3Last(1), m_d3Last(2), REF_TY.GRID) End If DisableCommandLog() EgtDraw() @@ -3385,7 +3375,7 @@ Public Class Controller d3Scale(1) = m_d3Last(1) / m_d3Prev(1) d3Scale(2) = m_d3Last(2) / m_d3Prev(2) ' eseguo scalatura - EgtScaleGlob(m_Scene.GetDragGroup(), frScale, d3Scale(0), d3Scale(1), d3Scale(2)) + EgtScale(m_Scene.GetDragGroup(), frScale, d3Scale(0), d3Scale(1), d3Scale(2), REF_TY.GLOB) m_d3Prev(0) = m_d3Last(0) m_d3Prev(1) = m_d3Last(1) m_d3Prev(2) = m_d3Last(2) @@ -3667,13 +3657,13 @@ Public Class Controller '-------------------------------- Registrazione Comandi (in Lua) --------------------------------- Private m_bCommandLog As Boolean = False - Public Function SetCommandLog(ByVal bCmdLog As Boolean, ByRef sCmdLogDir As String) As Boolean + Public Function SetCommandLog(ByVal bCmdLog As Boolean, ByVal sCmdLogDir As String, ByVal nId As Integer) As Boolean ' imposto stato m_bCommandLog = bCmdLog ' se necessario inizializzo logger If m_bCommandLog Then - Const sCmdLog As String = "EInCmdLua.log" - Const sCmdBak As String = sCmdLog & ".bak" + Dim sCmdLog As String = "EInCmdLua" & nId & ".log" + Dim sCmdBak As String = sCmdLog & ".bak" Dim sFile = sCmdLogDir & "\" & sCmdLog Dim sBackup = sCmdLogDir & "\" & sCmdBak ' se logger già in uso, non faccio alcunchè e non lo avvio diff --git a/EgtInterface.vb b/EgtInterface.vb index 86ea2f5..4cff46b 100644 --- a/EgtInterface.vb +++ b/EgtInterface.vb @@ -592,6 +592,10 @@ End Sub Public Function EgtFreeMemory(ByVal sB As IntPtr) As Boolean End Function + +Public Function EgtOutLog(ByVal sMag As String) As Boolean +End Function + '---------- Geo Base ----------------------------------------------------------- @@ -835,7 +839,7 @@ End Function '---------- GeomDb Objects Create ---------------------------------------------- Private Function EgtCreateGroup(ByVal nParentId As Integer, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, ByVal nRefType As REF_TY) As Integer + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, ByVal nRefType As REF_TY) As Integer End Function Public Function EgtCreateGroup(ByVal nParentId As Integer, ByRef frRef As Frame3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Integer Return EgtCreateGroup(nParentId, frRef.Orig(), frRef.VersX(), frRef.VersY(), frRef.VersZ(), nRefType) @@ -906,7 +910,8 @@ Public Function EgtCreateCurveArc2PVN(ByVal nParentId As Integer, End Function -Public Function EgtCreateCurveCompoByChain(ByVal nParentId As Integer, ByVal nNumCrv As Integer, ByVal nCrvId() As Integer, ByRef PtNearStart As Point3d, ByVal bCrvErase As Boolean) As Integer +Public Function EgtCreateCurveCompoByChain(ByVal nParentId As Integer, ByVal nNumCrv As Integer, ByVal nCrvId() As Integer, + ByRef PtNearStart As Point3d, ByVal bCrvErase As Boolean, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Integer End Function @@ -960,11 +965,15 @@ End Function '---------- GeomDb Objects Modify ---------------------------------------------- -Private Function EgtChangeGroupFrame(ByVal nId As Integer, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean +Private Function EgtChangeGroupFrame(ByVal nId As Integer, ByRef PtOrig As Point3d, + ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, ByVal nRefType As REF_TY) As Boolean End Function -Public Function EgtChangeGroupFrame(ByVal nId As Integer, ByRef frRef As Frame3d) As Boolean - Return EgtChangeGroupFrame(nId, frRef.Orig(), frRef.VersX(), frRef.VersY(), frRef.VersZ()) +Public Function EgtChangeGroupFrame(ByVal nId As Integer, ByRef frRef As Frame3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean + Return EgtChangeGroupFrame(nId, frRef.Orig(), frRef.VersX(), frRef.VersY(), frRef.VersZ(), nRefType) +End Function + + +Public Function EgtChangeVectorBase(ByVal nId As Integer, ByRef PtBase As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function @@ -990,19 +999,15 @@ Public Function EgtInvertCurve(ByVal nId As Integer) As Boolean End Function -Public Function EgtModifyCurveStartPoint(ByVal nId As Integer, ByRef PtStart As Point3d) As Boolean +Public Function EgtModifyCurveStartPoint(ByVal nId As Integer, ByRef PtStart As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function -Public Function EgtModifyCurveEndPoint(ByVal nId As Integer, ByRef PtEnd As Point3d) As Boolean +Public Function EgtModifyCurveEndPoint(ByVal nId As Integer, ByRef PtEnd As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function -Public Function EgtModifyCurveExtrusion(ByVal nId As Integer, ByRef VtExtr As Vector3d) As Boolean -End Function - - -Public Function EgtSetCurveExtrusionFromGrid(ByVal nId As Integer) As Boolean +Public Function EgtModifyCurveExtrusion(ByVal nId As Integer, ByRef VtExtr As Vector3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function @@ -1018,11 +1023,11 @@ Public Function EgtExtendCurveEndByLen(ByVal nId As Integer, ByVal dLen As Doubl End Function -Public Function EgtTrimExtendCurveByLen(ByVal nId As Integer, ByVal dLen As Double, ByRef PtNear As Point3d) As Boolean +Public Function EgtTrimExtendCurveByLen(ByVal nId As Integer, ByVal dLen As Double, ByRef PtNear As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function -Public Function EgtSplitCurveAtPoint(ByVal nId As Integer, ByRef PtOn As Point3d) As Boolean +Public Function EgtSplitCurveAtPoint(ByVal nId As Integer, ByRef PtOn As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function @@ -1030,7 +1035,7 @@ Public Function EgtOffsetCurve(ByVal nId As Integer, ByVal dDist As Double, ByVa End Function -Public Function EgtModifyCurveCircleCPN(ByVal nId As Integer, ByRef PtOn As Point3d) As Boolean +Public Function EgtModifyCurveCircleCPN(ByVal nId As Integer, ByRef PtOn As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function @@ -1038,11 +1043,11 @@ Public Function EgtModifyCurveArcRadius(ByVal nId As Integer, ByVal dRad As Doub End Function -Public Function EgtModifyCurveArcC2PN(ByVal nId As Integer, ByRef PtEnd As Point3d) As Boolean +Public Function EgtModifyCurveArcC2PN(ByVal nId As Integer, ByRef PtEnd As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function -Public Function EgtModifyCurveArc3P(ByVal nId As Integer, ByRef PtMid As Point3d) As Boolean +Public Function EgtModifyCurveArc3P(ByVal nId As Integer, ByRef PtMid As Point3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function @@ -1417,49 +1422,40 @@ End Function '---------- GeomDb Obj Transform ----------------------------------------------- -Public Function EgtMove(ByVal nId As Integer, ByRef VtMove As Vector3d) As Boolean +Public Function EgtMove(ByVal nId As Integer, ByRef VtMove As Vector3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function -Public Function EgtMoveGlob(ByVal nId As Integer, ByRef VtMove As Vector3d) As Boolean +Public Function EgtRotate(ByVal nId As Integer, ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean +End Function + + +Private Function EgtScale(ByVal nId As Integer, ByRef PtOrig As Point3d, + ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double, ByVal nRefType As REF_TY) As Boolean +End Function +Public Function EgtScale(ByVal nId As Integer, ByRef Frame As Frame3d, + ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean + Return EgtScale(nId, Frame.Orig(), Frame.VersX(), Frame.VersY(), Frame.VersZ(), dCoeffX, dCoeffY, dCoeffZ, nRefType) +End Function + + +Public Function EgtMirror(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean +End Function + + +Public Function EgtShear(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d, + ByRef VtDir As Vector3d, ByVal dCoeff As Double, Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Boolean End Function Public Function EgtMoveGroup(ByVal nId As Integer, ByRef VtMove As Vector3d) As Boolean End Function - -Public Function EgtRotate(ByVal nId As Integer, ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean -End Function - - -Public Function EgtRotateGlob(ByVal nId As Integer, ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean -End Function - Public Function EgtRotateGroup(ByVal nId As Integer, ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean End Function - -Private Function EgtScale(ByVal nId As Integer, ByRef PtOrig As Point3d, - ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean -End Function -Public Function EgtScale(ByVal nId As Integer, ByRef Frame As Frame3d, - ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean - Return EgtScale(nId, Frame.Orig(), Frame.VersX(), Frame.VersY(), Frame.VersZ(), dCoeffX, dCoeffY, dCoeffZ) -End Function - - -Private Function EgtScaleGlob(ByVal nId As Integer, ByRef PtOrig As Point3d, - ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean -End Function -Public Function EgtScaleGlob(ByVal nId As Integer, ByRef Frame As Frame3d, - ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean - Return EgtScaleGlob(nId, Frame.Orig(), Frame.VersX(), Frame.VersY(), Frame.VersZ(), dCoeffX, dCoeffY, dCoeffZ) -End Function - Private Function EgtScaleGroup(ByVal nId As Integer, ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, @@ -1470,28 +1466,10 @@ Public Function EgtScaleGroup(ByVal nId As Integer, ByRef Frame As Frame3d, Return EgtScaleGroup(nId, Frame.Orig(), Frame.VersX(), Frame.VersY(), Frame.VersZ(), dCoeffX, dCoeffY, dCoeffZ) End Function - -Public Function EgtMirror(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d) As Boolean -End Function - - -Public Function EgtMirrorGlob(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d) As Boolean -End Function - Public Function EgtMirrorGroup(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d) As Boolean End Function - -Public Function EgtShear(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d, - ByRef VtDir As Vector3d, ByVal dCoeff As Double) As Boolean -End Function - - -Public Function EgtShearGlob(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d, - ByRef VtDir As Vector3d, ByVal dCoeff As Double) As Boolean -End Function - Public Function EgtShearGroup(ByVal nId As Integer, ByRef PtOn As Point3d, ByRef VtNorm As Vector3d, ByRef VtDir As Vector3d, ByVal dCoeff As Double) As Boolean @@ -1500,44 +1478,82 @@ End Function '---------- GeomDb Snap Vector/Point/Frame ------------------------------------- +Public Function EgtStartPoint(ByVal nId As Integer, ByVal nRefId As Integer, ByRef PtP As Point3d) As Boolean +End Function Public Function EgtStartPoint(ByVal nId As Integer, ByRef PtP As Point3d) As Boolean + Return EgtStartPoint(nId, nId, PtP) End Function +Public Function EgtEndPoint(ByVal nId As Integer, ByVal nRefId As Integer, ByRef PtP As Point3d) As Boolean +End Function Public Function EgtEndPoint(ByVal nId As Integer, ByRef PtP As Point3d) As Boolean + Return EgtEndPoint(nId, nId, PtP) End Function +Public Function EgtMidPoint(ByVal nId As Integer, ByVal nRefId As Integer, ByRef PtP As Point3d) As Boolean +End Function Public Function EgtMidPoint(ByVal nId As Integer, ByRef PtP As Point3d) As Boolean + Return EgtMidPoint(nId, nId, PtP) End Function +Public Function EgtCenterPoint(ByVal nId As Integer, ByVal nRefId As Integer, ByRef PtP As Point3d) As Boolean +End Function Public Function EgtCenterPoint(ByVal nId As Integer, ByRef PtP As Point3d) As Boolean + Return EgtCenterPoint(nId, nId, PtP) End Function +Public Function EgtAtParamPoint(ByVal nId As Integer, ByVal dU As Double, ByVal nRefId As Integer, ByRef PtP As Point3d) As Boolean +End Function Public Function EgtAtParamPoint(ByVal nId As Integer, ByVal dU As Double, ByRef PtP As Point3d) As Boolean + Return EgtAtParamPoint(nId, dU, nId, PtP) +End Function + + +Public Function EgtNearPoint(ByVal nId As Integer, ByRef PtNear As Point3d, ByVal nRefId As Integer, ByRef PtP As Point3d) As Boolean +End Function +Public Function EgtNearPoint(ByVal nId As Integer, ByRef PtNear As Point3d, ByRef PtP As Point3d) As Boolean + Return EgtNearPoint(nId, PtNear, nId, PtP) End Function Public Function EgtIntersectionPoint(ByVal nId1 As Integer, ByVal nId2 As Integer, ByRef PtNear As Point3d, - ByRef PtP As Point3d) As Boolean + ByVal nRefId As Integer, ByRef PtP As Point3d) As Boolean +End Function +Public Function EgtIntersectionPoint(ByVal nId1 As Integer, ByVal nId2 As Integer, ByRef PtNear As Point3d, + ByRef PtP As Point3d) As Boolean + Return EgtIntersectionPoint(nId1, nId2, PtNear, nId1, PtP) End Function +Public Function EgtStartVector(ByVal nId As Integer, ByVal nRefId As Integer, ByRef VtV As Vector3d) As Boolean +End Function Public Function EgtStartVector(ByVal nId As Integer, ByRef VtV As Vector3d) As Boolean + Return EgtStartVector(nId, nId, VtV) End Function +Public Function EgtEndVector(ByVal nId As Integer, ByVal nRefId As Integer, ByRef VtV As Vector3d) As Boolean +End Function Public Function EgtEndVector(ByVal nId As Integer, ByRef VtV As Vector3d) As Boolean + Return EgtEndVector(nId, nId, VtV) End Function +Public Function EgtMidVector(ByVal nId As Integer, ByVal nRefId As Integer, ByRef VtV As Vector3d) As Boolean +End Function Public Function EgtMidVector(ByVal nId As Integer, ByRef VtV As Vector3d) As Boolean + Return EgtMidVector(nId, nId, VtV) End Function +Public Function EgtAtParamVector(ByVal nId As Integer, ByVal dU As Double, ByVal nRefId As Integer, ByRef VtV As Vector3d) As Boolean +End Function Public Function EgtAtParamVector(ByVal nId As Integer, ByVal dU As Double, ByRef VtV As Vector3d) As Boolean + Return EgtAtParamVector(nId, dU, nId, VtV) End Function @@ -1549,7 +1565,10 @@ Public Function EgtCurveLengthAtPoint(ByVal nId As Integer, ByRef ptOn As Point3 End Function +Public Function EgtCurveExtrusion(ByVal nId As Integer, ByVal nRefId As Integer, ByRef VtExtr As Vector3d) As Boolean +End Function Public Function EgtCurveExtrusion(ByVal nId As Integer, ByRef VtExtr As Vector3d) As Boolean + Return EgtCurveExtrusion(nId, nId, VtExtr) End Function @@ -1566,11 +1585,17 @@ Public Function EgtGetMinDistPntSidePointCurve(ByRef ptP As Point3d, ByVal nId A End Function +Public Function EgtExtTextNormVersor(ByVal nId As Integer, ByVal nRefId As Integer, ByRef VtNorm As Vector3d) As Boolean +End Function Public Function EgtExtTextNormVersor(ByVal nId As Integer, ByRef VtNorm As Vector3d) As Boolean + Return EgtExtTextNormVersor(nId, nId, VtNorm) End Function +Public Function EgtCurveArcNormVersor(ByVal nId As Integer, ByVal nRefId As Integer, ByRef VtNorm As Vector3d) As Boolean +End Function Public Function EgtCurveArcNormVersor(ByVal nId As Integer, ByRef VtNorm As Vector3d) As Boolean + Return EgtCurveArcNormVersor(nId, nId, VtNorm) End Function @@ -1912,7 +1937,8 @@ Public Enum GDB_TY As Integer CRV_BEZ = 258 CRV_COMPO = 259 SRF_MESH = 512 - EXT_TEXT = 1024 + VOL_ZMAP = 1024 + EXT_TEXT = 2048 End Enum 'Costanti : TIPO RIFERIMENTO DI DATI GEOMETRICI Public Enum REF_TY As Integer diff --git a/Form1.vb b/Form1.vb index 753ae16..541aa7c 100644 --- a/Form1.vb +++ b/Form1.vb @@ -12,6 +12,7 @@ '---------------------------------------------------------------------------- Imports System.Runtime.InteropServices +Imports System.Threading Imports System.Text Imports System.Math Imports System.IO @@ -23,6 +24,8 @@ Imports TestEIn.Controller Public Class Form1 + Private m_objMutex As Mutex + Private m_nInstance As Integer = 0 Private m_sDataRoot As String = String.Empty Private m_sIniFile As String = String.Empty Private WithEvents m_Controller As New Controller @@ -30,6 +33,10 @@ Public Class Form1 Private m_bShowGridFrame As Boolean Private m_bCPlaneTypePos As Boolean + Public Function GetInstance() As Integer + Return m_nInstance + End Function + Public Function GetExeRoot() As String Return Application.StartupPath End Function @@ -40,7 +47,7 @@ Public Class Form1 '-------------------------------- Form ------------------------------------------------------------ Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load - ' installo aggiornamento interfaccia + ' Installo aggiornamento interfaccia AddHandler System.Windows.Forms.Application.Idle, AddressOf Application_Idle ' Title EmitTitle() @@ -51,8 +58,29 @@ Public Class Form1 End If ' Impostazione path Ini file m_sIniFile = m_sDataRoot & "\TestEIn.ini" + ' Verifico indice di istanza + m_objMutex = New Mutex(False, "Global\TestEIn") + If m_objMutex.WaitOne(0, False) Then + ' Prima istanza + m_nInstance = 1 + ' Aggiorno stato istanze attive + WritePrivateProfileString("General", "Instances", m_nInstance, m_sIniFile) + Else + ' Cerco il primo indice di istanza libero (max 32) + Dim nTmp As Integer = GetPrivateProfileInt("General", "Instances", 0, m_sIniFile) + m_nInstance = 1 + Dim nMask As Integer = 1 + While (nTmp And nMask) <> 0 And m_nInstance < 32 + m_nInstance += 1 + nMask *= 2 + End While + ' Aggiorno stato istanze attive + nTmp += (1 << (m_nInstance - 1)) + WritePrivateProfileString("General", "Instances", nTmp, m_sIniFile) + End If ' Inizializzazione generale di EgtInterface - EgtInit(0, m_sDataRoot & "\EInGenlog.txt") + Dim sIniFile As String = m_sDataRoot & "\EInGenlog" & m_nInstance.ToString() & ".txt" + EgtInit(0, sIniFile) ' imposto chiave di protezione Dim sKey As String = String.Empty GetPrivateProfileString("General", "Key", "", sKey, m_sIniFile) @@ -166,9 +194,12 @@ Public Class Form1 ' Impostazioni controller m_Controller.SetScene(Scene1) Dim bLuaReg As Boolean = (GetPrivateProfileInt("General", "CommandLog", 0, m_sIniFile) <> 0) - If Not m_Controller.SetCommandLog(bLuaReg, m_sDataRoot) Then - MessageBox.Show("Command log not running : another instance already open", "EIn Warning", - MessageBoxButtons.OK, MessageBoxIcon.Warning) + If Not m_Controller.SetCommandLog(bLuaReg, m_sDataRoot, m_nInstance) Then + EgtOutLog("Command log not started") + If My.Application.CommandLineArgs.Count() = 0 Then + MessageBox.Show("Command log not started", "TestEIn Warning", + MessageBoxButtons.OK, MessageBoxIcon.Warning) + End If End If If m_Controller.GetCommandLog() Then tsStatusReg.BackColor = Color.Lime @@ -221,6 +252,8 @@ Public Class Form1 WritePrivateProfileWinPos("General", "WinPlace", nFlag, Me.Left, Me.Top, Me.Width, Me.Height, m_sIniFile) ' Terminazione generale di EgtInterface EgtExit() + ' Rilascio mutex + m_objMutex.Close() ' Disabilito gestore Idle RemoveHandler Application.Idle, AddressOf Application_Idle End Sub diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index bed3662..c48bcff 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -43,5 +43,5 @@ Imports System.Runtime.InteropServices ' utilizzando l'asterisco (*) come descritto di seguito: ' - - + +