From 7e2ca67c5861481b84294093019d9f40377aea0f Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 5 Apr 2022 14:56:29 -0600 Subject: [PATCH 01/51] updated Disclaimer to DISCLAIMER_preliminary.md --- ModelViewer/ModelViewer.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModelViewer/ModelViewer.rc b/ModelViewer/ModelViewer.rc index ba1e3b5..49b6e69 100644 --- a/ModelViewer/ModelViewer.rc +++ b/ModelViewer/ModelViewer.rc @@ -774,7 +774,7 @@ BEGIN GROUPBOX "Notice",IDC_STATIC,7,47,204,49 LTEXT "This software uses the Visualization Toolkit (vtk), written and copyrighted by Ken Martin, Will Schroeder and Bill Lorensen. The authors of vtk have granted permission to use, copy, and distribute vtk while retaining their copyright. ",IDC_STATIC,15,59,191,34 GROUPBOX "Disclaimer",IDC_STATIC,7,98,204,119 - LTEXT "This version of Model Viewer is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey (USGS).",IDC_STATIC,15,110,189,34 + LTEXT "This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey (USGS).",IDC_STATIC,15,110,189,34 LTEXT "No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty.",IDC_STATIC,15,148,190,34 LTEXT "The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software.",IDC_STATIC,15,187,190,26 GROUPBOX "Credits",IDC_STATIC,7,220,204,42 From 39fc438d6a22abb4af59c4e37c59dd38fd644f8d Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 5 Apr 2022 16:19:06 -0600 Subject: [PATCH 02/51] Update about with approved disclaimer --- .github/workflows/build.yml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70cb6c6..04e8ae2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,6 +153,26 @@ jobs: } Write-Output "NEXT_VERSION=$next_version" >> $env:GITHUB_ENV + + - name: Update About + shell: pwsh + run: | + $prelim_pt1 = '"This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey \(USGS\).",.*$' + $prelim_pt2 = '"No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty.",.*$' + $prelim_pt3 = '"The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software.",.*$' + + $approved_pt1 = '"This software has been approved for release by the U.S. Geological Survey (USGS). Although the software has been subjected to rigorous review, the USGS reserves the right to update the software as needed pursuant to further analysis and review.",IDC_STATIC,15,110,189,40' + $approved_pt2 = '"No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty.",IDC_STATIC,15,152,190,34' + $approved_pt3 = '"Furthermore, the software is released on condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from its authorized or unauthorized use.",IDC_STATIC,15,187,190,26' + + # sed ModelViewer.rc + $file = ".\ModelViewer\ModelViewer.rc" + (Get-Content $file) | Foreach-Object { + $_ -replace $prelim_pt1, $approved_pt1` + -replace $prelim_pt1, $approved_pt2` + -replace $prelim_pt1, $approved_pt3` + } | Set-Content $file + - name: Commit and push if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') uses: actions-js/push@master @@ -160,12 +180,12 @@ jobs: github_token: ${{secrets.GITHUB_TOKEN}} branch: main - # - name: Commit and push branch - # if: (! (github.repository == 'MODFLOW-USGS/modelviewer-mf6') ) - # uses: actions-js/push@master - # with: - # github_token: ${{secrets.GITHUB_TOKEN}} - # branch: HEAD:refs/heads/__${{env.NEXT_VERSION}}.${{github.run_number}} + - name: Commit and push branch + if: (! (github.repository == 'MODFLOW-USGS/modelviewer-mf6') ) + uses: actions-js/push@master + with: + github_token: ${{secrets.GITHUB_TOKEN}} + branch: HEAD:refs/heads/__${{env.NEXT_VERSION}}.${{github.run_number}} - name: Configure shell: pwsh From ffb0d899482979c1b0a7f8e96e8ccc72e599073f Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 5 Apr 2022 16:27:39 -0600 Subject: [PATCH 03/51] try fetch-depth --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04e8ae2..bfd1386 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,8 +37,13 @@ jobs: steps: + # - name: Checkout + # uses: actions/checkout@v2 + - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - name: Cache vtk id: cache-vtk From bdd9a9fe6dfcfaeb80e126ee027c21e6cbf83a22 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 5 Apr 2022 16:36:44 -0600 Subject: [PATCH 04/51] back to the old way? --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bfd1386..b53a57b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,13 +37,13 @@ jobs: steps: - # - name: Checkout - # uses: actions/checkout@v2 - - name: Checkout uses: actions/checkout@v2 - with: - fetch-depth: 0 # otherwise, you will fail to push refs to dest repo + + # - name: Checkout + # uses: actions/checkout@v2 + # with: + # fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - name: Cache vtk id: cache-vtk @@ -190,7 +190,7 @@ jobs: uses: actions-js/push@master with: github_token: ${{secrets.GITHUB_TOKEN}} - branch: HEAD:refs/heads/__${{env.NEXT_VERSION}}.${{github.run_number}} + branch: __${{env.NEXT_VERSION}}.${{github.run_number}} - name: Configure shell: pwsh From f55f21b09871c1f6ff8d91a0e5b13d40470b8ca3 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 5 Apr 2022 16:44:24 -0600 Subject: [PATCH 05/51] fixed cut and paste error --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b53a57b..2634993 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -174,8 +174,8 @@ jobs: $file = ".\ModelViewer\ModelViewer.rc" (Get-Content $file) | Foreach-Object { $_ -replace $prelim_pt1, $approved_pt1` - -replace $prelim_pt1, $approved_pt2` - -replace $prelim_pt1, $approved_pt3` + -replace $prelim_pt2, $approved_pt2` + -replace $prelim_pt3, $approved_pt3` } | Set-Content $file - name: Commit and push From ae26750a6077b819d9410b0dad749bd9df2b40ee Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 5 Apr 2022 18:23:28 -0600 Subject: [PATCH 06/51] Update README.md for approval --- .github/workflows/build.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2634993..7d7824e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -178,6 +178,25 @@ jobs: -replace $prelim_pt3, $approved_pt3` } | Set-Content $file + # @TODO Only on push to main on MODFLOW-USGS/modelviewer-mf6 + - name: Update README.md + shell: pwsh + run: | + $approved = ("Disclaimer`n" + + "----------`n" + + "`n" + + "This software has been approved for release by the U.S. Geological Survey`n" + + "(USGS). Although the software has been subjected to rigorous review, the USGS`n" + + "reserves the right to update the software as needed pursuant to further analysis`n" + + "and review. No warranty, expressed or implied, is made by the USGS or the U.S.`n" + + "Government as to the functionality of the software and related material nor`n" + + "shall the fact of release constitute any such warranty. Furthermore, the`n" + + "software is released on condition that neither the USGS nor the U.S. Government`n" + + "shall be held liable for any damages resulting from its authorized or`n" + + "unauthorized use.") + $file = ".\README.md" + (Get-Content -Raw $file) -replace "(?ms)Disclaimer.*", $approved | Set-Content $file + - name: Commit and push if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') uses: actions-js/push@master From 857bf6dd95cc4333a1a6e646608050041968e248 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 12 Apr 2022 09:10:14 -0600 Subject: [PATCH 07/51] tidying up --- code.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code.json b/code.json index b0c8b6c..bf98143 100644 --- a/code.json +++ b/code.json @@ -3,7 +3,7 @@ "name": "modelviewer-mf6", "organization": "U.S. Geological Survey", "description": "Model Viewer for Modflow 6: A Program For Three-Dimensional Visualization of Ground-water Model Results", - "version": "1.0", + "version": "1.0.0-rc.1", "status": "Release Candidate", "permissions": { @@ -19,7 +19,7 @@ "homepageURL": "https://www.usgs.gov/software/model-viewer-program-three-dimensional-visualization-ground-water-model-results", "downloadURL": "https://github.com/MODFLOW-USGS/modelviewer-mf6/releases/latest", "disclaimerURL": "https://github.com/MODFLOW-USGS/modelviewer-mf6/blob/main/DISCLAIMER.md", - "repositoryURL": "https://github.com/MODFLOW-USGS/modelviewer-mf6", + "repositoryURL": "https://github.com/MODFLOW-USGS/modelviewer-mf6.git", "vcs": "git", "laborHours": -1, From f9cbc862da11f95f42ab69d5b529107953e07ed9 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 21 Apr 2022 18:22:50 -0600 Subject: [PATCH 08/51] refactored GridType (enum class) --- ModelViewer/MvDoc.cpp | 40 ++++++------- ModelViewer/MvDoc.h | 3 +- ModelViewer/SolidDlg.cpp | 6 +- ModelViewer/SubgridPage.cpp | 18 +++--- mv/Modflow6DataSource.cpp | 50 ++++++++-------- mv/Modflow6DataSource.h | 6 +- mv/mvDataSource.h | 2 +- mv/mvDefine.h | 14 +++-- mv/mvManager.cpp | 110 ++++++++++++++++++------------------ mv/mvManager.h | 2 +- 10 files changed, 129 insertions(+), 122 deletions(-) diff --git a/ModelViewer/MvDoc.cpp b/ModelViewer/MvDoc.cpp index de0418a..40a8b7e 100644 --- a/ModelViewer/MvDoc.cpp +++ b/ModelViewer/MvDoc.cpp @@ -854,7 +854,7 @@ void CMvDoc::UpdateGridDlg() // Grid lines CGridLinesPage *lines = m_GridDlg->m_GridLinesPage; - lines->m_StructuredGrid = (m_Manager->GetGridType() == MV_STRUCTURED_GRID); + lines->m_StructuredGrid = (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID); if (m_Manager->IsScalarSubgridOn()) { // if subgrid is on, then limit the extent of the grid lines @@ -868,7 +868,7 @@ void CMvDoc::UpdateGridDlg() } else { - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { lines->m_XMin = 0; lines->m_XMax = sdim[0] - 1; @@ -883,7 +883,7 @@ void CMvDoc::UpdateGridDlg() lines->m_ZMax = m_Manager->GetNumberOfLayersInUnstructuredGrid(); } } - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { int p[3]; m_Manager->GetGridLinePositions(p); @@ -923,7 +923,7 @@ void CMvDoc::UpdateGridDlg() // Subgrid page CSubgridPage *subgrid = m_GridDlg->m_SubgridPage; const int *voi = m_Manager->GetScalarSubgridExtent(); - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { // structured grid subgrid->m_col_min = voi[0] + 1; @@ -937,7 +937,7 @@ void CMvDoc::UpdateGridDlg() subgrid->m_lay_upper_limit = sdim[2] - 1; subgrid->m_ActivateSubgrid = m_Manager->IsScalarSubgridOn(); } - else if (m_Manager->GetGridType() == MV_LAYERED_GRID) + else if (m_Manager->GetGridType() == GridType::MV_LAYERED_GRID) { subgrid->m_col_min = 0; subgrid->m_col_max = 0; @@ -955,7 +955,7 @@ void CMvDoc::UpdateGridDlg() subgrid->GetDlgItem(IDC_JHIGH)->SetWindowText(""); subgrid->m_ActivateSubgrid = 0; } - else if (m_Manager->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_Manager->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { subgrid->m_col_min = 0; subgrid->m_col_max = 0; @@ -980,7 +980,7 @@ void CMvDoc::UpdateGridDlg() // Grid display page CGridDisplayPage *display = m_GridDlg->m_GridDisplayPage; - display->m_UnstructuredGrid = (m_Manager->GetGridType() == MV_UNSTRUCTURED_GRID); + display->m_UnstructuredGrid = (m_Manager->GetGridType() == GridType::MV_UNSTRUCTURED_GRID); if (display->m_UnstructuredGrid) { display->m_GridDisplayMode = 1; @@ -1013,7 +1013,7 @@ void CMvDoc::UpdateVectorDlg() // Controls Page CVectorControlsPage *ctrl = m_VectorDlg->m_ControlsPage; const int *vdim = m_Manager->GetVectorGridDimensions(); - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { int extent[6]; int rate[3]; @@ -1465,7 +1465,7 @@ void CMvDoc::OnUpdateShowGridShell(CCmdUI *pCmdUI) void CMvDoc::OnShowGridLines() { - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { if (m_Manager->AreActivatedGridLinesVisible()) { @@ -1481,7 +1481,7 @@ void CMvDoc::OnShowGridLines() m_GridDlg->m_PropertySheet->GetActiveIndex() == 0); } } - else if (m_Manager->GetGridType() == MV_LAYERED_GRID) + else if (m_Manager->GetGridType() == GridType::MV_LAYERED_GRID) { if (m_Manager->IsGridLayerVisible()) { @@ -1502,15 +1502,15 @@ void CMvDoc::OnShowGridLines() void CMvDoc::OnUpdateShowGridLines(CCmdUI *pCmdUI) { - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { pCmdUI->SetCheck(m_Manager->AreActivatedGridLinesVisible()); } - else if (m_Manager->GetGridType() == MV_LAYERED_GRID) + else if (m_Manager->GetGridType() == GridType::MV_LAYERED_GRID) { pCmdUI->SetCheck(m_Manager->IsGridLayerVisible()); } - else if (m_Manager->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_Manager->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { pCmdUI->SetCheck(FALSE); } @@ -2276,7 +2276,7 @@ void CMvDoc::ApplySubgrid(int col_min, int col_max, int row_min, int row_max, in { int imin, imax, jmin, jmax, kmin, kmax; // convert to vtk indexing and compute extents for points - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { const int *sdim = m_Manager->GetScalarGridDimensions(); // note that imin, imax, jmin, etc refer to point dimensions @@ -2287,7 +2287,7 @@ void CMvDoc::ApplySubgrid(int col_min, int col_max, int row_min, int row_max, in kmin = sdim[2] - lay_max - 1; kmax = sdim[2] - lay_min; } - else if (m_Manager->GetGridType() == MV_LAYERED_GRID) + else if (m_Manager->GetGridType() == GridType::MV_LAYERED_GRID) { imin = 0; imax = 0; @@ -2992,7 +2992,7 @@ void CMvDoc::SetGridLayerPosition(int layerNumber) void CMvDoc::SetGridDisplayToInterpolated() { m_Manager->SetGridDisplayToInterpolated(); - if (m_Manager->GetGridType() != MV_UNSTRUCTURED_GRID) + if (m_Manager->GetGridType() != GridType::MV_UNSTRUCTURED_GRID) { m_GridDlg->m_GridLinesPage->Activate(TRUE); } @@ -3014,11 +3014,11 @@ void CMvDoc::SetGridDisplayToStairstepped() OnShowNone(); } m_Manager->SetGridDisplayToStairstepped(); - if (m_Manager->GetGridType() == MV_STRUCTURED_GRID) + if (m_Manager->GetGridType() == GridType::MV_STRUCTURED_GRID) { m_Manager->HideGridLines(); } - else if (m_Manager->GetGridType() == MV_LAYERED_GRID) + else if (m_Manager->GetGridType() == GridType::MV_LAYERED_GRID) { m_Manager->HideGridLayer(); } @@ -3033,7 +3033,7 @@ void CMvDoc::SetGridDisplayToStairstepped() SetModifiedFlag(TRUE); } -int CMvDoc::GetGridType() +GridType CMvDoc::GetGridType() { return m_Manager->GetGridType(); -} \ No newline at end of file +} diff --git a/ModelViewer/MvDoc.h b/ModelViewer/MvDoc.h index 9b1913e..aa28c52 100644 --- a/ModelViewer/MvDoc.h +++ b/ModelViewer/MvDoc.h @@ -10,6 +10,7 @@ #endif // _MSC_VER > 1000 #include "vtkSmartPointer.h" +#include "mvDefine.h" class mvManager; class mvGUISettings; @@ -55,7 +56,7 @@ class CMvDoc : public CDocument void GetVectorMagnitudeRange(double* range); char* GetModelName(); char* GetDataName(); - int GetGridType(); + GridType GetGridType(); // Callback functions for modeless dialog boxes (tools) diff --git a/ModelViewer/SolidDlg.cpp b/ModelViewer/SolidDlg.cpp index 4fb4a0a..b080fac 100644 --- a/ModelViewer/SolidDlg.cpp +++ b/ModelViewer/SolidDlg.cpp @@ -119,9 +119,9 @@ void CSolidDlg::Reinitialize() void CSolidDlg::Activate(BOOL b) { - GetDlgItem(IDC_SOLID_DISPLAY_SMOOTH)->EnableWindow(b && m_pDoc->GetGridType() != MV_UNSTRUCTURED_GRID); - GetDlgItem(IDC_SOLID_DISPLAY_BLOCKY)->EnableWindow(b && m_PrimaryScalarMode == 0 && m_pDoc->GetGridType() != MV_UNSTRUCTURED_GRID); - GetDlgItem(IDC_SOLID_DISPLAY_BANDED)->EnableWindow(b && m_pDoc->GetGridType() != MV_UNSTRUCTURED_GRID); + GetDlgItem(IDC_SOLID_DISPLAY_SMOOTH)->EnableWindow(b && m_pDoc->GetGridType() != GridType::MV_UNSTRUCTURED_GRID); + GetDlgItem(IDC_SOLID_DISPLAY_BLOCKY)->EnableWindow(b && m_PrimaryScalarMode == 0 && m_pDoc->GetGridType() != GridType::MV_UNSTRUCTURED_GRID); + GetDlgItem(IDC_SOLID_DISPLAY_BANDED)->EnableWindow(b && m_pDoc->GetGridType() != GridType::MV_UNSTRUCTURED_GRID); GetDlgItem(IDC_APPLY_THRESHOLD)->EnableWindow(b); GetDlgItem(IDC_COLOR_BANDS)->EnableWindow(b && ((CButton *)GetDlgItem(IDC_SOLID_DISPLAY_BANDED))->GetCheck()); GetDlgItem(IDC_APPLY)->EnableWindow(b); diff --git a/ModelViewer/SubgridPage.cpp b/ModelViewer/SubgridPage.cpp index 45b8ec6..467a845 100644 --- a/ModelViewer/SubgridPage.cpp +++ b/ModelViewer/SubgridPage.cpp @@ -46,7 +46,7 @@ void CSubgridPage::DoDataExchange(CDataExchange* pDX) { DDX_Check(pDX, IDC_ACTIVATE_SUBGRID, m_ActivateSubgrid); - if (m_pDoc->GetGridType() == MV_STRUCTURED_GRID) + if (m_pDoc->GetGridType() == GridType::MV_STRUCTURED_GRID) { DDX_Text(pDX, IDC_ILOW, m_col_min); DDX_Text(pDX, IDC_IHIGH, m_col_max); @@ -71,7 +71,7 @@ void CSubgridPage::DoDataExchange(CDataExchange* pDX) } } } - if (m_pDoc->GetGridType() == MV_STRUCTURED_GRID || m_pDoc->GetGridType() == MV_LAYERED_GRID) + if (m_pDoc->GetGridType() == GridType::MV_STRUCTURED_GRID || m_pDoc->GetGridType() == GridType::MV_LAYERED_GRID) { DDX_Text(pDX, IDC_KLOW, m_lay_min); DDX_Text(pDX, IDC_KHIGH, m_lay_max); @@ -127,9 +127,9 @@ void CSubgridPage::Reinitialize() void CSubgridPage::Activate(BOOL b) { - GetDlgItem(IDC_ACTIVATE_SUBGRID)->EnableWindow(b && m_pDoc->GetGridType() != MV_UNSTRUCTURED_GRID); + GetDlgItem(IDC_ACTIVATE_SUBGRID)->EnableWindow(b && m_pDoc->GetGridType() != GridType::MV_UNSTRUCTURED_GRID); BOOL bb = ((CButton*)GetDlgItem(IDC_ACTIVATE_SUBGRID))->GetCheck(); - BOOL bbb = b && bb && m_pDoc->GetGridType() == MV_STRUCTURED_GRID; + BOOL bbb = b && bb && m_pDoc->GetGridType() == GridType::MV_STRUCTURED_GRID; GetDlgItem(IDC_ILOW)->EnableWindow(bbb); GetDlgItem(IDC_IHIGH)->EnableWindow(bbb); GetDlgItem(IDC_JLOW)->EnableWindow(bbb); @@ -138,7 +138,7 @@ void CSubgridPage::Activate(BOOL b) GetDlgItem(IDC_IHIGH_SPIN)->EnableWindow(bbb); GetDlgItem(IDC_JLOW_SPIN)->EnableWindow(bbb); GetDlgItem(IDC_JHIGH_SPIN)->EnableWindow(bbb); - bbb = b && bb && m_pDoc->GetGridType() != MV_UNSTRUCTURED_GRID; + bbb = b && bb && m_pDoc->GetGridType() != GridType::MV_UNSTRUCTURED_GRID; GetDlgItem(IDC_KLOW)->EnableWindow(bbb); GetDlgItem(IDC_KHIGH)->EnableWindow(bbb); GetDlgItem(IDC_KLOW_SPIN)->EnableWindow(bbb); @@ -162,7 +162,7 @@ void CSubgridPage::Apply() { if (CustomUpdateData(TRUE) && m_ActivateSubgrid) { - if (m_pDoc->GetGridType() == MV_STRUCTURED_GRID) + if (m_pDoc->GetGridType() == GridType::MV_STRUCTURED_GRID) { if (m_col_min < 1) { @@ -181,7 +181,7 @@ void CSubgridPage::Apply() m_row_max = m_row_upper_limit; } } - if (m_pDoc->GetGridType() == MV_STRUCTURED_GRID || m_pDoc->GetGridType() == MV_LAYERED_GRID) + if (m_pDoc->GetGridType() == GridType::MV_STRUCTURED_GRID || m_pDoc->GetGridType() == GridType::MV_LAYERED_GRID) { if (m_lay_min < 1) { @@ -201,7 +201,7 @@ void CSubgridPage::OnActivateSubgrid() { // TODO: Add your control notification handler code here BOOL b = ((CButton*)GetDlgItem(IDC_ACTIVATE_SUBGRID))->GetCheck(); - BOOL bb = b && m_pDoc->GetGridType() == MV_STRUCTURED_GRID; + BOOL bb = b && m_pDoc->GetGridType() == GridType::MV_STRUCTURED_GRID; GetDlgItem(IDC_ILOW)->EnableWindow(bb); GetDlgItem(IDC_IHIGH)->EnableWindow(bb); GetDlgItem(IDC_JLOW)->EnableWindow(bb); @@ -210,7 +210,7 @@ void CSubgridPage::OnActivateSubgrid() GetDlgItem(IDC_IHIGH_SPIN)->EnableWindow(bb); GetDlgItem(IDC_JLOW_SPIN)->EnableWindow(bb); GetDlgItem(IDC_JHIGH_SPIN)->EnableWindow(bb); - if (m_pDoc->GetGridType() == MV_STRUCTURED_GRID || m_pDoc->GetGridType() == MV_LAYERED_GRID) + if (m_pDoc->GetGridType() == GridType::MV_STRUCTURED_GRID || m_pDoc->GetGridType() == GridType::MV_LAYERED_GRID) { GetDlgItem(IDC_KLOW)->EnableWindow(b); GetDlgItem(IDC_KHIGH)->EnableWindow(b); diff --git a/mv/Modflow6DataSource.cpp b/mv/Modflow6DataSource.cpp index dedd161..e9f3813 100644 --- a/mv/Modflow6DataSource.cpp +++ b/mv/Modflow6DataSource.cpp @@ -49,7 +49,7 @@ Modflow6DataSource::Modflow6DataSource() { m_NumberOfVTKPoints = 0; m_NumberOfVTKCells = 0; - m_GridType = MV_GRID_NOT_DEFINED; + m_GridType = GridType::MV_GRID_NOT_DEFINED; m_NumberOfScalarDataTypes = 0; m_NumberOfCellColumns = 0; m_NumberOfCellRows = 0; @@ -162,7 +162,7 @@ char *Modflow6DataSource::LoadData(char *dataFileList) char *pList = dataFileList; ParseDataFileList(pList, nameFile); - m_GridType = MV_GRID_NOT_DEFINED; + m_GridType = GridType::MV_GRID_NOT_DEFINED; if (strlen(nameFile) > 0) { // if nameFile is specified, then get the gridFile, headFile, and budgetFile from @@ -174,7 +174,7 @@ char *Modflow6DataSource::LoadData(char *dataFileList) m_DataFileList = 0; return errMsg; } - if (m_GridType == MV_GRID_NOT_DEFINED) + if (m_GridType == GridType::MV_GRID_NOT_DEFINED) { delete[] m_DataFileList; m_DataFileList = 0; @@ -196,15 +196,15 @@ char *Modflow6DataSource::LoadData(char *dataFileList) aRecord[49] = '\0'; if (strstr(aRecord, "DISV")) { - m_GridType = MV_LAYERED_GRID; + m_GridType = GridType::MV_LAYERED_GRID; } else if (strstr(aRecord, "DISU")) { - m_GridType = MV_UNSTRUCTURED_GRID; + m_GridType = GridType::MV_UNSTRUCTURED_GRID; } else if (strstr(aRecord, "DIS")) { - m_GridType = MV_STRUCTURED_GRID; + m_GridType = GridType::MV_STRUCTURED_GRID; } else { @@ -231,13 +231,13 @@ char *Modflow6DataSource::LoadData(char *dataFileList) errMsg = 0; switch (m_GridType) { - case MV_STRUCTURED_GRID: + case GridType::MV_STRUCTURED_GRID: errMsg = CreateDisGrid(gridFile); break; - case MV_LAYERED_GRID: - CreateDisvGrid(gridFile); + case GridType::MV_LAYERED_GRID: + errMsg = CreateDisvGrid(gridFile); break; - case MV_UNSTRUCTURED_GRID: + case GridType::MV_UNSTRUCTURED_GRID: errMsg = CreateDisuGrid(gridFile); break; } @@ -368,7 +368,7 @@ char *Modflow6DataSource::ExtractModflowOutputFileNames(char *nameFile, headFile[0] = '\0'; budgetFile[0] = '\0'; gridFile[0] = '\0'; - m_GridType = MV_GRID_NOT_DEFINED; + m_GridType = GridType::MV_GRID_NOT_DEFINED; ocFile[0] = '\0'; ifstream in(nameFile, ios::in); if (!in.is_open()) @@ -392,7 +392,7 @@ char *Modflow6DataSource::ExtractModflowOutputFileNames(char *nameFile, mvUtil::TrimLeft(gridFile); ExtractFileName(gridFile); strcat(gridFile, ".grb"); - m_GridType = MV_STRUCTURED_GRID; + m_GridType = GridType::MV_STRUCTURED_GRID; } else if (!_strnicmp(aline, "disv6 ", 6)) { @@ -400,7 +400,7 @@ char *Modflow6DataSource::ExtractModflowOutputFileNames(char *nameFile, mvUtil::TrimLeft(gridFile); ExtractFileName(gridFile); strcat(gridFile, ".grb"); - m_GridType = MV_LAYERED_GRID; + m_GridType = GridType::MV_LAYERED_GRID; } else if (!_strnicmp(aline, "disu6 ", 5)) { @@ -408,7 +408,7 @@ char *Modflow6DataSource::ExtractModflowOutputFileNames(char *nameFile, mvUtil::TrimLeft(gridFile); strcat(gridFile, ".grb"); ExtractFileName(gridFile); - m_GridType = MV_UNSTRUCTURED_GRID; + m_GridType = GridType::MV_UNSTRUCTURED_GRID; } if (!_strnicmp(aline, "oc6 ", 4)) { @@ -1680,7 +1680,7 @@ char *Modflow6DataSource::CountHead(char *dataTypeLabel) double pertim, totim, value; char text[16]; m_NumberOfTimePoints = 0; - if (m_GridType == MV_UNSTRUCTURED_GRID) + if (m_GridType == GridType::MV_UNSTRUCTURED_GRID) { jmax = m_NumberOfModflowCells; kmax = 1; @@ -1823,7 +1823,7 @@ char *Modflow6DataSource::CountBudgetAndFeatures() m_IfBudget.read((char *)(&node), sizeof(int)); m_IfBudget.read((char *)(&id2), sizeof(int)); mf_cell_index = node - 1; - if (m_GridType == MV_STRUCTURED_GRID) + if (m_GridType == GridType::MV_STRUCTURED_GRID) { num_vtk_cells_for_this_flowType++; } @@ -1910,7 +1910,7 @@ char *Modflow6DataSource::CountBudgetAndFeatures() delete vtk_cell_count; // ********* temporary -- no vectors for DISU GRID ********** - if (m_GridType == MV_UNSTRUCTURED_GRID) + if (m_GridType == GridType::MV_UNSTRUCTURED_GRID) { m_HasSpecificDischargeData = 0; } @@ -1923,7 +1923,7 @@ void Modflow6DataSource::GetTimePoints(double *timePoints, int *periods, int *st int kstp, kper, n1, n2, n3, i, j, jmax, k, kmax; double pertim, totim, value; char text[16]; - if (m_GridType == MV_UNSTRUCTURED_GRID) + if (m_GridType == GridType::MV_UNSTRUCTURED_GRID) { jmax = m_NumberOfModflowCells; kmax = 1; @@ -1984,7 +1984,7 @@ void Modflow6DataSource::SetTimePointTo(int timePointIndex) m_IfHead.read((char *)(&n1), sizeof(int)); m_IfHead.read((char *)(&n2), sizeof(int)); int ncpl; - if (m_GridType == MV_STRUCTURED_GRID) + if (m_GridType == GridType::MV_STRUCTURED_GRID) { ncpl = n1 * n2; } @@ -2055,7 +2055,7 @@ void Modflow6DataSource::SetTimePointTo(int timePointIndex) memset(modflow_active_cell, 0, m_NumberOfModflowCells * sizeof(int)); // read head - if (m_GridType == MV_STRUCTURED_GRID) + if (m_GridType == GridType::MV_STRUCTURED_GRID) { int ncol, nrow, ncpl; double *pointValues = m_ScalarArray; @@ -2094,7 +2094,7 @@ void Modflow6DataSource::SetTimePointTo(int timePointIndex) mvUtil::interp3d(cellValues, pointValues, m_Delr, m_Delc_revdir, m_Elev, ncol, nrow, m_NumberOfCellLayers, m_InactiveCellValue, znull, useLayer); } - else if (m_GridType == MV_LAYERED_GRID) + else if (m_GridType == GridType::MV_LAYERED_GRID) { int p, q, ncpl; double dx, dy, dz; @@ -2199,7 +2199,7 @@ void Modflow6DataSource::SetTimePointTo(int timePointIndex) } delete[] sumOfWeights; } - else if (m_GridType == MV_UNSTRUCTURED_GRID) + else if (m_GridType == GridType::MV_UNSTRUCTURED_GRID) { int nodes, n1, n2; memset(m_ScalarArray, 0, m_NumberOfVTKPoints * sizeof(double)); @@ -2307,7 +2307,7 @@ void Modflow6DataSource::SetTimePointTo(int timePointIndex) if (IsModelFeature(flowType)) { - if (m_GridType == MV_STRUCTURED_GRID) + if (m_GridType == GridType::MV_STRUCTURED_GRID) { // find the Modflow col, row, and layer for this node int nm1 = node - 1; @@ -2341,7 +2341,7 @@ void Modflow6DataSource::SetTimePointTo(int timePointIndex) m_IfBudget.read((char *)(&value1), sizeof(double)); m_IfBudget.read((char *)(&value2), sizeof(double)); m_IfBudget.read((char *)(&value3), sizeof(double)); - if (m_GridType == MV_STRUCTURED_GRID) + if (m_GridType == GridType::MV_STRUCTURED_GRID) { // find the Modflow col, row, and layer for this node int nm1 = node - 1; @@ -2364,7 +2364,7 @@ void Modflow6DataSource::SetTimePointTo(int timePointIndex) m_VectorArray[3 * ivtk + 2] = m_InactiveCellValue; } } - else if (m_GridType == MV_LAYERED_GRID /* || m_GridType == MV_UNSTRUCTURED_GRID */) + else if (m_GridType == GridType::MV_LAYERED_GRID /* || m_GridType == GridType::MV_UNSTRUCTURED_GRID */) { int nm1 = node - 1; if (modflow_active_cell[nm1]) diff --git a/mv/Modflow6DataSource.h b/mv/Modflow6DataSource.h index b399521..d6c233d 100644 --- a/mv/Modflow6DataSource.h +++ b/mv/Modflow6DataSource.h @@ -17,7 +17,7 @@ class MV_EXPORT Modflow6DataSource : public mvDataSource static char *GetNameStatic() { return "Modflow 6"; } virtual char *GetName() { return GetNameStatic(); } virtual int GetPrimaryScalarMode() { return MV_CELL_SCALARS; } - virtual int GetGridType() { return m_GridType; } + virtual GridType GetGridType() { return m_GridType; } // virtual int AreAllCellsActive() { return 0; } virtual char *LoadData(char *dataFileList); virtual void AdvanceOneTimePoint() { SetTimePointTo(-1); } @@ -48,7 +48,7 @@ class MV_EXPORT Modflow6DataSource : public mvDataSource int m_NumberOfCellLayers; int m_NumberOfModflowCells; int m_ModelFeatureArraySize; - int m_GridType; + GridType m_GridType; int m_HasSpecificDischargeData; ifstream m_IfHead; ifstream m_IfBudget; @@ -92,4 +92,4 @@ class MV_EXPORT Modflow6DataSource : public mvDataSource void ExtractFileName(char *aString); }; -#endif \ No newline at end of file +#endif diff --git a/mv/mvDataSource.h b/mv/mvDataSource.h index c0c5b4f..701d8e9 100644 --- a/mv/mvDataSource.h +++ b/mv/mvDataSource.h @@ -35,7 +35,7 @@ class MV_EXPORT mvDataSource * 3) vtkStructuredGrid with all active cells, 4) vtkStructuredGrid that * might contain inactive cells, and 5) vtkUnstructuredGrid.. */ - virtual int GetGridType() = 0; + virtual GridType GetGridType() = 0; /** * Returns the convention used for indexing. diff --git a/mv/mvDefine.h b/mv/mvDefine.h index d5b545d..57b33a3 100644 --- a/mv/mvDefine.h +++ b/mv/mvDefine.h @@ -1,3 +1,5 @@ +#ifndef __mvDefine_h +#define __mvDefine_h #define MV_VERSION "MF6" @@ -14,10 +16,12 @@ #define MV_CELL_SCALARS 0 #define MV_POINT_SCALARS 1 -#define MV_GRID_NOT_DEFINED 0 -#define MV_STRUCTURED_GRID 4 -#define MV_LAYERED_GRID 5 -#define MV_UNSTRUCTURED_GRID 6 +enum class GridType { + MV_GRID_NOT_DEFINED = 0, + MV_STRUCTURED_GRID = 4, // DIS6 + MV_LAYERED_GRID = 5, // DISV6 + MV_UNSTRUCTURED_GRID = 6 // DISU6 +}; #define MV_INITIAL_DISPLAY_BOUNDING_BOX 0 #define MV_INITIAL_DISPLAY_GRID_OUTLINE 1 @@ -28,3 +32,5 @@ #define MP_TRAVEL_TIME 0 #define MP_MIN_TRAVEL_TIME 1 #define MP_MAX_TRAVEL_TIME 2 + +#endif // __mvDefine_h diff --git a/mv/mvManager.cpp b/mv/mvManager.cpp index 0838f3a..42d781b 100644 --- a/mv/mvManager.cpp +++ b/mv/mvManager.cpp @@ -621,7 +621,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_PointScalars->SetNumberOfComponents(1); m_CellScalars = vtkSmartPointer::New(); m_CellScalars->SetNumberOfComponents(1); - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { // DIS grid - interpolated m_ScalarLayeredGrid = 0; @@ -671,7 +671,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_StairsteppedGrid->SetCells(cellType, cellArray); delete[] cellType; } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { // DISV grid - interpolated m_ScalarStructuredGrid = 0; @@ -780,7 +780,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_StairsteppedGrid->SetCells(cellType, cellArray); delete[] cellType; } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { // DISU grid m_ScalarStructuredGrid = 0; @@ -841,7 +841,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_Vectors->SetNumberOfComponents(3); m_VectorMagnitudes = vtkSmartPointer::New(); m_VectorMagnitudes->SetNumberOfComponents(1); - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { m_VectorUnstructuredGrid = 0; m_VectorDataSet = vtkSmartPointer::New(); @@ -851,7 +851,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_ExtractStructuredGridVector->SetInputData(m_VectorDataSet); m_ActiveVectorDataSet->SetInputConnection(m_ExtractStructuredGridVector->GetOutputPort()); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_VectorDataSet = 0; m_VectorUnstructuredGrid = vtkSmartPointer::New(); @@ -875,7 +875,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_InterpolatedGridPoints->SetDataTypeToDouble(); m_InterpolatedGridPoints->SetData(doubleArray); - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { vtkSmartPointer doubleArray = vtkSmartPointer::New(); doubleArray->SetNumberOfComponents(3); @@ -883,7 +883,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_StairsteppedGridPoints->SetDataTypeToDouble(); m_StairsteppedGridPoints->SetData(doubleArray); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { vtkSmartPointer doubleArray = vtkSmartPointer::New(); doubleArray->SetNumberOfComponents(3); @@ -892,7 +892,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_StairsteppedGridPoints->SetDataTypeToDouble(); m_StairsteppedGridPoints->SetData(doubleArray); } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { vtkSmartPointer doubleArray = vtkSmartPointer::New(); doubleArray->SetNumberOfComponents(3); @@ -929,15 +929,15 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) } ComputeActiveScalarRange(); - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { m_ScalarStructuredGrid->Modified(); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_ScalarLayeredGrid->Modified(); } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { m_ScalarUnstructuredGrid->Modified(); } @@ -972,17 +972,17 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) // default Axes double bounds[6]; - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { m_ScalarStructuredGrid->ComputeBounds(); m_ScalarStructuredGrid->GetBounds(bounds); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_ScalarLayeredGrid->ComputeBounds(); m_ScalarLayeredGrid->GetBounds(bounds); } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { m_ScalarUnstructuredGrid->ComputeBounds(); m_ScalarUnstructuredGrid->GetBounds(bounds); @@ -998,13 +998,13 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) if (m_DataSource->GetVectorArray() != 0) { int np; - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { const int *vdim = m_DataSource->GetVectorGridDimensions(); m_VectorDataSet->SetDimensions(vdim[0], vdim[1], vdim[2]); np = vdim[0] * vdim[1] * vdim[2]; } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { np = m_DataSource->GetNumModelCells(); // vtkCellArray *connectivity = vtkCellArray::New(); @@ -1066,13 +1066,13 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) if (m_DataSource->GetModelFeatureArray()) { double rgba[4]; - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { m_ModelFeatures->SetGridTypeToStructuredGrid(); m_ModelFeatures->SetFullGridDimensions(m_DataSource->GetScalarGridDimensions()); m_ModelFeatures->SetGridPoints(m_InterpolatedGridPoints); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_ModelFeatures->SetGridTypeToUnstructuredGrid(); // Send the cell (connectivity) data from m_ScalarLayeredGrid to m_ModelFeatures @@ -1081,7 +1081,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_ScalarLayeredGrid->GetCells()); m_ModelFeatures->SetGridPoints(m_InterpolatedGridPoints); } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { m_ModelFeatures->SetGridTypeToUnstructuredGrid(); // Send the cell (connectivity) data from m_ScalarUnstructuredGrid to m_ModelFeatures @@ -1164,7 +1164,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_UseLogColorBar[i] = 0; m_NumColorBarLabels[i] = 5; m_ColorBarLabelPrecision[i] = 3; - if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { m_SolidDisplayMode[i] = MV_SOLID_BLOCKY; } @@ -1184,7 +1184,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_CustomIsosurfaceValues[i] = 0; } - if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { SetSolidDisplayToBlocky(); } @@ -1245,7 +1245,7 @@ void mvManager::ApplyDefaultSettings() SetCroppedAwayPiecesOpacity(0.2); // Subgrid - if (GetGridType() == MV_STRUCTURED_GRID) + if (GetGridType() == GridType::MV_STRUCTURED_GRID) { int *sdim = m_DataSource->GetScalarGridDimensions(); SetScalarSubgridExtent(0, sdim[0] - 1, 0, sdim[1] - 1, 0, sdim[2] - 1); @@ -1264,7 +1264,7 @@ void mvManager::ApplyDefaultSettings() } else { - if (m_DataSource->GetGridType() != MV_LAYERED_GRID) + if (m_DataSource->GetGridType() != GridType::MV_LAYERED_GRID) { int *sdim = m_DataSource->GetScalarGridDimensions(); // SetGridLinePositions(sdim[0]/2, sdim[1]/2, sdim[2]/2); @@ -1300,7 +1300,7 @@ void mvManager::ApplyDefaultSettings() SetColorBarLabelPrecision(3); // Solid amd Grid Display - if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { SetSolidDisplayToBlocky(); SetGridDisplayToStairstepped(); @@ -1423,7 +1423,7 @@ void mvManager::SetReleaseDataFlag(int b) } } -int mvManager::GetGridType() const +GridType mvManager::GetGridType() const { if (m_DataSource != 0) { @@ -1431,7 +1431,7 @@ int mvManager::GetGridType() const } else { - return 0; + return GridType::MV_GRID_NOT_DEFINED; } } @@ -1670,7 +1670,7 @@ void mvManager::UpdateColorBands() void mvManager::SetScalarSubgridExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax) { - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { // note that imin, imax, jmin, etc refer to point indices, starting from zero, and using vtk convention // In particular, k goes from bottom to top. @@ -1696,7 +1696,7 @@ void mvManager::SetScalarSubgridExtent(int imin, int imax, int jmin, int jmax, i } m_ExtractCellsForSubgrid->SetCellList(cellList); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { // kmin = top layer in subgrid // kmax = bottom layer in subgrid @@ -1719,11 +1719,11 @@ void mvManager::SetScalarSubgridExtent(int imin, int imax, int jmin, int jmax, i const int *mvManager::GetScalarSubgridExtent() { - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { return m_ExtractStructuredGridForSubgrid->GetVOI(); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { // TO DO return 0; @@ -1733,7 +1733,7 @@ const int *mvManager::GetScalarSubgridExtent() void mvManager::ScalarSubgridOn() { - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { const int *sdim = m_DataSource->GetScalarGridDimensions(); int *v = m_ExtractStructuredGridForSubgrid->GetVOI(); @@ -1844,7 +1844,7 @@ void mvManager::ScalarSubgridOn() m_BlockySolidThreshold->SetInputConnection(m_ExtractCellsForSubgrid->GetOutputPort()); } } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_ActiveScalarDataSet->SetInputConnection(m_ExtractCellsForSubgrid->GetOutputPort()); m_BlockySolidThreshold->SetInputConnection(m_ExtractCellsForSubgrid->GetOutputPort()); @@ -1892,7 +1892,7 @@ void mvManager::ScalarSubgridOn() void mvManager::ScalarSubgridOff() { - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { if (m_GridDisplayMode == MV_GRID_INTERPOLATED) { @@ -1921,7 +1921,7 @@ void mvManager::ScalarSubgridOff() m_ExtractFace[i]->SetInputConnection(m_ActiveScalarDataSet->GetOutputPort()); } } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { if (m_GridDisplayMode == MV_GRID_INTERPOLATED) { @@ -1976,7 +1976,7 @@ void mvManager::ScalarSubgridOff() int mvManager::IsScalarSubgridOn() const { - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { if (m_GridDisplayMode == MV_GRID_INTERPOLATED) { @@ -1987,7 +1987,7 @@ int mvManager::IsScalarSubgridOn() const return (m_ActiveScalarDataSet->GetInput() == m_ExtractCellsForSubgrid->GetOutput()); } } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { return (m_ActiveScalarDataSet->GetInput() == m_ExtractCellsForSubgrid->GetOutput()); } @@ -2186,7 +2186,7 @@ void mvManager::CropVectors(double xmin, double xmax, m_CropBoxForVectors->SetModelBounds(bounds); m_CropBoxForVectors->SetBounds(m_VectorBounds); m_CropBoxForVectors->SetAngle(m_VectorClippingAngle); - if (GetGridType() == MV_STRUCTURED_GRID) + if (GetGridType() == GridType::MV_STRUCTURED_GRID) { m_CropVectors->SetInputConnection(m_ExtractStructuredGridVector->GetOutputPort()); } @@ -2199,7 +2199,7 @@ void mvManager::CropVectors(double xmin, double xmax, } else { - if (GetGridType() == MV_STRUCTURED_GRID) + if (GetGridType() == GridType::MV_STRUCTURED_GRID) { m_ActiveVectorDataSet->SetInputConnection(m_ExtractStructuredGridVector->GetOutputPort()); } @@ -2613,7 +2613,7 @@ void mvManager::HideGridLines() void mvManager::ActivateGridLines(int i) { - if ((m_DataSource == 0) || (GetGridType() != MV_LAYERED_GRID)) + if ((m_DataSource == 0) || (GetGridType() != GridType::MV_LAYERED_GRID)) { m_GridLinesActivated[i] = 1; if (m_ActivatedGridLinesVisibility == 1) @@ -2661,7 +2661,7 @@ void mvManager::SetGridLineColor(double r, double g, double b) int mvManager::AreGridLinesActive(int i) const { - if ((m_DataSource != 0) && (GetGridType() == MV_LAYERED_GRID)) + if ((m_DataSource != 0) && (GetGridType() == GridType::MV_LAYERED_GRID)) { return false; } @@ -2945,15 +2945,15 @@ void mvManager::OnDataModified() // { // m_ScalarStructuredGrid->Modified(); // } - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { m_ScalarStructuredGrid->Modified(); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_ScalarLayeredGrid->Modified(); } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { m_ScalarUnstructuredGrid->Modified(); } @@ -3091,17 +3091,17 @@ void mvManager::SetScalarDataTypeTo(int dataTypeIndex) int numPoints; int numCells; - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { numPoints = m_ScalarStructuredGrid->GetNumberOfPoints(); numCells = m_ScalarStructuredGrid->GetNumberOfCells(); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { numPoints = m_ScalarLayeredGrid->GetNumberOfPoints(); numCells = m_ScalarLayeredGrid->GetNumberOfCells(); } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { numPoints = m_ScalarUnstructuredGrid->GetNumberOfPoints(); numCells = m_ScalarUnstructuredGrid->GetNumberOfCells(); @@ -3124,15 +3124,15 @@ void mvManager::SetScalarDataTypeTo(int dataTypeIndex) } ComputeActiveScalarRange(); - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { m_ScalarStructuredGrid->Modified(); } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_ScalarLayeredGrid->Modified(); } - else if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { m_ScalarUnstructuredGrid->Modified(); } @@ -4971,7 +4971,7 @@ char *mvManager::Serialize(const char *fileName, mvGUISettings *gui) const } out << "Model feature glyph size = " << m_ModelFeatures->GetGlyphSize() << endl; - if (GetGridType() == MV_STRUCTURED_GRID) + if (GetGridType() == GridType::MV_STRUCTURED_GRID) { // Subgrid int *subg = m_ExtractStructuredGridForSubgrid->GetVOI(); @@ -6158,7 +6158,7 @@ void mvManager::RemoveOverlay() bool mvManager::GetIsStructuredGrid() { - return (GetGridType() == MV_STRUCTURED_GRID); + return (GetGridType() == GridType::MV_STRUCTURED_GRID); }; void mvManager::SetBoundingBoxBounds() @@ -6220,11 +6220,11 @@ int mvManager::GetNumberOfLayersInUnstructuredGrid() const void mvManager::SetGridDisplayToInterpolated() { - if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { return; } - if (m_DataSource->GetGridType() == MV_STRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_STRUCTURED_GRID) { if (IsScalarSubgridOn()) { @@ -6235,7 +6235,7 @@ void mvManager::SetGridDisplayToInterpolated() m_ActiveScalarDataSet->SetInputData(m_ScalarStructuredGrid); } } - else if (m_DataSource->GetGridType() == MV_LAYERED_GRID) + else if (m_DataSource->GetGridType() == GridType::MV_LAYERED_GRID) { m_ExtractCellsForSubgrid->SetInputData(m_ScalarLayeredGrid); if (IsScalarSubgridOn()) @@ -6260,7 +6260,7 @@ void mvManager::SetGridDisplayToInterpolated() void mvManager::SetGridDisplayToStairstepped() { - if (m_DataSource->GetGridType() == MV_UNSTRUCTURED_GRID) + if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { return; } diff --git a/mv/mvManager.h b/mv/mvManager.h index 5d65a37..992eca7 100644 --- a/mv/mvManager.h +++ b/mv/mvManager.h @@ -66,7 +66,7 @@ class MV_EXPORT mvManager int HasVectorData() const; int HasPathlineData() const; // int AreAllCellsActive() const; - int GetGridType() const; + GridType GetGridType() const; bool GetIsStructuredGrid(); void ApplyDefaultSettings(); void SetImmediateModeRendering(int b); From 9afda36e2987c905337cdde2bad3af0a5e9040c7 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 3 May 2022 09:56:57 -0600 Subject: [PATCH 09/51] ifdef'd out display tab on CGridDlg --- ModelViewer/GridDlg.cpp | 10 ++++++++++ ModelViewer/GridDlg.h | 2 ++ ModelViewer/MvDoc.cpp | 2 ++ 3 files changed, 14 insertions(+) diff --git a/ModelViewer/GridDlg.cpp b/ModelViewer/GridDlg.cpp index f6c352a..e67410c 100644 --- a/ModelViewer/GridDlg.cpp +++ b/ModelViewer/GridDlg.cpp @@ -36,13 +36,17 @@ CGridDlg::CGridDlg(CWnd* pParent, CMvDoc* pDoc) m_SubgridPage = new CSubgridPage; m_SubgridPage->m_pDoc = pDoc; m_SubgridPage->m_Parent = this; +#ifdef ENABLE_CGRIDDISPLAYPAGE m_GridDisplayPage = new CGridDisplayPage; m_GridDisplayPage->m_pDoc = pDoc; m_GridDisplayPage->m_Parent = this; +#endif m_PropertySheet->AddPage(m_GridLinesPage); m_PropertySheet->AddPage(m_GridShellPage); m_PropertySheet->AddPage(m_SubgridPage); +#ifdef ENABLE_CGRIDDISPLAYPAGE m_PropertySheet->AddPage(m_GridDisplayPage); +#endif } CGridDlg::~CGridDlg() @@ -51,7 +55,9 @@ CGridDlg::~CGridDlg() delete m_GridLinesPage; delete m_GridShellPage; delete m_SubgridPage; +#ifdef ENABLE_CGRIDDISPLAYPAGE delete m_GridDisplayPage; +#endif } void CGridDlg::DoDataExchange(CDataExchange* pDX) @@ -134,7 +140,9 @@ void CGridDlg::Reinitialize() m_GridLinesPage->Reinitialize(); m_GridShellPage->Reinitialize(); m_SubgridPage->Reinitialize(); +#ifdef ENABLE_CGRIDDISPLAYPAGE m_GridDisplayPage->Reinitialize(); +#endif } void CGridDlg::Activate(BOOL Activate) @@ -143,7 +151,9 @@ void CGridDlg::Activate(BOOL Activate) m_GridLinesPage->Activate(b); m_GridShellPage->Activate(b); m_SubgridPage->Activate(b); +#ifdef ENABLE_CGRIDDISPLAYPAGE m_GridDisplayPage->Activate(b); +#endif } void CGridDlg::OnApply() diff --git a/ModelViewer/GridDlg.h b/ModelViewer/GridDlg.h index f8b4163..321d4ea 100644 --- a/ModelViewer/GridDlg.h +++ b/ModelViewer/GridDlg.h @@ -31,7 +31,9 @@ class CGridDlg : public CDialog CGridLinesPage *m_GridLinesPage; CGridShellPage *m_GridShellPage; CSubgridPage *m_SubgridPage; +#ifdef ENABLE_CGRIDDISPLAYPAGE CGridDisplayPage *m_GridDisplayPage; +#endif // Dialog Data //{{AFX_DATA(CGridDlg) diff --git a/ModelViewer/MvDoc.cpp b/ModelViewer/MvDoc.cpp index 40a8b7e..7bf4de0 100644 --- a/ModelViewer/MvDoc.cpp +++ b/ModelViewer/MvDoc.cpp @@ -978,6 +978,7 @@ void CMvDoc::UpdateGridDlg() subgrid->CustomUpdateData(FALSE); subgrid->Activate(TRUE); +#ifdef ENABLE_CGRIDDISPLAYPAGE // Grid display page CGridDisplayPage *display = m_GridDlg->m_GridDisplayPage; display->m_UnstructuredGrid = (m_Manager->GetGridType() == GridType::MV_UNSTRUCTURED_GRID); @@ -1000,6 +1001,7 @@ void CMvDoc::UpdateGridDlg() display->UpdateData(FALSE); display->Activate(TRUE); } +#endif // Grid Dlg m_GridDlg->m_GridShellPage->Activate(m_Manager->IsGridShellVisible()); From 58a36d114f79f0e3853b1d411abe3085a1777102 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 4 May 2022 08:54:36 -0600 Subject: [PATCH 10/51] updated break allocation --- ModelViewer/ModelViewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModelViewer/ModelViewer.cpp b/ModelViewer/ModelViewer.cpp index b4129e0..9d9834e 100644 --- a/ModelViewer/ModelViewer.cpp +++ b/ModelViewer/ModelViewer.cpp @@ -76,7 +76,7 @@ BOOL CModelViewerApp::InitInstance() AfxEnableMemoryLeakDump(FALSE); // Use the following to set breakpoint // - // _CrtSetBreakAlloc(1030); + // _CrtSetBreakAlloc(1046); // // This should be the only memory leak char* ptr = new char[10]; From 344bbf06776448504b189861bee8497f69539749 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 4 May 2022 09:07:53 -0600 Subject: [PATCH 11/51] Refactored to use SolidDisplayType enum --- ModelViewer/MvDoc.cpp | 2 +- ModelViewer/SolidDlg.cpp | 18 ++++++++++++------ ModelViewer/SolidDlg.h | 14 ++++++++------ mv/mvDefine.h | 33 ++++++++++++++++++--------------- mv/mvManager.cpp | 40 +++++++++++++++++++++++----------------- mv/mvManager.h | 4 ++-- 6 files changed, 64 insertions(+), 47 deletions(-) diff --git a/ModelViewer/MvDoc.cpp b/ModelViewer/MvDoc.cpp index 7bf4de0..35adcc1 100644 --- a/ModelViewer/MvDoc.cpp +++ b/ModelViewer/MvDoc.cpp @@ -3025,7 +3025,7 @@ void CMvDoc::SetGridDisplayToStairstepped() m_Manager->HideGridLayer(); } m_GridDlg->m_GridLinesPage->Activate(FALSE); - m_SolidDlg->m_SolidDisplayMode = 1; + m_SolidDlg->m_SolidDisplayMode = SolidDisplayType::MV_SOLID_BLOCKY; m_SolidDlg->UpdateData(FALSE); m_SolidDlg->GetDlgItem(IDC_SOLID_DISPLAY_SMOOTH)->EnableWindow(FALSE); m_SolidDlg->GetDlgItem(IDC_SOLID_DISPLAY_BLOCKY)->EnableWindow(FALSE); diff --git a/ModelViewer/SolidDlg.cpp b/ModelViewer/SolidDlg.cpp index b080fac..74be236 100644 --- a/ModelViewer/SolidDlg.cpp +++ b/ModelViewer/SolidDlg.cpp @@ -22,7 +22,7 @@ CSolidDlg::CSolidDlg(CWnd *pParent, CMvDoc *pDoc) m_SolidThresholdMin = 0.0; m_SolidThresholdMax = 0.0; m_ApplyThreshold = FALSE; - m_SolidDisplayMode = -1; + m_SolidDisplayMode = SolidDisplayType::MV_SOLID_NOT_DEFINED; m_NumberOfColorBands = 0; //}}AFX_DATA_INIT @@ -41,11 +41,17 @@ void CSolidDlg::DoDataExchange(CDataExchange *pDX) DDX_Text(pDX, IDC_SOLID_THRESHOLD_MIN, m_SolidThresholdMin); DDX_Text(pDX, IDC_SOLID_THRESHOLD_MAX, m_SolidThresholdMax); DDX_Check(pDX, IDC_APPLY_THRESHOLD, m_ApplyThreshold); - DDX_Radio(pDX, IDC_SOLID_DISPLAY_SMOOTH, m_SolidDisplayMode); DDX_Text(pDX, IDC_COLOR_BANDS, m_NumberOfColorBands); DDV_MinMaxInt(pDX, m_NumberOfColorBands, 2, 50); //}}AFX_DATA_MAP + int value = static_cast(m_SolidDisplayMode); + DDX_Radio(pDX, IDC_SOLID_DISPLAY_SMOOTH, value); + if (pDX->m_bSaveAndValidate) + { + m_SolidDisplayMode = static_cast(value); + } + pDX->PrepareEditCtrl(IDC_SOLID_THRESHOLD_MAX); if (pDX->m_bSaveAndValidate) { @@ -109,7 +115,7 @@ BOOL CSolidDlg::OnInitDialog() void CSolidDlg::Reinitialize() { m_ApplyThreshold = FALSE; - m_SolidDisplayMode = 0; + m_SolidDisplayMode = SolidDisplayType::MV_SOLID_SMOOTH; UpdateData(FALSE); GetDlgItem(IDC_SOLID_THRESHOLD_MAX)->SetWindowText(""); GetDlgItem(IDC_SOLID_THRESHOLD_MIN)->SetWindowText(""); @@ -134,21 +140,21 @@ void CSolidDlg::Activate(BOOL b) void CSolidDlg::OnSolidDisplaySmooth() { - m_SolidDisplayMode = 0; + m_SolidDisplayMode = SolidDisplayType::MV_SOLID_SMOOTH; GetDlgItem(IDC_COLOR_BANDS)->EnableWindow(FALSE); m_pDoc->SetSolidDisplayToSmooth(); } void CSolidDlg::OnSolidDisplayBlocky() { - m_SolidDisplayMode = 1; + m_SolidDisplayMode = SolidDisplayType::MV_SOLID_BLOCKY; GetDlgItem(IDC_COLOR_BANDS)->EnableWindow(FALSE); m_pDoc->SetSolidDisplayToBlocky(); } void CSolidDlg::OnSolidDisplayBanded() { - m_SolidDisplayMode = 3; + m_SolidDisplayMode = SolidDisplayType::MV_SOLID_BANDED; GetDlgItem(IDC_COLOR_BANDS)->EnableWindow(TRUE); m_pDoc->SetSolidDisplayToBanded(); } diff --git a/ModelViewer/SolidDlg.h b/ModelViewer/SolidDlg.h index ddf908a..aa5773b 100644 --- a/ModelViewer/SolidDlg.h +++ b/ModelViewer/SolidDlg.h @@ -7,6 +7,8 @@ // SolidDlg.h : header file // +#include "mvDefine.h" + ///////////////////////////////////////////////////////////////////////////// // CSolidDlg dialog class CMvDoc; @@ -23,13 +25,13 @@ class CSolidDlg : public CDialog // Dialog Data //{{AFX_DATA(CSolidDlg) enum { IDD = IDD_SOLID }; - double m_SolidThresholdMin; - double m_SolidThresholdMax; - BOOL m_ApplyThreshold; - int m_SolidDisplayMode; - int m_NumberOfColorBands; + double m_SolidThresholdMin; + double m_SolidThresholdMax; + BOOL m_ApplyThreshold; + SolidDisplayType m_SolidDisplayMode; + int m_NumberOfColorBands; //}}AFX_DATA - int m_PrimaryScalarMode; + int m_PrimaryScalarMode; // Overrides // ClassWizard generated virtual function overrides diff --git a/mv/mvDefine.h b/mv/mvDefine.h index 57b33a3..25298d2 100644 --- a/mv/mvDefine.h +++ b/mv/mvDefine.h @@ -1,26 +1,29 @@ #ifndef __mvDefine_h #define __mvDefine_h -#define MV_VERSION "MF6" +#define MV_VERSION "MF6" -#define MV_SOLID_SMOOTH 0 -#define MV_SOLID_BLOCKY 1 -#define MV_SOLID_BANDED 2 +enum class SolidDisplayType { + MV_SOLID_NOT_DEFINED = -1, + MV_SOLID_SMOOTH = 0, + MV_SOLID_BLOCKY = 1, + MV_SOLID_BANDED = 2 +}; -#define MV_GRID_INTERPOLATED 0 -#define MV_GRID_STAIRSTEPPED 1 +#define MV_GRID_INTERPOLATED 0 +#define MV_GRID_STAIRSTEPPED 1 -#define MV_PATHLINE_TUBE 0 -#define MV_PATHLINE_LINE 1 +#define MV_PATHLINE_TUBE 0 +#define MV_PATHLINE_LINE 1 -#define MV_CELL_SCALARS 0 -#define MV_POINT_SCALARS 1 +#define MV_CELL_SCALARS 0 +#define MV_POINT_SCALARS 1 enum class GridType { - MV_GRID_NOT_DEFINED = 0, - MV_STRUCTURED_GRID = 4, // DIS6 - MV_LAYERED_GRID = 5, // DISV6 - MV_UNSTRUCTURED_GRID = 6 // DISU6 + MV_GRID_NOT_DEFINED = 0, + MV_STRUCTURED_GRID = 4, // DIS6 + MV_LAYERED_GRID = 5, // DISV6 + MV_UNSTRUCTURED_GRID = 6 // DISU6 }; #define MV_INITIAL_DISPLAY_BOUNDING_BOX 0 @@ -33,4 +36,4 @@ enum class GridType { #define MP_MIN_TRAVEL_TIME 1 #define MP_MAX_TRAVEL_TIME 2 -#endif // __mvDefine_h +#endif // __mvDefine_h diff --git a/mv/mvManager.cpp b/mv/mvManager.cpp index 42d781b..ffd4d75 100644 --- a/mv/mvManager.cpp +++ b/mv/mvManager.cpp @@ -1144,7 +1144,7 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_UseLogColorBar = new int[m_NumScalarDataTypes]; m_NumColorBarLabels = new int[m_NumScalarDataTypes]; m_ColorBarLabelPrecision = new int[m_NumScalarDataTypes]; - m_SolidDisplayMode = new int[m_NumScalarDataTypes]; + m_SolidDisplayMode = new SolidDisplayType[m_NumScalarDataTypes]; m_DoSolidThreshold = new int[m_NumScalarDataTypes]; m_SolidThresholdMax = new double[m_NumScalarDataTypes]; m_SolidThresholdMin = new double[m_NumScalarDataTypes]; @@ -1166,11 +1166,11 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) m_ColorBarLabelPrecision[i] = 3; if (m_DataSource->GetGridType() == GridType::MV_UNSTRUCTURED_GRID) { - m_SolidDisplayMode[i] = MV_SOLID_BLOCKY; + m_SolidDisplayMode[i] = SolidDisplayType::MV_SOLID_BLOCKY; } else { - m_SolidDisplayMode[i] = MV_SOLID_SMOOTH; + m_SolidDisplayMode[i] = SolidDisplayType::MV_SOLID_SMOOTH; } m_DoSolidThreshold[i] = 0; m_SolidThresholdMax[i] = 1; @@ -1657,7 +1657,7 @@ void mvManager::UpdateColorBands() delete[] values; } - if (m_SolidDisplayMode[m_ActiveDataType] == MV_SOLID_SMOOTH) + if (m_SolidDisplayMode[m_ActiveDataType] == SolidDisplayType::MV_SOLID_SMOOTH) { m_SolidMapper->SetScalarModeToUsePointData(); } @@ -3154,11 +3154,11 @@ void mvManager::SetScalarDataTypeTo(int dataTypeIndex) SetColorBarNumberOfLabels(m_NumColorBarLabels[dataTypeIndex]); SetColorBarLabelPrecision(m_ColorBarLabelPrecision[dataTypeIndex]); - if (m_SolidDisplayMode[dataTypeIndex] == MV_SOLID_BLOCKY) + if (m_SolidDisplayMode[dataTypeIndex] == SolidDisplayType::MV_SOLID_BLOCKY) { SetSolidDisplayToBlocky(); } - else if (m_SolidDisplayMode[dataTypeIndex] == MV_SOLID_BANDED) + else if (m_SolidDisplayMode[dataTypeIndex] == SolidDisplayType::MV_SOLID_BANDED) { SetSolidDisplayToBanded(); } @@ -3204,26 +3204,26 @@ void mvManager::SetScalarDataTypeTo(int dataTypeIndex) void mvManager::SetSolidDisplayToBlocky() { - m_SolidDisplayMode[m_ActiveDataType] = MV_SOLID_BLOCKY; + m_SolidDisplayMode[m_ActiveDataType] = SolidDisplayType::MV_SOLID_BLOCKY; m_SolidMapper->SetScalarModeToUseCellData(); BuildPipelineForSolid(); } void mvManager::SetSolidDisplayToSmooth() { - m_SolidDisplayMode[m_ActiveDataType] = MV_SOLID_SMOOTH; + m_SolidDisplayMode[m_ActiveDataType] = SolidDisplayType::MV_SOLID_SMOOTH; m_SolidMapper->SetScalarModeToUsePointData(); BuildPipelineForSolid(); } void mvManager::SetSolidDisplayToBanded() { - m_SolidDisplayMode[m_ActiveDataType] = MV_SOLID_BANDED; + m_SolidDisplayMode[m_ActiveDataType] = SolidDisplayType::MV_SOLID_BANDED; m_SolidMapper->SetScalarModeToUseCellData(); BuildPipelineForSolid(); } -int mvManager::GetSolidDisplayMode() const +SolidDisplayType mvManager::GetSolidDisplayMode() const { if (m_SolidDisplayMode != 0) { @@ -3231,7 +3231,7 @@ int mvManager::GetSolidDisplayMode() const } else { - return 0; + return SolidDisplayType::MV_SOLID_SMOOTH; } } @@ -4366,7 +4366,7 @@ void mvManager::BuildPipelineForSolid() vtkAlgorithmOutput *previousAlgorithmOutput; if (m_DoSolidThreshold[m_ActiveDataType]) { - if (m_SolidDisplayMode[m_ActiveDataType] == MV_SOLID_SMOOTH || m_SolidDisplayMode[m_ActiveDataType] == MV_SOLID_BANDED) + if (m_SolidDisplayMode[m_ActiveDataType] == SolidDisplayType::MV_SOLID_SMOOTH || m_SolidDisplayMode[m_ActiveDataType] == SolidDisplayType::MV_SOLID_BANDED) { previousAlgorithmOutput = m_SmoothSolid->GetOutputPort(); } @@ -4626,7 +4626,7 @@ void mvManager::BuildPipelineForSolid() if (m_DoSolidThreshold[m_ActiveDataType]) { // for smooth or banded solid, we clip - if (m_SolidDisplayMode[m_ActiveDataType] == MV_SOLID_SMOOTH || m_SolidDisplayMode[m_ActiveDataType] == MV_SOLID_BANDED) + if (m_SolidDisplayMode[m_ActiveDataType] == SolidDisplayType::MV_SOLID_SMOOTH || m_SolidDisplayMode[m_ActiveDataType] == SolidDisplayType::MV_SOLID_BANDED) { m_FacesClipMin->SetInputConnection(m_Faces->GetOutputPort()); m_CroppedSolid->AddInputConnection(m_FacesClipMax->GetOutputPort()); @@ -4653,7 +4653,7 @@ void mvManager::BuildPipelineForSolid() } // Create color bands - if (m_SolidDisplayMode[m_ActiveDataType] == MV_SOLID_BANDED) + if (m_SolidDisplayMode[m_ActiveDataType] == SolidDisplayType::MV_SOLID_BANDED) { m_ColorBandFilter->SetInputConnection(previousAlgorithmOutput); previousAlgorithmOutput = m_ColorBandFilter->GetOutputPort(); @@ -4888,7 +4888,7 @@ char *mvManager::Serialize(const char *fileName, mvGUISettings *gui) const out << "Color bar " << (i + 1) << " label precision = " << m_ColorBarLabelPrecision[i] << endl; // Solid Control - out << "Solid " << (i + 1) << " display mode = " << m_SolidDisplayMode[i] << endl; + out << "Solid " << (i + 1) << " display mode = " << static_cast(m_SolidDisplayMode[i]) << endl; out << "Solid " << (i + 1) << " apply threshold = " << m_DoSolidThreshold[i] << endl; out << "Solid " << (i + 1) << " threshold lower limit = " << m_SolidThresholdMin[i] << endl; out << "Solid " << (i + 1) << " threshold upper limit = " << m_SolidThresholdMax[i] << endl; @@ -5576,7 +5576,13 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro m_NumColorBarLabels = numColorBarLabels; m_ColorBarLabelPrecision = colorBarLabelPrecision; - m_SolidDisplayMode = solidDisplayMode; + m_SolidDisplayMode = new SolidDisplayType[numDataTypes]; + for (i = 0; i < numDataTypes; ++i) + { + m_SolidDisplayMode[i] = static_cast(solidDisplayMode[i]); + } + delete[] solidDisplayMode; + m_DoSolidThreshold = applySolidThreshold; m_SolidThresholdMax = solidThresholdMax; m_SolidThresholdMin = solidThresholdMin; @@ -6286,7 +6292,7 @@ void mvManager::SetGridDisplayToStairstepped() // Set solid display mode to blocky for all data types for (int i = 0; i < m_NumScalarDataTypes; i++) { - m_SolidDisplayMode[i] = MV_SOLID_BLOCKY; + m_SolidDisplayMode[i] = SolidDisplayType::MV_SOLID_BLOCKY; } BuildPipelineForSolid(); } diff --git a/mv/mvManager.h b/mv/mvManager.h index 992eca7..b6213c0 100644 --- a/mv/mvManager.h +++ b/mv/mvManager.h @@ -350,7 +350,7 @@ class MV_EXPORT mvManager void SolidThresholdOff(); int IsSolidThresholdOn() const; void SetSolidThresholdLimits(double minValue, double maxValue); - int GetSolidDisplayMode() const; + SolidDisplayType GetSolidDisplayMode() const; void GetSolidThresholdLimits(double *limits) const; // Isosurface Control @@ -416,7 +416,7 @@ class MV_EXPORT mvManager int *m_NumberOfColorBands; int *m_NumberOfCustomIsosurfaces; int *m_NumberOfRegularIsosurfaces; - int *m_SolidDisplayMode; + SolidDisplayType *m_SolidDisplayMode; int *m_UseLogColorBar; int *m_UseRegularIsosurface; From 41a30f47842ff3ce535e79e66426bea5fdf86085 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 4 May 2022 10:33:33 -0600 Subject: [PATCH 12/51] working on actions/versioning --- .github/workflows/build.yml | 36 +++++++++++++++++++++++++++++++++++- CMakeLists.txt | 2 +- ModelViewer/ModelViewer.rc | 2 +- code.json | 6 +++--- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9003b5..62729a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,8 @@ on: - README.md env: + DIST_DIR: mvmf6-1.1.0-prerelease.x + USER_DIST_DIR: mvmf6-${{github.repository_owner}}-1.1.0-prerelease.x VTK_VERSION: 6.3.0 RELEASES_URL: ${{github.api_url}}/repos/${{github.repository}}/releases VTK_6_3_0_VS2017_X64_URL: https://github.com/MODFLOW-USGS/modelviewer-mf6/releases/download/vtk-6.3.0-vs2017-x64/vtk-6.3.0-vs2017-x64.7z @@ -167,8 +169,19 @@ jobs: } Write-Output "NEXT_VERSION=$next_version" >> $env:GITHUB_ENV + - name: Update build date + shell: pwsh + run: | + # sed ModelViewer.rc + $date_compiled = "$((Get-Date -UFormat '%m/%d/%Y (compiled %b %d %Y %T)'))" + $file = ".\ModelViewer\ModelViewer.rc" + (Get-Content $file) | Foreach-Object { + $_ -replace '"(?[0-1][1-9])\/(?[0-3][1-9])\/(?\d{4}) \(.*\)"', """$date_compiled"""` + } | Set-Content $file + # @TODO Only on push to main on MODFLOW-USGS/modelviewer-mf6 - name: Update About + if: ${{ false }} shell: pwsh run: | $prelim_pt1 = '"This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey \(USGS\).",.*$' @@ -189,6 +202,7 @@ jobs: # @TODO Only on push to main on MODFLOW-USGS/modelviewer-mf6 - name: Update README.md + if: ${{ false }} shell: pwsh run: | $approved = ("Disclaimer`n" + @@ -229,17 +243,37 @@ jobs: run: cmake --build --preset vs2019 --config release - name: Install + if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') shell: pwsh run: cmake --install _vs2019 --prefix ${{env.DIST_DIR}} --config release + - name: Install (user) + if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + shell: pwsh + run: cmake --install _vs2019 --prefix ${{env.USER_DIST_DIR}} --config release + - name: Build mvmf6 zip + if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') run: | Copy-Item .\Help\mvmf6.chm ${{env.DIST_DIR}}\bin\. 7z a -tzip ${{env.DIST_DIR}}.zip .\${{env.DIST_DIR}}\ + - name: Build mvmf6 zip (user) + if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + run: | + Copy-Item .\Help\mvmf6.chm ${{env.USER_DIST_DIR}}\bin\. + 7z a -tzip ${{env.USER_DIST_DIR}}.zip .\${{env.USER_DIST_DIR}}\ + + - name: Upload artifact (user) + if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + uses: actions/upload-artifact@v3 + with: + name: ${{env.USER_DIST_DIR}}.zip + path: ${{env.USER_DIST_DIR}}.zip + # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch - name: Create release - if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') || (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') run: | # store new commit $target_commitish = (git log -n1 --format=format:"%H") diff --git a/CMakeLists.txt b/CMakeLists.txt index 1679738..b7d0877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20) project ( MvProject - VERSION 1.0.12 + VERSION 1.1.0 LANGUAGES CXX C ) diff --git a/ModelViewer/ModelViewer.rc b/ModelViewer/ModelViewer.rc index 49b6e69..da9fcbc 100644 --- a/ModelViewer/ModelViewer.rc +++ b/ModelViewer/ModelViewer.rc @@ -769,7 +769,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,161,7,50,14,WS_GROUP ICON IDR_MAINFRAME,IDC_STATIC,7,7,20,20 LTEXT "Model Viewer for Modflow 6",IDC_MV_VERSION,45,7,107,10,SS_NOPREFIX - LTEXT "Version 1.0.12",IDC_STATIC,45,20,107,10 + LTEXT "Version 1.1.0-prerelease.1",IDC_STATIC,45,20,107,10 LTEXT "03/25/2022 (compiled Mar 25 2022 14:49:37)",IDC_MV_RELEASE,45,33,129,8 GROUPBOX "Notice",IDC_STATIC,7,47,204,49 LTEXT "This software uses the Visualization Toolkit (vtk), written and copyrighted by Ken Martin, Will Schroeder and Bill Lorensen. The authors of vtk have granted permission to use, copy, and distribute vtk while retaining their copyright. ",IDC_STATIC,15,59,191,34 diff --git a/code.json b/code.json index bf98143..338b643 100644 --- a/code.json +++ b/code.json @@ -3,8 +3,8 @@ "name": "modelviewer-mf6", "organization": "U.S. Geological Survey", "description": "Model Viewer for Modflow 6: A Program For Three-Dimensional Visualization of Ground-water Model Results", - "version": "1.0.0-rc.1", - "status": "Release Candidate", + "version": "1.1.0-prerelease.x", + "status": "Development", "permissions": { "usageType": "openSource", @@ -41,7 +41,7 @@ }, "date": { - "metadataLastUpdated": "2022-02-17" + "metadataLastUpdated": "2022-05-04" } } ] From 41b7115374a67527548f2a364d020466e4c41a59 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 4 May 2022 10:42:57 -0600 Subject: [PATCH 13/51] increased IDC_MV_RELEASE width --- ModelViewer/ModelViewer.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModelViewer/ModelViewer.rc b/ModelViewer/ModelViewer.rc index da9fcbc..5ca8c85 100644 --- a/ModelViewer/ModelViewer.rc +++ b/ModelViewer/ModelViewer.rc @@ -770,7 +770,7 @@ BEGIN ICON IDR_MAINFRAME,IDC_STATIC,7,7,20,20 LTEXT "Model Viewer for Modflow 6",IDC_MV_VERSION,45,7,107,10,SS_NOPREFIX LTEXT "Version 1.1.0-prerelease.1",IDC_STATIC,45,20,107,10 - LTEXT "03/25/2022 (compiled Mar 25 2022 14:49:37)",IDC_MV_RELEASE,45,33,129,8 + LTEXT "05/04/2022 (compiled May 04 2022 16:35:19)",IDC_MV_RELEASE,45,33,166,8 GROUPBOX "Notice",IDC_STATIC,7,47,204,49 LTEXT "This software uses the Visualization Toolkit (vtk), written and copyrighted by Ken Martin, Will Schroeder and Bill Lorensen. The authors of vtk have granted permission to use, copy, and distribute vtk while retaining their copyright. ",IDC_STATIC,15,59,191,34 GROUPBOX "Disclaimer",IDC_STATIC,7,98,204,119 From 1dff447ce432b5e728cb6111bb2d417d7eb890c2 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 4 May 2022 17:50:56 -0600 Subject: [PATCH 14/51] Store relative paths for binary files in order to allow concentration files to be opened for example Directory tree: ex-gwt-moc3d-p01c mf6gwf ex-gwt-moc3d-p01c-with-conc.mvmf6 -- Model Viewer MF6 flow.dis.grb -- grid file flow.bud -- budget file mf6gwt trans.ucn -- concentration file ex-gwt-moc3d-p01c-with-conc.mvmf6 contents: ... File code count = 4 File code 1 = File code 2 = .\flow.dis.grb File code 3 = ..\mf6gwt\trans.ucn File code 4 = .\flow.bud ... --- ModelViewer/DataFilesDialog.cpp | 24 +++-------- ModelViewer/ModelViewer.rc | 11 +++-- ModelViewer/Modflow6DataFilesDlg.cpp | 13 +++--- ModelViewer/Modflow6DataFilesDlg.h | 2 +- mv/mvManager.cpp | 60 +++++++++++++++++++++++++--- mv/mvManager.h | 3 ++ 6 files changed, 81 insertions(+), 32 deletions(-) diff --git a/ModelViewer/DataFilesDialog.cpp b/ModelViewer/DataFilesDialog.cpp index a3f6f84..4c10bd6 100644 --- a/ModelViewer/DataFilesDialog.cpp +++ b/ModelViewer/DataFilesDialog.cpp @@ -31,8 +31,7 @@ char *DataFilesDialog::GetModflow6DataFiles() return NULL; } - // For now, we just use the file name and not the path. - // TO DO: Determine the path relative to the document file. + // Store fullpaths and convert to relative when Serializing BOOL setdir = FALSE; char *dataFileList; if (dlg.m_FileSpecificationMethod == 0) @@ -43,7 +42,6 @@ char *DataFilesDialog::GetModflow6DataFiles() { _chdir((LPCTSTR)name.Left(pos)); setdir = TRUE; - name = name.Right(name.GetLength() - pos - 1); } dataFileList = new char[name.GetLength() + 20]; strcpy(dataFileList, (LPCTSTR)name); @@ -57,26 +55,16 @@ char *DataFilesDialog::GetModflow6DataFiles() { _chdir((LPCTSTR)gridFile.Left(pos)); setdir = TRUE; - gridFile = gridFile.Right(gridFile.GetLength() - pos - 1); } - CString headFile = dlg.m_HeadFile; - pos = headFile.ReverseFind('\\'); - if (pos != -1) - { - headFile = headFile.Right(headFile.GetLength() - pos - 1); - } - CString budgetFile = dlg.m_BudgetFile; - pos = budgetFile.ReverseFind('\\'); - if (pos != -1) - { - budgetFile = budgetFile.Right(budgetFile.GetLength() - pos - 1); - } - dataFileList = new char[gridFile.GetLength() + headFile.GetLength() + budgetFile.GetLength() + 20]; + CString headOrConcFile = dlg.m_HeadOrConcFile; + CString budgetFile = dlg.m_BudgetFile; + + dataFileList = new char[gridFile.GetLength() + headOrConcFile.GetLength() + budgetFile.GetLength() + 20]; // no name file strcpy(dataFileList, "\n"); strcat(dataFileList, (LPCTSTR)gridFile); strcat(dataFileList, "\n"); - strcat(dataFileList, (LPCTSTR)headFile); + strcat(dataFileList, (LPCTSTR)headOrConcFile); strcat(dataFileList, "\n"); strcat(dataFileList, (LPCTSTR)budgetFile); strcat(dataFileList, "\n"); diff --git a/ModelViewer/ModelViewer.rc b/ModelViewer/ModelViewer.rc index 5ca8c85..9a4fc55 100644 --- a/ModelViewer/ModelViewer.rc +++ b/ModelViewer/ModelViewer.rc @@ -1405,9 +1405,9 @@ BEGIN PUSHBUTTON "Browse...",IDC_BROWSE_GWF_MODEL_GRID_FILE,183,71,50,14 PUSHBUTTON "Browse...",IDC_BROWSE_GWF_MODEL_HEAD_FILE,183,111,50,14 PUSHBUTTON "Browse...",IDC_BROWSE_GWF_MODEL_BUDGET_FILE,183,153,50,14 - LTEXT "Grid file",IDC_STATIC,7,76,25,8 - LTEXT "Head file",IDC_STATIC,7,115,29,8 - LTEXT "Budget file",IDC_STATIC,7,159,35,8 + LTEXT "Grid file",IDC_STATIC,7,76,168,8 + LTEXT "Head or concentration file",IDC_STATIC,7,115,168,8 + LTEXT "Budget file",IDC_STATIC,7,159,168,8 END IDD_GRID_DISPLAY DIALOGEX 0, 0, 146, 82 @@ -1626,6 +1626,11 @@ BEGIN 0 END +IDD_MODFLOW6_DATA_FILES AFX_DIALOG_LAYOUT +BEGIN + 0 +END + ///////////////////////////////////////////////////////////////////////////// // diff --git a/ModelViewer/Modflow6DataFilesDlg.cpp b/ModelViewer/Modflow6DataFilesDlg.cpp index 0089637..0cb679f 100644 --- a/ModelViewer/Modflow6DataFilesDlg.cpp +++ b/ModelViewer/Modflow6DataFilesDlg.cpp @@ -13,7 +13,7 @@ CModflow6DataFilesDlg::CModflow6DataFilesDlg(CWnd* pParent /*=NULL*/) : CDialog(CModflow6DataFilesDlg::IDD, pParent) { m_GwfModelNameFile = _T(""); - m_HeadFile = _T(""); + m_HeadOrConcFile = _T(""); m_GridFile = _T(""); m_BudgetFile = _T(""); m_FileSpecificationMethod = 0; @@ -27,7 +27,7 @@ void CModflow6DataFilesDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_GWF_MODEL_NAME_FILE, m_GwfModelNameFile); - DDX_Text(pDX, IDC_GWF_MODEL_HEAD_FILE, m_HeadFile); + DDX_Text(pDX, IDC_GWF_MODEL_HEAD_FILE, m_HeadOrConcFile); DDX_Text(pDX, IDC_GWF_MODEL_GRID_FILE, m_GridFile); DDX_Text(pDX, IDC_GWF_MODEL_BUDGET_FILE, m_BudgetFile); DDX_Radio(pDX, IDC_SPECIFY_MODFLOW6_NAME_FILE, m_FileSpecificationMethod); @@ -142,9 +142,12 @@ void CModflow6DataFilesDlg::OnBrowseGwfModelGridFile() void CModflow6DataFilesDlg::OnBrowseGwfModelHeadFile() { - CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - "Head Files (*.hds; *.bhd; *.hdb; *.hed)|*.hds; *.bhd; *.hdb; *.hed|All Files (*.*)|*.*||"); - fileDlg.m_ofn.lpstrTitle = "GWF Model Head File"; + static TCHAR BASED_CODE szFilter[] = _T("Head & Concentration Files (*.hds; *.bhd; *.hdb; *.hed; *.ucn)|*.hds; *.bhd; *.hdb; *.hed; *.ucn|") + _T("Concentration Files (*.ucn)|*.ucn|") + _T("Head Files (*.hds; *.bhd; *.hdb; *.hed)|*.hds; *.bhd; *.hdb; *.hed|") + _T("All Files (*.*)|*.*||"); + CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter); + fileDlg.m_ofn.lpstrTitle = "GWF Model Head or GWT Model Concentration File"; if (fileDlg.DoModal() != IDOK) { return; diff --git a/ModelViewer/Modflow6DataFilesDlg.h b/ModelViewer/Modflow6DataFilesDlg.h index 89b1d16..f487609 100644 --- a/ModelViewer/Modflow6DataFilesDlg.h +++ b/ModelViewer/Modflow6DataFilesDlg.h @@ -20,7 +20,7 @@ class CModflow6DataFilesDlg : public CDialog public: afx_msg void OnBrowseGwfModelNameFile(); CString m_GwfModelNameFile; - CString m_HeadFile; + CString m_HeadOrConcFile; CString m_GridFile; CString m_BudgetFile; virtual BOOL OnInitDialog(); diff --git a/mv/mvManager.cpp b/mv/mvManager.cpp index ffd4d75..571b773 100644 --- a/mv/mvManager.cpp +++ b/mv/mvManager.cpp @@ -66,13 +66,16 @@ using std::ofstream; using std::pow; // This must be below vtkStandardNewMacro -#if defined(_DEBUG) && defined(MV_DEBUG_MEMORY_LEAKS) #include +#if defined(_DEBUG) && defined(MV_DEBUG_MEMORY_LEAKS) #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif +// This must be below +#include + mvManager::mvManager() { // initial values @@ -4823,7 +4826,9 @@ char *mvManager::Serialize(const char *fileName, mvGUISettings *gui) const { cr = strchr(code, '\n'); *(cr) = '\0'; - out << "File code " << (i + 1) << " = " << code << endl; + // Get relative paths for all file codes + std::string relative = GetRelativePath(fileName, code); + out << "File code " << (i + 1) << " = " << relative.c_str() << endl; code = cr + 1; } @@ -5170,8 +5175,12 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro return; } - char *dataFileList = new char[ncode * 1024]; - dataFileList[0] = '\0'; + // Get absolute paths for all file codes + std::string dirname = GetDirName(fileName); + char szDest[MAX_PATH]; + char fullpath[MAX_PATH]; + char * dataFileList = new char[ncode * 1024]; + dataFileList[0] = '\0'; for (i = 0; i < ncode; i++) { buffer[0] = '\0'; @@ -5183,7 +5192,18 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro strcpy(errorMsg, "The Model Viewer file is damaged and cannot be loaded."); return; } - strcat(dataFileList, buffer); + if (strlen(buffer)) + { + strcpy(szDest, dirname.c_str()); + VERIFY(PathAppend(szDest, buffer)); + VERIFY(PathCanonicalize(fullpath, szDest)); + VERIFY(PathFileExists(fullpath)); + strcat(dataFileList, fullpath); + } + else + { + strcat(dataFileList, ""); + } strcat(dataFileList, "\n"); } @@ -6301,3 +6321,33 @@ int mvManager::GetGridDisplayMode() { return m_GridDisplayMode; } + +std::string mvManager::GetRelativePath(const char *pszFrom, const char *pszTo) +{ + TCHAR szOut[MAX_PATH] = ""; + if (strlen(pszTo) && PathIsSameRoot(pszFrom, pszTo)) + { + std::string cpTo(pszTo); + std::replace(cpTo.begin(), cpTo.end(), '/', '\\'); + VERIFY(PathCanonicalize(szOut, cpTo.c_str())); + cpTo = szOut; + VERIFY(PathRelativePathTo(szOut, pszFrom, FILE_ATTRIBUTE_NORMAL, cpTo.c_str(), FILE_ATTRIBUTE_NORMAL)); + return std::string(szOut); + } + return std::string(pszTo); +} + +std::string mvManager::GetDirName(const char *fullPath) +{ + char szPath[MAX_PATH]; + char szOut[MAX_PATH]; + char szDrive[_MAX_DRIVE]; + char szDir[_MAX_DIR]; + char szDest[MAX_PATH]; + + ASSERT(!PathIsRelative(fullPath)); + VERIFY(_tsplitpath_s(fullPath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, 0, NULL, 0) == 0); + VERIFY(_tmakepath_s(szPath, _MAX_DIR, szDrive, szDir, NULL, NULL) == 0); + + return std::string(szPath); +} diff --git a/mv/mvManager.h b/mv/mvManager.h index b6213c0..261de1d 100644 --- a/mv/mvManager.h +++ b/mv/mvManager.h @@ -59,6 +59,9 @@ class MV_EXPORT mvManager mvManager(); virtual ~mvManager(); + static std::string GetDirName(const char *fullPath); + static std::string GetRelativePath(const char *pszFrom, const char *pszTo); + // Data set and animation control // void ClearData(); char *LoadData(char *modelType, char *dataFileList); From 94579f154d4c56a4b1d63e6618a399eac64b56c3 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 4 May 2022 18:10:18 -0600 Subject: [PATCH 15/51] Use MFC as shared DLL on all mv builds --- mv/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mv/CMakeLists.txt b/mv/CMakeLists.txt index 6e38766..bb646d4 100644 --- a/mv/CMakeLists.txt +++ b/mv/CMakeLists.txt @@ -6,10 +6,8 @@ project ( LANGUAGES CXX C ) -if (MV_DEBUG_MEMORY_LEAKS) - # This sets 'Use MFC in a Shared DLL' -- automatically sets _AFXDLL - set(CMAKE_MFC_FLAG 2) -endif() +# This sets 'Use MFC in a Shared DLL' -- automatically sets _AFXDLL +set(CMAKE_MFC_FLAG 2) add_library(mv Modflow6DataSource.cpp From 0cbb8ed11f5ef1ae2143afe5aa770e9078422caa Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Fri, 6 May 2022 17:24:59 -0600 Subject: [PATCH 16/51] WIP currently compiles w/ vtk-6.3.0 vtk-7.1.1 vtk-8.2.0 printing and copying image to clipboard still needs work. --- CMakeLists.txt | 2 + ModelViewer/MvView.cpp | 538 ++++++++++++++++++++++------------------- ModelViewer/MvView.h | 12 +- mv/ModpathReader.cpp | 9 + mv/mvColorBar.cpp | 19 +- mv/mvDisplayObject.cpp | 2 + mv/mvDisplayObject.h | 2 + mv/mvManager.cpp | 2 + mv/mvManager.h | 2 + 9 files changed, 341 insertions(+), 247 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7d0877..2b6212b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,10 +10,12 @@ project ( include(GNUInstallDirs) # check for vtk +message(STATUS "VTK_DIR=${VTK_DIR}") find_package(VTK REQUIRED) if(NOT VTK_DIR) message(FATAL_ERROR "Please set VTK_DIR.") endif() +message(STATUS "VTK_USE_FILE=${VTK_USE_FILE}") include(${VTK_USE_FILE}) # check for MFC diff --git a/ModelViewer/MvView.cpp b/ModelViewer/MvView.cpp index 860da89..71ec97c 100644 --- a/ModelViewer/MvView.cpp +++ b/ModelViewer/MvView.cpp @@ -11,6 +11,9 @@ #include "BitmapResolutionDlg.h" #include "ExportAnimationDlg.h" +#if 1 +#include "vtkMFCWindow.h" +#endif #include "vtkRenderer.h" #include "vtkLight.h" #include "vtkLightCollection.h" @@ -89,15 +92,21 @@ END_MESSAGE_MAP() CMvView::CMvView() { +#if 1 + m_MFCWindow = nullptr; +#endif // vtk rendering m_Renderer = vtkRenderer::New(); - m_Renderer->SetBackground(1, 1, 1); + //m_Renderer->SetBackground(1, 1, 1); + m_Renderer->SetBackground(0.9, 0.9, 0.9); #ifdef NDEBUG m_Renderer->GlobalWarningDisplayOff(); #endif - m_RenderWindow = vtkWin32OpenGLRenderWindow::New(); - m_RenderWindow->AddRenderer(m_Renderer); - m_Interactor = vtkWin32RenderWindowInteractor::New(); +#if 0 + m_RenderWindow = vtkWin32OpenGLRenderWindow::New(); // @done in vtkMFCWindow ctor + m_RenderWindow->AddRenderer(m_Renderer); // @moved to OnInitialUpdate + m_Interactor = vtkWin32RenderWindowInteractor::New(); // @done in vtkMFCWindow::SetRenderWindow +#endif m_Headlight = vtkLight::New(); m_Headlight->SetLightTypeToHeadlight(); m_AuxiliaryLight = vtkLight::New(); @@ -139,14 +148,21 @@ CMvView::CMvView() CMvView::~CMvView() { - m_Interactor->Delete(); +#if 0 + m_Interactor->Delete(); // @todo +#endif m_Renderer->SetRenderWindow(NULL); m_Renderer->RemoveLight(m_Headlight); m_Renderer->RemoveLight(m_AuxiliaryLight); - m_RenderWindow->Delete(); +#if 0 + m_RenderWindow->Delete(); // @todo +#endif m_Renderer->Delete(); m_Headlight->Delete(); m_AuxiliaryLight->Delete(); +#if 1 + if (this->m_MFCWindow) delete this->m_MFCWindow; +#endif } BOOL CMvView::PreCreateWindow(CREATESTRUCT &cs) @@ -176,74 +192,76 @@ void CMvView::OnDraw(CDC *pDC) CMvDoc *pDoc = GetDocument(); ASSERT_VALID(pDoc); // Initialize the interactor the first time this method is called - if (!m_Interactor->GetInitialized()) +#if 0 + if (!m_Interactor->GetInitialized()) // @todo { m_Interactor->SetRenderWindow(m_RenderWindow); WNDPROC OldProc = (WNDPROC)GetWindowLongPtr(m_hWnd, GWLP_WNDPROC); m_Interactor->Initialize(); SetWindowLongPtr(m_hWnd, GWLP_WNDPROC, (LONG_PTR)OldProc); } +#endif // Printing code - if (pDC->IsPrinting()) + if (pDC->IsPrinting()) // @todo { - int size[2]; - float scale; - - BeginWaitCursor(); - memcpy(size, m_RenderWindow->GetSize(), sizeof(int) * 2); - - float cxDIB = (float)size[0]; // Size of DIB - x - float cyDIB = (float)size[1]; // Size of DIB - y - CRect rcDest; - - // get size of printer page (in pixels) - float cxPage = (float)pDC->GetDeviceCaps(HORZRES); - float cyPage = (float)pDC->GetDeviceCaps(VERTRES); - // get printer pixels per inch - float cxInch = (float)pDC->GetDeviceCaps(LOGPIXELSX); - float cyInch = (float)pDC->GetDeviceCaps(LOGPIXELSY); - scale = cxInch / m_DPI; - - // - // Best Fit case -- create a rectangle which preserves - // the DIB's aspect ratio, and fills the page horizontally. - // - // The formula in the "->bottom" field below calculates the Y - // position of the printed bitmap, based on the size of the - // bitmap, the width of the page, and the relative size of - // a printed pixel (cyInch / cxInch). - // - rcDest.bottom = rcDest.left = 0; - if ((cyDIB * cxPage / cxInch) > (cxDIB * cyPage / cyInch)) - { - rcDest.top = cyPage; - rcDest.right = (cyPage * cxInch * cxDIB) / (cyInch * cyDIB); - } - else - { - rcDest.right = cxPage; - rcDest.top = (cxPage * cyInch * cyDIB) / (cxInch * cxDIB); - } - - CRect rcDestLP(rcDest); - pDC->DPtoLP(rcDestLP); - int DPI = m_RenderWindow->GetDPI(); - - m_RenderWindow->SetupMemoryRendering(rcDest.right / scale, - rcDest.top / scale, pDC->GetSafeHdc()); - - m_RenderWindow->Render(); - - pDC->SetStretchBltMode(HALFTONE); - ::SetBrushOrgEx(pDC->GetSafeHdc(), 0, 0, NULL); - - StretchBlt(pDC->GetSafeHdc(), 0, 0, - rcDest.right, rcDest.top, - m_RenderWindow->GetMemoryDC(), - 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); - - m_RenderWindow->ResumeScreenRendering(); - EndWaitCursor(); + //int size[2]; + //float scale; + + //BeginWaitCursor(); + //memcpy(size, m_RenderWindow->GetSize(), sizeof(int) * 2); + + //float cxDIB = (float)size[0]; // Size of DIB - x + //float cyDIB = (float)size[1]; // Size of DIB - y + //CRect rcDest; + + //// get size of printer page (in pixels) + //float cxPage = (float)pDC->GetDeviceCaps(HORZRES); + //float cyPage = (float)pDC->GetDeviceCaps(VERTRES); + //// get printer pixels per inch + //float cxInch = (float)pDC->GetDeviceCaps(LOGPIXELSX); + //float cyInch = (float)pDC->GetDeviceCaps(LOGPIXELSY); + //scale = cxInch / m_DPI; + + //// + //// Best Fit case -- create a rectangle which preserves + //// the DIB's aspect ratio, and fills the page horizontally. + //// + //// The formula in the "->bottom" field below calculates the Y + //// position of the printed bitmap, based on the size of the + //// bitmap, the width of the page, and the relative size of + //// a printed pixel (cyInch / cxInch). + //// + //rcDest.bottom = rcDest.left = 0; + //if ((cyDIB * cxPage / cxInch) > (cxDIB * cyPage / cyInch)) + //{ + // rcDest.top = cyPage; + // rcDest.right = (cyPage * cxInch * cxDIB) / (cyInch * cyDIB); + //} + //else + //{ + // rcDest.right = cxPage; + // rcDest.top = (cxPage * cyInch * cyDIB) / (cxInch * cxDIB); + //} + + //CRect rcDestLP(rcDest); + //pDC->DPtoLP(rcDestLP); + //int DPI = m_RenderWindow->GetDPI(); + + //m_RenderWindow->SetupMemoryRendering(rcDest.right / scale, + // rcDest.top / scale, pDC->GetSafeHdc()); + + //m_RenderWindow->Render(); + + //pDC->SetStretchBltMode(HALFTONE); + //::SetBrushOrgEx(pDC->GetSafeHdc(), 0, 0, NULL); + + //StretchBlt(pDC->GetSafeHdc(), 0, 0, + // rcDest.right, rcDest.top, + // m_RenderWindow->GetMemoryDC(), + // 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); + + //m_RenderWindow->ResumeScreenRendering(); + //EndWaitCursor(); } // Screen drawing code else @@ -267,7 +285,11 @@ void CMvView::OnDraw(CDC *pDC) { BeginWaitCursor(); } +#if 0 m_RenderWindow->Render(); +#else + this->m_MFCWindow->GetRenderWindow()->Render(); // @replaces m_RenderWindow->Render() +#endif if (!GetDocument()->IsAnimating()) { EndWaitCursor(); @@ -357,6 +379,7 @@ CMvDoc *CMvView::GetDocument() // non-debug version is inline ///////////////////////////////////////////////////////////////////////////// // The Window Function -- overrides the one implemented in the base class +#if 0 // @todo LRESULT CMvView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -378,6 +401,7 @@ LRESULT CMvView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) } return CView::WindowProc(message, wParam, lParam); } +#endif ///////////////////////////////////////////////////////////////////////////// // Public methods @@ -385,7 +409,11 @@ LRESULT CMvView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) void CMvView::SetInteractorStyle(int interactorStyle) { // This assumes that the interactor style is an vtkInteractorStyleSwitch +#if 0 vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::SafeDownCast(m_Interactor->GetInteractorStyle()); +#else + vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::SafeDownCast(m_MFCWindow->GetInteractor()->GetInteractorStyle()); // @replaces m_Interactor->GetInteractorStyle() +#endif if (iss) { if (interactorStyle == 1) @@ -433,7 +461,8 @@ void CMvView::ApplyViewSettings(mvGUISettings *gui) } else { - m_Renderer->SetBackground(1, 1, 1); + //m_Renderer->SetBackground(1, 1, 1); + m_Renderer->SetBackground(0.9, 0.9, 0.9); } } @@ -546,144 +575,144 @@ void CMvView::PlaceHeadlightWithCamera() void CMvView::WriteBmp(ofstream *file, BOOL useScreenResolution) { - int *size = m_RenderWindow->GetSize(); - - // Parameters for writing bitmap at screen resolution - int width = size[0]; - int height = size[1]; - int XPelsPerMeter = 0; - int YPelsPerMeter = 0; - float magnification = 1; - - if (!useScreenResolution) - { - if (m_BitmapResolutionOption == 1) - { - XPelsPerMeter = 5904; // 150 ppi - YPelsPerMeter = 5904; - if (m_BitmapSideOption == 0) - { - width = m_BitmapWidthInInches * 150; - height = (((long)width) * size[1]) / size[0]; - magnification = ((float)width) / size[0]; - } - else - { - height = m_BitmapHeightInInches * 150; - width = (((long)height) * size[0]) / size[1]; - magnification = ((float)height) / size[1]; - } - } - else if (m_BitmapResolutionOption == 2) - { - XPelsPerMeter = 11808; // 300 ppi - YPelsPerMeter = 11808; - if (m_BitmapSideOption == 0) - { - width = m_BitmapWidthInInches * 300; - height = (((long)width) * size[1]) / size[0]; - magnification = ((float)width) / size[0]; - } - else - { - height = m_BitmapHeightInInches * 300; - width = (((long)height) * size[0]) / size[1]; - magnification = ((float)height) / size[1]; - } - } - } - int dataWidth = ((width * 3 + 3) / 4) * 4; - - // write the bitmap file header - file->put((char)66); - file->put((char)77); - long temp = (long)(dataWidth * height) + 54L; - file->put((char)(temp % 256)); - file->put((char)((temp % 65536L) / 256)); - file->put((char)(temp / 65536L)); - for (int row = 0; row < 5; row++) - { - file->put((char)0); - } - file->put((char)54); - file->put((char)0); - file->put((char)0); - file->put((char)0); - - // write the bitmap info header - file->put((char)40); // biSize - file->put((char)0); - file->put((char)0); - file->put((char)0); - - file->put((char)(width % 256)); // biWidth - file->put((char)(width / 256)); - file->put((char)0); - file->put((char)0); - - file->put((char)(height % 256)); // biHeight - file->put((char)(height / 256)); - file->put((char)0); - file->put((char)0); - - file->put((char)1); // biPlanes - file->put((char)0); - file->put((char)24); // biBitCount - file->put((char)0); - - for (int row = 0; row < 8; row++) // biCompression and biSizeImage - { - file->put((char)0); - } - - file->put((char)(XPelsPerMeter % 256)); // biXPelsPerMeter - file->put((char)(XPelsPerMeter / 256)); - file->put((char)0); - file->put((char)0); - - file->put((char)(XPelsPerMeter % 256)); // biYPelsPerMeter - file->put((char)(XPelsPerMeter / 256)); - file->put((char)0); - file->put((char)0); - - for (int row = 0; row < 8; row++) // biClrUsed and biClrImportant - { - file->put((char)0); - } - - // temporarily change color bar and text size - CMvDoc *pDoc = GetDocument(); - int colorBarWidth = pDoc->GetColorBarWidth(); - int colorBarHeight = pDoc->GetColorBarHeight(); - int colorBarOffset = pDoc->GetColorBarOffset(); - int colorBarFontSize = pDoc->GetColorBarFontSize(); - int timeLabelFontSize = pDoc->GetTimeLabelFontSize(); - const double *pos = pDoc->GetTimeLabelPosition(); - double timeLabelPos[2]; - timeLabelPos[0] = pos[0]; - timeLabelPos[1] = pos[1]; - if (magnification != 1) - { - pDoc->SetColorBarSize((int)(colorBarWidth * magnification), - (int)(colorBarHeight * magnification), - (int)(colorBarOffset * magnification), FALSE); - pDoc->SetColorBarFontSize((int)(colorBarFontSize * magnification), FALSE); - pDoc->SetTimeLabelFontSize((int)(timeLabelFontSize * magnification), FALSE); - pDoc->SetTimeLabelPosition(timeLabelPos[0] * magnification, - timeLabelPos[1] * magnification, FALSE); - } - // render to memory and write bitmap data - m_RenderWindow->SetupMemoryRendering(width, height, GetDC()->GetSafeHdc()); - m_RenderWindow->Render(); - file->write((char *)m_RenderWindow->GetMemoryData(), dataWidth * height); - if (magnification != 1) - { - pDoc->SetColorBarSize(colorBarWidth, colorBarHeight, colorBarOffset, FALSE); - pDoc->SetColorBarFontSize(colorBarFontSize, FALSE); - pDoc->SetTimeLabelFontSize(timeLabelFontSize, FALSE); - pDoc->SetTimeLabelPosition(timeLabelPos[0], timeLabelPos[1], FALSE); - } - m_RenderWindow->ResumeScreenRendering(); + //int *size = m_RenderWindow->GetSize(); + + //// Parameters for writing bitmap at screen resolution + //int width = size[0]; + //int height = size[1]; + //int XPelsPerMeter = 0; + //int YPelsPerMeter = 0; + //float magnification = 1; + + //if (!useScreenResolution) + //{ + // if (m_BitmapResolutionOption == 1) + // { + // XPelsPerMeter = 5904; // 150 ppi + // YPelsPerMeter = 5904; + // if (m_BitmapSideOption == 0) + // { + // width = m_BitmapWidthInInches * 150; + // height = (((long)width) * size[1]) / size[0]; + // magnification = ((float)width) / size[0]; + // } + // else + // { + // height = m_BitmapHeightInInches * 150; + // width = (((long)height) * size[0]) / size[1]; + // magnification = ((float)height) / size[1]; + // } + // } + // else if (m_BitmapResolutionOption == 2) + // { + // XPelsPerMeter = 11808; // 300 ppi + // YPelsPerMeter = 11808; + // if (m_BitmapSideOption == 0) + // { + // width = m_BitmapWidthInInches * 300; + // height = (((long)width) * size[1]) / size[0]; + // magnification = ((float)width) / size[0]; + // } + // else + // { + // height = m_BitmapHeightInInches * 300; + // width = (((long)height) * size[0]) / size[1]; + // magnification = ((float)height) / size[1]; + // } + // } + //} + //int dataWidth = ((width * 3 + 3) / 4) * 4; + + //// write the bitmap file header + //file->put((char)66); + //file->put((char)77); + //long temp = (long)(dataWidth * height) + 54L; + //file->put((char)(temp % 256)); + //file->put((char)((temp % 65536L) / 256)); + //file->put((char)(temp / 65536L)); + //for (int row = 0; row < 5; row++) + //{ + // file->put((char)0); + //} + //file->put((char)54); + //file->put((char)0); + //file->put((char)0); + //file->put((char)0); + + //// write the bitmap info header + //file->put((char)40); // biSize + //file->put((char)0); + //file->put((char)0); + //file->put((char)0); + + //file->put((char)(width % 256)); // biWidth + //file->put((char)(width / 256)); + //file->put((char)0); + //file->put((char)0); + + //file->put((char)(height % 256)); // biHeight + //file->put((char)(height / 256)); + //file->put((char)0); + //file->put((char)0); + + //file->put((char)1); // biPlanes + //file->put((char)0); + //file->put((char)24); // biBitCount + //file->put((char)0); + + //for (int row = 0; row < 8; row++) // biCompression and biSizeImage + //{ + // file->put((char)0); + //} + + //file->put((char)(XPelsPerMeter % 256)); // biXPelsPerMeter + //file->put((char)(XPelsPerMeter / 256)); + //file->put((char)0); + //file->put((char)0); + + //file->put((char)(XPelsPerMeter % 256)); // biYPelsPerMeter + //file->put((char)(XPelsPerMeter / 256)); + //file->put((char)0); + //file->put((char)0); + + //for (int row = 0; row < 8; row++) // biClrUsed and biClrImportant + //{ + // file->put((char)0); + //} + + //// temporarily change color bar and text size + //CMvDoc *pDoc = GetDocument(); + //int colorBarWidth = pDoc->GetColorBarWidth(); + //int colorBarHeight = pDoc->GetColorBarHeight(); + //int colorBarOffset = pDoc->GetColorBarOffset(); + //int colorBarFontSize = pDoc->GetColorBarFontSize(); + //int timeLabelFontSize = pDoc->GetTimeLabelFontSize(); + //const double *pos = pDoc->GetTimeLabelPosition(); + //double timeLabelPos[2]; + //timeLabelPos[0] = pos[0]; + //timeLabelPos[1] = pos[1]; + //if (magnification != 1) + //{ + // pDoc->SetColorBarSize((int)(colorBarWidth * magnification), + // (int)(colorBarHeight * magnification), + // (int)(colorBarOffset * magnification), FALSE); + // pDoc->SetColorBarFontSize((int)(colorBarFontSize * magnification), FALSE); + // pDoc->SetTimeLabelFontSize((int)(timeLabelFontSize * magnification), FALSE); + // pDoc->SetTimeLabelPosition(timeLabelPos[0] * magnification, + // timeLabelPos[1] * magnification, FALSE); + //} + //// render to memory and write bitmap data + //m_RenderWindow->SetupMemoryRendering(width, height, GetDC()->GetSafeHdc()); + //m_RenderWindow->Render(); + //file->write((char *)m_RenderWindow->GetMemoryData(), dataWidth * height); + //if (magnification != 1) + //{ + // pDoc->SetColorBarSize(colorBarWidth, colorBarHeight, colorBarOffset, FALSE); + // pDoc->SetColorBarFontSize(colorBarFontSize, FALSE); + // pDoc->SetTimeLabelFontSize(timeLabelFontSize, FALSE); + // pDoc->SetTimeLabelPosition(timeLabelPos[0], timeLabelPos[1], FALSE); + //} + //m_RenderWindow->ResumeScreenRendering(); } ///////////////////////////////////////////////////////////////////////////// @@ -692,8 +721,20 @@ void CMvView::WriteBmp(ofstream *file, BOOL useScreenResolution) void CMvView::OnInitialUpdate() { CView::OnInitialUpdate(); - m_RenderWindow->SetWindowId(m_hWnd); +#if 1 + if (m_MFCWindow) + { + ASSERT(_CrtIsValidHeapPointer(this->m_MFCWindow)); + delete this->m_MFCWindow; + } + m_MFCWindow = new vtkMFCWindow(this); + + ASSERT(this->m_Renderer && _CrtIsValidHeapPointer(this->m_Renderer)); + m_MFCWindow->GetRenderWindow()->AddRenderer(this->m_Renderer); // @from CMvView ctor +#else + m_RenderWindow->SetWindowId(m_hWnd); // @done in vtkMFCWindow::SetRenderWindow m_RenderWindow->WindowInitialize(); +#endif GetDocument()->CreateToolDialogs(); SetInteractorStyle(GetDocument()->GetInteractorStyle()); } @@ -726,7 +767,9 @@ int CMvView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; - m_RenderWindow->SetParentId(lpCreateStruct->hwndParent); +#if 0 + m_RenderWindow->SetParentId(lpCreateStruct->hwndParent); // @done in vtkMFCWindow::SetRenderWindow +#endif return 0; } @@ -738,51 +781,58 @@ BOOL CMvView::OnEraseBkgnd(CDC *pDC) void CMvView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); +#if 0 if (m_Interactor->GetInitialized()) { m_Interactor->SetSize(cx, cy); } +#else + if (this->m_MFCWindow) + { + this->m_MFCWindow->MoveWindow(0, 0, cx, cy); // @replaces m_Interactor->SetSize(cx, cy) + } +#endif } void CMvView::OnCopyDisplayToClipboard() { - LPBITMAPINFOHEADER lpbi; - DWORD dwLen; - HANDLE hDIB = NULL; - int *size = m_RenderWindow->GetSize(); - int dataWidth = ((size[0] * 3 + 3) / 4) * 4; - - if (OpenClipboard()) - { - BeginWaitCursor(); - EmptyClipboard(); - - dwLen = sizeof(BITMAPINFOHEADER) + dataWidth * size[1]; - hDIB = ::GlobalAlloc(GHND, dwLen); - lpbi = (LPBITMAPINFOHEADER)::GlobalLock(hDIB); - - lpbi->biSize = sizeof(BITMAPINFOHEADER); - lpbi->biWidth = size[0]; - lpbi->biHeight = size[1]; - lpbi->biPlanes = 1; - lpbi->biBitCount = 24; - lpbi->biCompression = BI_RGB; - lpbi->biClrUsed = 0; - lpbi->biClrImportant = 0; - lpbi->biSizeImage = dataWidth * size[1]; - - m_RenderWindow->SetupMemoryRendering(size[0], size[1], GetDC()->GetSafeHdc()); - m_RenderWindow->Render(); - - memcpy((LPSTR)lpbi + lpbi->biSize, m_RenderWindow->GetMemoryData(), - dataWidth * size[1]); - - SetClipboardData(CF_DIB, hDIB); - ::GlobalUnlock(hDIB); - CloseClipboard(); - m_RenderWindow->ResumeScreenRendering(); - EndWaitCursor(); - } + //LPBITMAPINFOHEADER lpbi; + //DWORD dwLen; + //HANDLE hDIB = NULL; + //int *size = m_RenderWindow->GetSize(); + //int dataWidth = ((size[0] * 3 + 3) / 4) * 4; + + //if (OpenClipboard()) + //{ + // BeginWaitCursor(); + // EmptyClipboard(); + + // dwLen = sizeof(BITMAPINFOHEADER) + dataWidth * size[1]; + // hDIB = ::GlobalAlloc(GHND, dwLen); + // lpbi = (LPBITMAPINFOHEADER)::GlobalLock(hDIB); + + // lpbi->biSize = sizeof(BITMAPINFOHEADER); + // lpbi->biWidth = size[0]; + // lpbi->biHeight = size[1]; + // lpbi->biPlanes = 1; + // lpbi->biBitCount = 24; + // lpbi->biCompression = BI_RGB; + // lpbi->biClrUsed = 0; + // lpbi->biClrImportant = 0; + // lpbi->biSizeImage = dataWidth * size[1]; + + // m_RenderWindow->SetupMemoryRendering(size[0], size[1], GetDC()->GetSafeHdc()); + // m_RenderWindow->Render(); + + // memcpy((LPSTR)lpbi + lpbi->biSize, m_RenderWindow->GetMemoryData(), + // dataWidth * size[1]); + + // SetClipboardData(CF_DIB, hDIB); + // ::GlobalUnlock(hDIB); + // CloseClipboard(); + // m_RenderWindow->ResumeScreenRendering(); + // EndWaitCursor(); + //} } void CMvView::OnUpdateCopyDisplayToClipboard(CCmdUI *pCmdUI) diff --git a/ModelViewer/MvView.h b/ModelViewer/MvView.h index 138cead..f8d2d4a 100644 --- a/ModelViewer/MvView.h +++ b/ModelViewer/MvView.h @@ -16,8 +16,12 @@ using std::ofstream; class vtkLight; class vtkRenderer; +#if 1 +class vtkMFCWindow; // @replaces vtkWin32OpenGLRenderWindow and vtkWin32RenderWindowInteractor +#else class vtkWin32OpenGLRenderWindow; class vtkWin32RenderWindowInteractor; +#endif class mvGUISettings; class CMvView : public CView @@ -83,8 +87,12 @@ class CMvView : public CView // Objects for vtk rendering vtkRenderer* m_Renderer; +#if 1 + vtkMFCWindow* m_MFCWindow; // @replaces m_RenderWindow and m_Interactor +#else vtkWin32OpenGLRenderWindow* m_RenderWindow; vtkWin32RenderWindowInteractor* m_Interactor; +#endif vtkLight* m_Headlight; vtkLight* m_AuxiliaryLight; @@ -119,7 +127,9 @@ class CMvView : public CView CString m_FileStartNumber; // Protected methods - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); +#if 0 + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); // @todo +#endif void PlaceHeadlightWithCamera(); void WriteBmp(ofstream* file, BOOL useScreenResolution); diff --git a/mv/ModpathReader.cpp b/mv/ModpathReader.cpp index 9384187..1c2c928 100644 --- a/mv/ModpathReader.cpp +++ b/mv/ModpathReader.cpp @@ -145,7 +145,12 @@ void ModpathReader::ReadData(char *pathlineFile, int &numPathlines, int &numCoor if (intArray->GetValue(j) + 1 == i) { double w[4]; +#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION <= 2) || (VTK_MAJOR_VERSION <= 6)) doubleArray->GetTupleValue(j, w); +#else + doubleArray->GetTypedTuple(j, w); +#endif + if (v[0] == w[0] && v[1] == w[1] && v[2] == w[2]) { flag = -1; // ignore coincident point @@ -215,7 +220,11 @@ void ModpathReader::ReadData(char *pathlineFile, int &numPathlines, int &numCoor if (locator[i] != -1) { double w[4]; +#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION <= 2) || (VTK_MAJOR_VERSION <= 6)) doubleArray->GetTupleValue(j, w); +#else + doubleArray->GetTypedTuple(j, w); +#endif coordinates[3 * k] = w[0]; coordinates[3 * k + 1] = w[1]; coordinates[3 * k + 2] = w[2]; diff --git a/mv/mvColorBar.cpp b/mv/mvColorBar.cpp index 754acb7..0af9fde 100644 --- a/mv/mvColorBar.cpp +++ b/mv/mvColorBar.cpp @@ -258,7 +258,9 @@ int mvColorBar::RenderOpaqueGeometry(vtkViewport *viewport) } // polygons & cell colors +#if 0 unsigned char *rgba, *rgb; +#endif vtkIdType ptIds[4]; for (i = 0; i < m_NumberOfColors; i++) { @@ -268,23 +270,36 @@ int mvColorBar::RenderOpaqueGeometry(vtkViewport *viewport) ptIds[3] = ptIds[0] + 2; polys->InsertNextCell(4, ptIds); + unsigned char *rgb = colors->GetPointer(3 * i); // write into array directly if ((strcmp(m_LookupTable->GetClassName(), "vtkLogLookupTable") == 0) || (strcmp(m_LookupTable->GetClassName(), "mvLogColorTable") == 0)) { double logRange0 = log(range[0]) / log(10.0); double logRange1 = log(range[1]) / log(10.0); double e = logRange0 + (logRange1 - logRange0) * ((double)i / (m_NumberOfColors - 1.0)); - rgba = m_LookupTable->MapValue(pow(10.0, e)); +#if 0 + unsigned char* rgba = m_LookupTable->MapValue(pow(10.0, e)); +#else + const unsigned char *rgba = m_LookupTable->MapValue(pow(10.0, e)); + rgb[0] = rgba[0]; + rgb[1] = rgba[1]; + rgb[2] = rgba[2]; +#endif } else { - rgba = m_LookupTable->MapValue(range[0] + (range[1] - range[0]) * + const unsigned char *rgba = m_LookupTable->MapValue(range[0] + (range[1] - range[0]) * ((double)i / (m_NumberOfColors - 1.0))); + rgb[0] = rgba[0]; + rgb[1] = rgba[1]; + rgb[2] = rgba[2]; } +#if 0 rgb = colors->GetPointer(3 * i); // write into array directly rgb[0] = rgba[0]; rgb[1] = rgba[1]; rgb[2] = rgba[2]; +#endif } // Now position everything properly diff --git a/mv/mvDisplayObject.cpp b/mv/mvDisplayObject.cpp index db49c9b..440e9bd 100644 --- a/mv/mvDisplayObject.cpp +++ b/mv/mvDisplayObject.cpp @@ -171,10 +171,12 @@ void mvDisplayObject::SetScale(double xScale, double yScale, double zScale) m_LODActor->SetScale(xScale, yScale, zScale); } +#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) void mvDisplayObject::SetImmediateModeRendering(int b) { m_Mapper->SetImmediateModeRendering(b); } +#endif void mvDisplayObject::UseLODActor(int b) { diff --git a/mv/mvDisplayObject.h b/mv/mvDisplayObject.h index 845ca34..afa3e04 100644 --- a/mv/mvDisplayObject.h +++ b/mv/mvDisplayObject.h @@ -31,7 +31,9 @@ class MV_EXPORT mvDisplayObject double GetSpecular(); double GetSpecularPower(); void SetScale(double xScale, double yScale, double zScale); +#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) void SetImmediateModeRendering(int b); +#endif void UseLODActor(int b); void SetNumberOfCloudPoints(int n); void SetScalarRange(double min, double max); diff --git a/mv/mvManager.cpp b/mv/mvManager.cpp index 571b773..e607dec 100644 --- a/mv/mvManager.cpp +++ b/mv/mvManager.cpp @@ -1387,6 +1387,7 @@ void mvManager::ApplyDefaultSettings() // Grid Display } +#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) void mvManager::SetImmediateModeRendering(int b) { m_SolidMapper->SetImmediateModeRendering(b); @@ -1401,6 +1402,7 @@ void mvManager::SetImmediateModeRendering(int b) m_GridLines[i]->SetImmediateModeRendering(b); } } +#endif void mvManager::SetReleaseDataFlag(int b) { diff --git a/mv/mvManager.h b/mv/mvManager.h index 261de1d..018647a 100644 --- a/mv/mvManager.h +++ b/mv/mvManager.h @@ -72,7 +72,9 @@ class MV_EXPORT mvManager GridType GetGridType() const; bool GetIsStructuredGrid(); void ApplyDefaultSettings(); +#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) void SetImmediateModeRendering(int b); +#endif void SetReleaseDataFlag(int b); const int *GetScalarGridDimensions() const; const int *GetVectorGridDimensions() const; From a7bea8a24ff701611c840000743a70929b896b6b Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Fri, 6 May 2022 20:50:40 -0600 Subject: [PATCH 17/51] Standardized vtk version guards If vtk is compiled with qt the qt libraries need to be removed from MFC builds --- mv/ModpathReader.cpp | 4 ++-- mv/mvDisplayObject.cpp | 4 ++-- mv/mvDisplayObject.h | 4 ++-- mv/mvManager.cpp | 4 ++-- mv/mvManager.h | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mv/ModpathReader.cpp b/mv/ModpathReader.cpp index 1c2c928..df88c89 100644 --- a/mv/ModpathReader.cpp +++ b/mv/ModpathReader.cpp @@ -145,7 +145,7 @@ void ModpathReader::ReadData(char *pathlineFile, int &numPathlines, int &numCoor if (intArray->GetValue(j) + 1 == i) { double w[4]; -#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION <= 2) || (VTK_MAJOR_VERSION <= 6)) +#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION <= 1) || (VTK_MAJOR_VERSION < 7)) // https://vtk.org/doc/nightly/html/VTK-7-1-Changes.html doubleArray->GetTupleValue(j, w); #else doubleArray->GetTypedTuple(j, w); @@ -220,7 +220,7 @@ void ModpathReader::ReadData(char *pathlineFile, int &numPathlines, int &numCoor if (locator[i] != -1) { double w[4]; -#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION <= 2) || (VTK_MAJOR_VERSION <= 6)) +#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION <= 1) || (VTK_MAJOR_VERSION < 7)) // https://vtk.org/doc/nightly/html/VTK-7-1-Changes.html doubleArray->GetTupleValue(j, w); #else doubleArray->GetTypedTuple(j, w); diff --git a/mv/mvDisplayObject.cpp b/mv/mvDisplayObject.cpp index 440e9bd..5ff9579 100644 --- a/mv/mvDisplayObject.cpp +++ b/mv/mvDisplayObject.cpp @@ -171,10 +171,10 @@ void mvDisplayObject::SetScale(double xScale, double yScale, double zScale) m_LODActor->SetScale(xScale, yScale, zScale); } -#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) +#if ((VTK_MAJOR_VERSION == 8) && (VTK_MINOR_VERSION <= 1) || (VTK_MAJOR_VERSION < 8)) // https://vtk.org/Wiki/VTK/API_Changes_8_0_1_to_8_1_0 void mvDisplayObject::SetImmediateModeRendering(int b) { - m_Mapper->SetImmediateModeRendering(b); + m_Mapper->SetImmediateModeRendering(b); // deprecated vtk 8.1 } #endif diff --git a/mv/mvDisplayObject.h b/mv/mvDisplayObject.h index afa3e04..52d7afa 100644 --- a/mv/mvDisplayObject.h +++ b/mv/mvDisplayObject.h @@ -31,8 +31,8 @@ class MV_EXPORT mvDisplayObject double GetSpecular(); double GetSpecularPower(); void SetScale(double xScale, double yScale, double zScale); -#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) - void SetImmediateModeRendering(int b); +#if ((VTK_MAJOR_VERSION == 8) && (VTK_MINOR_VERSION <= 1) || (VTK_MAJOR_VERSION < 8)) // https://vtk.org/Wiki/VTK/API_Changes_8_0_1_to_8_1_0 + void SetImmediateModeRendering(int b); // deprecated vtk 8.1 #endif void UseLODActor(int b); void SetNumberOfCloudPoints(int n); diff --git a/mv/mvManager.cpp b/mv/mvManager.cpp index e607dec..238d431 100644 --- a/mv/mvManager.cpp +++ b/mv/mvManager.cpp @@ -1387,8 +1387,8 @@ void mvManager::ApplyDefaultSettings() // Grid Display } -#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) -void mvManager::SetImmediateModeRendering(int b) +#if ((VTK_MAJOR_VERSION == 8) && (VTK_MINOR_VERSION <= 1) || (VTK_MAJOR_VERSION < 8)) // https://vtk.org/Wiki/VTK/API_Changes_8_0_1_to_8_1_0 +void mvManager::SetImmediateModeRendering(int b) // deprecated vtk 8.1 { m_SolidMapper->SetImmediateModeRendering(b); m_IsosurfaceMapper->SetImmediateModeRendering(b); diff --git a/mv/mvManager.h b/mv/mvManager.h index 018647a..31f4fc0 100644 --- a/mv/mvManager.h +++ b/mv/mvManager.h @@ -72,8 +72,8 @@ class MV_EXPORT mvManager GridType GetGridType() const; bool GetIsStructuredGrid(); void ApplyDefaultSettings(); -#if ((VTK_MAJOR_VERSION <= 8) && (VTK_MINOR_VERSION < 2)) - void SetImmediateModeRendering(int b); +#if ((VTK_MAJOR_VERSION == 8) && (VTK_MINOR_VERSION <= 1) || (VTK_MAJOR_VERSION < 8)) // https://vtk.org/Wiki/VTK/API_Changes_8_0_1_to_8_1_0 + void SetImmediateModeRendering(int b); // deprecated vtk 8.1 #endif void SetReleaseDataFlag(int b); const int *GetScalarGridDimensions() const; From 5808d33423d5d9eeca756d1db84966eab9b21c1c Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Mon, 9 May 2022 11:24:22 -0600 Subject: [PATCH 18/51] Added COMPONENTS for find_package(VTK) for vtk-6.3 and vtk-9.1 Added vtk_module_autoinit for vtk-9.1 --- CMakeLists.txt | 164 ++++++++++++++++++++++++++++++++++++- ModelViewer/CMakeLists.txt | 23 ++++++ 2 files changed, 185 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b6212b..9a37b0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,11 +12,171 @@ include(GNUInstallDirs) # check for vtk message(STATUS "VTK_DIR=${VTK_DIR}") find_package(VTK REQUIRED) + +if (${VTK_VERSION} VERSION_EQUAL "6.3") + find_package(VTK + COMPONENTS + vtkalglib + vtkCommonColor + vtkCommonComputationalGeometry + vtkCommonCore + vtkCommonDataModel + vtkCommonExecutionModel + vtkCommonMath + vtkCommonMisc + vtkCommonSystem + vtkCommonTransforms + vtkDICOMParser + vtkFiltersCore + vtkFiltersExtraction + vtkFiltersGeneral + vtkFiltersGeometry + vtkFiltersModeling + vtkFiltersSources + vtkFiltersStatistics + vtkfreetype + vtkftgl + vtkGUISupportMFC + vtkImagingCore + vtkImagingFourier + vtkImagingHybrid + vtkInteractionStyle + vtkIOCore + vtkIOImage + vtkjpeg + # vtkmetaio + vtkpng + vtkRenderingCore + vtkRenderingFreeType + vtkRenderingLOD + vtkRenderingOpenGL + vtksys + vtktiff + vtkzlib + REQUIRED + ) +endif() + +if (${VTK_VERSION} VERSION_EQUAL "9.1") + find_package(VTK + COMPONENTS + CommonColor + CommonComputationalGeometry + CommonCore + CommonDataModel + CommonExecutionModel + CommonMath + CommonMisc + CommonSystem + CommonTransforms + doubleconversion + expat + FiltersCore + FiltersExtraction + FiltersGeneral + FiltersGeometry + FiltersModeling + FiltersSources + FiltersStatistics + fmt + freetype + glew + GUISupportMFC + InteractionStyle + IOCore + IOLegacy + IOXML + IOXMLParser + kissfft + loguru + lz4 + lzma + ParallelCore + ParallelDIY + pugixml + RenderingCore + RenderingFreeType + RenderingLOD + RenderingOpenGL2 + RenderingUI + vtksys # had to add vtk + zlib + REQUIRED + ) +endif() + +# if (${VTK_VERSION} VERSION_EQUAL "9.1") +# # python C:\VTK-9.1.0\Utilities\Maintenance\FindNeededModules.py -s ./ModelViewer/ -s ./mv/ -j C:\VTK-9.1.0-vs2019-x64-build\modules.json +# # find_package(VTK COMPONENTS RenderingExternal REQUIRED) +# find_package(VTK +# COMPONENTS +# CommonCore +# CommonDataModel +# CommonExecutionModel +# CommonTransforms +# FiltersCore +# FiltersExtraction +# FiltersGeneral +# FiltersGeometry +# FiltersModeling +# FiltersSources +# RenderingCore +# RenderingLOD +# # These modules are suggested since they implement an existing module. +# # Uncomment those you need. +# FiltersParallel # implements VTK::FiltersCore +# InteractionStyle # implements VTK::RenderingCore +# RenderingFreeType # implements VTK::RenderingCore +# RenderingOpenGL2 # implements VTK::RenderingCore +# RenderingUI # implements VTK::RenderingCore +# # manually added +# GUISupportMFC +# CommonMath +# CommonMisc +# CommonColor +# CommonComputationalGeometry +# vtksys +# CommonSystem +# glew ## vtkglew +# loguru ## vtkloguru +# FiltersStatistics +# ParallelDIY ## vtkParallelDIY +# ParallelCore +# kissfft ## vtkkissfft +# fmt ## vtkfmt +# pugixml ## vtkpugixml +# IOXML +# IOLegacy +# IOCore +# IOXMLParser +# lz4 ## vtklz4 +# doubleconversion ## vtkdoubleconversion +# lzma ## vtklzma +# zlib ## vtkzlib +# expat ## vtkexpat +# # after #include \nVTK_MODULE_INIT(vtkRenderingFreeType) +# freetype ## vtkfreetype +# FiltersHybrid +# FiltersTexture +# ImagingSources +# ImagingCore +# REQUIRED +# ) +# endif() + if(NOT VTK_DIR) message(FATAL_ERROR "Please set VTK_DIR.") endif() -message(STATUS "VTK_USE_FILE=${VTK_USE_FILE}") -include(${VTK_USE_FILE}) +if (NOT VTK_FOUND) + message("${VTK_NOT_FOUND_MESSAGE}") + return() +endif() +if (${VTK_VERSION} VERSION_LESS "9.0") + message(STATUS "VTK_USE_FILE=${VTK_USE_FILE}") + include(${VTK_USE_FILE}) +else() + message(STATUS "Found vtk ${VTK_VERSION}") +endif() # check for MFC find_package(MFC REQUIRED) diff --git a/ModelViewer/CMakeLists.txt b/ModelViewer/CMakeLists.txt index ef471e6..cd80932 100644 --- a/ModelViewer/CMakeLists.txt +++ b/ModelViewer/CMakeLists.txt @@ -141,6 +141,28 @@ add_executable(ModelViewer WIN32 VectorThresholdPage.h ) +if (${VTK_VERSION} VERSION_GREATER_EQUAL "9.0") + # vtk 9.1.0 + # + # VTK::RenderingFreeType fixes + # ERROR: In C:\VTK-9.1.0\Rendering\Core\vtkTextMapper.cxx, line 522 + # vtkOpenGLTextMapper (0000023EAF61D1A0): Could not locate vtkTextRenderer object. + # + # VTK::InteractionStyle fixes + # Warning: In C:\VTK-9.1.0\Rendering\Core\vtkInteractorStyleSwitchBase.cxx, line 37 + # vtkInteractorStyleSwitchBase (000001CF38197220): Warning: Link to vtkInteractionStyle for default style selection. + # + # Before adding, vtkWindowInteractor was broken (mouse did nothing) + # + vtk_module_autoinit( + TARGETS + ModelViewer + MODULES + VTK::RenderingFreeType # Fixes ERROR: In C:\VTK-9.1.0\Rendering\Core\vtkTextMapper.cxx, line 522 + VTK::InteractionStyle # Fixes nothing happens when interacting with the mouse + ) +endif() + # modify ModelViewer executable name set_target_properties(ModelViewer PROPERTIES OUTPUT_NAME mvmf6) @@ -201,6 +223,7 @@ if (MSVC) COMMAND ${CMAKE_COMMAND} -E echo Copying VTK dlls... ) foreach(_lib ${VTK_LIBRARIES}) + # message(STATUS "_lib=${_lib}") add_custom_command(TARGET ModelViewer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $ ) From 3f62a87f89e0d8aa472a7c8700620d489f775825 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Mon, 9 May 2022 11:37:45 -0600 Subject: [PATCH 19/51] minor cleanup --- CMakeLists.txt | 69 +++----------------------------------------------- 1 file changed, 3 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a37b0f..ab718f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,6 @@ project ( include(GNUInstallDirs) # check for vtk -message(STATUS "VTK_DIR=${VTK_DIR}") find_package(VTK REQUIRED) if (${VTK_VERSION} VERSION_EQUAL "6.3") @@ -105,66 +104,7 @@ if (${VTK_VERSION} VERSION_EQUAL "9.1") ) endif() -# if (${VTK_VERSION} VERSION_EQUAL "9.1") -# # python C:\VTK-9.1.0\Utilities\Maintenance\FindNeededModules.py -s ./ModelViewer/ -s ./mv/ -j C:\VTK-9.1.0-vs2019-x64-build\modules.json -# # find_package(VTK COMPONENTS RenderingExternal REQUIRED) -# find_package(VTK -# COMPONENTS -# CommonCore -# CommonDataModel -# CommonExecutionModel -# CommonTransforms -# FiltersCore -# FiltersExtraction -# FiltersGeneral -# FiltersGeometry -# FiltersModeling -# FiltersSources -# RenderingCore -# RenderingLOD -# # These modules are suggested since they implement an existing module. -# # Uncomment those you need. -# FiltersParallel # implements VTK::FiltersCore -# InteractionStyle # implements VTK::RenderingCore -# RenderingFreeType # implements VTK::RenderingCore -# RenderingOpenGL2 # implements VTK::RenderingCore -# RenderingUI # implements VTK::RenderingCore -# # manually added -# GUISupportMFC -# CommonMath -# CommonMisc -# CommonColor -# CommonComputationalGeometry -# vtksys -# CommonSystem -# glew ## vtkglew -# loguru ## vtkloguru -# FiltersStatistics -# ParallelDIY ## vtkParallelDIY -# ParallelCore -# kissfft ## vtkkissfft -# fmt ## vtkfmt -# pugixml ## vtkpugixml -# IOXML -# IOLegacy -# IOCore -# IOXMLParser -# lz4 ## vtklz4 -# doubleconversion ## vtkdoubleconversion -# lzma ## vtklzma -# zlib ## vtkzlib -# expat ## vtkexpat -# # after #include \nVTK_MODULE_INIT(vtkRenderingFreeType) -# freetype ## vtkfreetype -# FiltersHybrid -# FiltersTexture -# ImagingSources -# ImagingCore -# REQUIRED -# ) -# endif() - -if(NOT VTK_DIR) +if (NOT VTK_DIR) message(FATAL_ERROR "Please set VTK_DIR.") endif() if (NOT VTK_FOUND) @@ -172,21 +112,18 @@ if (NOT VTK_FOUND) return() endif() if (${VTK_VERSION} VERSION_LESS "9.0") - message(STATUS "VTK_USE_FILE=${VTK_USE_FILE}") include(${VTK_USE_FILE}) -else() - message(STATUS "Found vtk ${VTK_VERSION}") endif() # check for MFC find_package(MFC REQUIRED) -if(NOT MFC_FOUND) +if (NOT MFC_FOUND) message(FATAL_ERROR "MFC not found, please install Visual Studio Community 2019 / C++ MFC for latest v142 build tools (x86 & x64).") endif() option(MV_DEBUG_MEMORY_LEAKS "Build for memory debugging" OFF) mark_as_advanced(MV_DEBUG_MEMORY_LEAKS) -if(MV_DEBUG_MEMORY_LEAKS) +if (MV_DEBUG_MEMORY_LEAKS) set(BUILD_SHARED_LIBS OFF) else() set(BUILD_SHARED_LIBS ON) From 1ec36744b16e5de44cde8b5c14b5d4b761d88347 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Mon, 9 May 2022 11:46:52 -0600 Subject: [PATCH 20/51] reset background color --- ModelViewer/MvView.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ModelViewer/MvView.cpp b/ModelViewer/MvView.cpp index 71ec97c..4539c6c 100644 --- a/ModelViewer/MvView.cpp +++ b/ModelViewer/MvView.cpp @@ -97,8 +97,7 @@ CMvView::CMvView() #endif // vtk rendering m_Renderer = vtkRenderer::New(); - //m_Renderer->SetBackground(1, 1, 1); - m_Renderer->SetBackground(0.9, 0.9, 0.9); + m_Renderer->SetBackground(1, 1, 1); #ifdef NDEBUG m_Renderer->GlobalWarningDisplayOff(); #endif @@ -461,8 +460,7 @@ void CMvView::ApplyViewSettings(mvGUISettings *gui) } else { - //m_Renderer->SetBackground(1, 1, 1); - m_Renderer->SetBackground(0.9, 0.9, 0.9); + m_Renderer->SetBackground(1, 1, 1); } } From c5b221f6282f613c1238c92cd22d0bf457ee1f00 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 10 May 2022 13:23:21 -0600 Subject: [PATCH 21/51] Updated print/print-preview in OnDraw --- ModelViewer/MvView.cpp | 148 ++++++++++++++++++++++++----------------- ModelViewer/MvView.h | 4 +- 2 files changed, 90 insertions(+), 62 deletions(-) diff --git a/ModelViewer/MvView.cpp b/ModelViewer/MvView.cpp index 4539c6c..abfac53 100644 --- a/ModelViewer/MvView.cpp +++ b/ModelViewer/MvView.cpp @@ -160,7 +160,7 @@ CMvView::~CMvView() m_Headlight->Delete(); m_AuxiliaryLight->Delete(); #if 1 - if (this->m_MFCWindow) delete this->m_MFCWindow; + if (m_MFCWindow) delete m_MFCWindow; #endif } @@ -203,64 +203,92 @@ void CMvView::OnDraw(CDC *pDC) // Printing code if (pDC->IsPrinting()) // @todo { - //int size[2]; - //float scale; - - //BeginWaitCursor(); - //memcpy(size, m_RenderWindow->GetSize(), sizeof(int) * 2); - - //float cxDIB = (float)size[0]; // Size of DIB - x - //float cyDIB = (float)size[1]; // Size of DIB - y - //CRect rcDest; - - //// get size of printer page (in pixels) - //float cxPage = (float)pDC->GetDeviceCaps(HORZRES); - //float cyPage = (float)pDC->GetDeviceCaps(VERTRES); - //// get printer pixels per inch - //float cxInch = (float)pDC->GetDeviceCaps(LOGPIXELSX); - //float cyInch = (float)pDC->GetDeviceCaps(LOGPIXELSY); - //scale = cxInch / m_DPI; - - //// - //// Best Fit case -- create a rectangle which preserves - //// the DIB's aspect ratio, and fills the page horizontally. - //// - //// The formula in the "->bottom" field below calculates the Y - //// position of the printed bitmap, based on the size of the - //// bitmap, the width of the page, and the relative size of - //// a printed pixel (cyInch / cxInch). - //// - //rcDest.bottom = rcDest.left = 0; - //if ((cyDIB * cxPage / cxInch) > (cxDIB * cyPage / cyInch)) - //{ - // rcDest.top = cyPage; - // rcDest.right = (cyPage * cxInch * cxDIB) / (cyInch * cyDIB); - //} - //else - //{ - // rcDest.right = cxPage; - // rcDest.top = (cxPage * cyInch * cyDIB) / (cxInch * cxDIB); - //} - - //CRect rcDestLP(rcDest); - //pDC->DPtoLP(rcDestLP); - //int DPI = m_RenderWindow->GetDPI(); - - //m_RenderWindow->SetupMemoryRendering(rcDest.right / scale, - // rcDest.top / scale, pDC->GetSafeHdc()); - - //m_RenderWindow->Render(); - - //pDC->SetStretchBltMode(HALFTONE); - //::SetBrushOrgEx(pDC->GetSafeHdc(), 0, 0, NULL); - - //StretchBlt(pDC->GetSafeHdc(), 0, 0, - // rcDest.right, rcDest.top, - // m_RenderWindow->GetMemoryDC(), - // 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); - - //m_RenderWindow->ResumeScreenRendering(); - //EndWaitCursor(); +#if 0 + int size[2]; + float scale; + + BeginWaitCursor(); +#if 0 + memcpy(size, m_RenderWindow->GetSize(), sizeof(int) * 2); +#else + memcpy(size, m_MFCWindow->GetRenderWindow()->GetSize(), sizeof(int) * 2); +#endif + + float cxDIB = (float)size[0]; // Size of DIB - x + float cyDIB = (float)size[1]; // Size of DIB - y + CRect rcDest; + + // get size of printer page (in pixels) + float cxPage = (float)pDC->GetDeviceCaps(HORZRES); + float cyPage = (float)pDC->GetDeviceCaps(VERTRES); + // get printer pixels per inch + float cxInch = (float)pDC->GetDeviceCaps(LOGPIXELSX); + float cyInch = (float)pDC->GetDeviceCaps(LOGPIXELSY); + scale = cxInch / m_DPI; + + // + // Best Fit case -- create a rectangle which preserves + // the DIB's aspect ratio, and fills the page horizontally. + // + // The formula in the "->bottom" field below calculates the Y + // position of the printed bitmap, based on the size of the + // bitmap, the width of the page, and the relative size of + // a printed pixel (cyInch / cxInch). + // + rcDest.bottom = rcDest.left = 0; + if ((cyDIB * cxPage / cxInch) > (cxDIB * cyPage / cyInch)) + { + rcDest.top = cyPage; + rcDest.right = (cyPage * cxInch * cxDIB) / (cyInch * cyDIB); + } + else + { + rcDest.right = cxPage; + rcDest.top = (cxPage * cyInch * cyDIB) / (cxInch * cxDIB); + } + + CRect rcDestLP(rcDest); + pDC->DPtoLP(rcDestLP); +#if 0 + int DPI = m_RenderWindow->GetDPI(); + + m_RenderWindow->SetupMemoryRendering(rcDest.right / scale, + rcDest.top / scale, pDC->GetSafeHdc()); + + m_RenderWindow->Render(); +#else + int DPI = m_MFCWindow->GetRenderWindow()->GetDPI(); + + m_MFCWindow->GetRenderWindow()->SetupMemoryRendering(rcDest.right / scale, + rcDest.top / scale, pDC->GetSafeHdc()); + + m_MFCWindow->GetRenderWindow()->Render(); +#endif + + pDC->SetStretchBltMode(HALFTONE); + ::SetBrushOrgEx(pDC->GetSafeHdc(), 0, 0, NULL); + +#if 0 + StretchBlt(pDC->GetSafeHdc(), 0, 0, + rcDest.right, rcDest.top, + m_RenderWindow->GetMemoryDC(), + 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); + + m_RenderWindow->ResumeScreenRendering(); +#else + StretchBlt(pDC->GetSafeHdc(), 0, 0, + rcDest.right, rcDest.top, + m_MFCWindow->GetRenderWindow()->GetMemoryDC(), + 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); + + m_MFCWindow->GetRenderWindow()->ResumeScreenRendering(); +#endif + EndWaitCursor(); +#else + BeginWaitCursor(); + m_MFCWindow->DrawDC(pDC); + EndWaitCursor(); +#endif } // Screen drawing code else @@ -287,7 +315,7 @@ void CMvView::OnDraw(CDC *pDC) #if 0 m_RenderWindow->Render(); #else - this->m_MFCWindow->GetRenderWindow()->Render(); // @replaces m_RenderWindow->Render() + m_MFCWindow->GetRenderWindow()->Render(); // @replaces m_RenderWindow->Render() #endif if (!GetDocument()->IsAnimating()) { diff --git a/ModelViewer/MvView.h b/ModelViewer/MvView.h index f8d2d4a..7f8403e 100644 --- a/ModelViewer/MvView.h +++ b/ModelViewer/MvView.h @@ -90,8 +90,8 @@ class CMvView : public CView #if 1 vtkMFCWindow* m_MFCWindow; // @replaces m_RenderWindow and m_Interactor #else - vtkWin32OpenGLRenderWindow* m_RenderWindow; - vtkWin32RenderWindowInteractor* m_Interactor; + vtkWin32OpenGLRenderWindow* m_RenderWindow; // replaced by m_MFCWindow->GetRenderWindow() + vtkWin32RenderWindowInteractor* m_Interactor; // replaced by m_MFCWindow->GetInteractor() #endif vtkLight* m_Headlight; vtkLight* m_AuxiliaryLight; From e77bcc48c6357e75a170b886b135c6e7137b17f0 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 10 May 2022 13:28:51 -0600 Subject: [PATCH 22/51] cleanup print/print-preview in OnDraw --- ModelViewer/MvView.cpp | 85 +----------------------------------------- 1 file changed, 1 insertion(+), 84 deletions(-) diff --git a/ModelViewer/MvView.cpp b/ModelViewer/MvView.cpp index abfac53..e17c3cb 100644 --- a/ModelViewer/MvView.cpp +++ b/ModelViewer/MvView.cpp @@ -201,94 +201,11 @@ void CMvView::OnDraw(CDC *pDC) } #endif // Printing code - if (pDC->IsPrinting()) // @todo + if (pDC->IsPrinting()) { -#if 0 - int size[2]; - float scale; - - BeginWaitCursor(); -#if 0 - memcpy(size, m_RenderWindow->GetSize(), sizeof(int) * 2); -#else - memcpy(size, m_MFCWindow->GetRenderWindow()->GetSize(), sizeof(int) * 2); -#endif - - float cxDIB = (float)size[0]; // Size of DIB - x - float cyDIB = (float)size[1]; // Size of DIB - y - CRect rcDest; - - // get size of printer page (in pixels) - float cxPage = (float)pDC->GetDeviceCaps(HORZRES); - float cyPage = (float)pDC->GetDeviceCaps(VERTRES); - // get printer pixels per inch - float cxInch = (float)pDC->GetDeviceCaps(LOGPIXELSX); - float cyInch = (float)pDC->GetDeviceCaps(LOGPIXELSY); - scale = cxInch / m_DPI; - - // - // Best Fit case -- create a rectangle which preserves - // the DIB's aspect ratio, and fills the page horizontally. - // - // The formula in the "->bottom" field below calculates the Y - // position of the printed bitmap, based on the size of the - // bitmap, the width of the page, and the relative size of - // a printed pixel (cyInch / cxInch). - // - rcDest.bottom = rcDest.left = 0; - if ((cyDIB * cxPage / cxInch) > (cxDIB * cyPage / cyInch)) - { - rcDest.top = cyPage; - rcDest.right = (cyPage * cxInch * cxDIB) / (cyInch * cyDIB); - } - else - { - rcDest.right = cxPage; - rcDest.top = (cxPage * cyInch * cyDIB) / (cxInch * cxDIB); - } - - CRect rcDestLP(rcDest); - pDC->DPtoLP(rcDestLP); -#if 0 - int DPI = m_RenderWindow->GetDPI(); - - m_RenderWindow->SetupMemoryRendering(rcDest.right / scale, - rcDest.top / scale, pDC->GetSafeHdc()); - - m_RenderWindow->Render(); -#else - int DPI = m_MFCWindow->GetRenderWindow()->GetDPI(); - - m_MFCWindow->GetRenderWindow()->SetupMemoryRendering(rcDest.right / scale, - rcDest.top / scale, pDC->GetSafeHdc()); - - m_MFCWindow->GetRenderWindow()->Render(); -#endif - - pDC->SetStretchBltMode(HALFTONE); - ::SetBrushOrgEx(pDC->GetSafeHdc(), 0, 0, NULL); - -#if 0 - StretchBlt(pDC->GetSafeHdc(), 0, 0, - rcDest.right, rcDest.top, - m_RenderWindow->GetMemoryDC(), - 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); - - m_RenderWindow->ResumeScreenRendering(); -#else - StretchBlt(pDC->GetSafeHdc(), 0, 0, - rcDest.right, rcDest.top, - m_MFCWindow->GetRenderWindow()->GetMemoryDC(), - 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); - - m_MFCWindow->GetRenderWindow()->ResumeScreenRendering(); -#endif - EndWaitCursor(); -#else BeginWaitCursor(); m_MFCWindow->DrawDC(pDC); EndWaitCursor(); -#endif } // Screen drawing code else From c8fecfe336c7bd2f2a96d0792b1d9560a8844052 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Tue, 10 May 2022 14:19:48 -0600 Subject: [PATCH 23/51] build all branches on push --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62729a8..d5f1e30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,6 @@ name: build on: push: - branches: - - main - - develop paths-ignore: - .github/workflows/build-vtk*.yml - CODE_OF_CONDUCT.md From 76e2e996f162369f62c56c2c93742253391af932 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 08:07:16 -0600 Subject: [PATCH 24/51] Fixed missed conflict --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5a78f1..03a5ca6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -276,9 +276,6 @@ jobs: name: ${{env.USER_DIST_DIR}}.zip path: ${{env.USER_DIST_DIR}}.zip - # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch - - name: Create release - if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') - name: Create artifact uses: actions/upload-artifact@v3 with: From cc0a9987c847664f651f18397109c112de6541f9 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 08:09:21 -0600 Subject: [PATCH 25/51] Fixed another missed conflict --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03a5ca6..79887d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,6 @@ env: VTK_6_3_0_VS2017_X64_URL: https://github.com/MODFLOW-USGS/modelviewer-mf6/releases/download/vtk-6.3.0-vs2017-x64/vtk-6.3.0-vs2017-x64.7z HTMLHELP_URL: http://web.archive.org/web/20160201063255/http://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe SEM_VER_REGEX: ^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ - DIST_DIR: mvmf6-1.0.0 # automate this later jobs: From 2a8a2cd323aeffa7f3588174d4cbc35f0315819f Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 08:59:25 -0600 Subject: [PATCH 26/51] grouped together user artifact steps added develop* branch builds --- .github/workflows/build.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 79887d1..3c9223d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - develop + - develop* - "*-rc*" paths-ignore: - .github/workflows/build-vtk*.yml @@ -16,7 +16,7 @@ on: pull_request: branches: - main - - develop + - develop* - "*-rc*" paths-ignore: - .github/workflows/build-vtk*.yml @@ -251,17 +251,24 @@ jobs: shell: pwsh run: cmake --install _vs2019 --prefix ${{env.DIST_DIR}} --config release - - name: Install (user) - if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') - shell: pwsh - run: cmake --install _vs2019 --prefix ${{env.USER_DIST_DIR}} --config release - - name: Build mvmf6 zip if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') run: | Copy-Item .\Help\mvmf6.chm ${{env.DIST_DIR}}\bin\. 7z a -tzip ${{env.DIST_DIR}}.zip .\${{env.DIST_DIR}}\ + - name: Upload artifact + if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') + uses: actions/upload-artifact@v3 + with: + name: dist + path: ${{env.DIST_DIR}}.zip + + - name: Install (user) + if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + shell: pwsh + run: cmake --install _vs2019 --prefix ${{env.USER_DIST_DIR}} --config release + - name: Build mvmf6 zip (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') run: | @@ -275,12 +282,6 @@ jobs: name: ${{env.USER_DIST_DIR}}.zip path: ${{env.USER_DIST_DIR}}.zip - - name: Create artifact - uses: actions/upload-artifact@v3 - with: - name: dist - path: ${{env.DIST_DIR}}.zip - # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch - name: Create release # if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') || (github.repository != 'MODFLOW-USGS/modelviewer-mf6') From c9a42d3bae053ad3e3291d785fcbf24a2309d8c1 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 13:18:52 -0600 Subject: [PATCH 27/51] Added run_number to *DIST_DIR --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41dfe52..116b601 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,8 @@ on: - README.md env: - DIST_DIR: mvmf6-1.1.0-prerelease.x - USER_DIST_DIR: mvmf6-${{github.repository_owner}}-1.1.0-prerelease.x + DIST_DIR: mvmf6-1.1.0-prerelease.${{github.run_number}} + USER_DIST_DIR: mvmf6-${{github.repository_owner}}-1.1.0-prerelease.${{github.run_number}} VTK_VERSION: 6.3.0 RELEASES_URL: ${{github.api_url}}/repos/${{github.repository}}/releases VTK_6_3_0_VS2017_X64_URL: https://github.com/MODFLOW-USGS/modelviewer-mf6/releases/download/vtk-6.3.0-vs2017-x64/vtk-6.3.0-vs2017-x64.7z From 927af76236d000c91e80e699c874cc1635ef8dd7 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 15:04:54 -0600 Subject: [PATCH 28/51] Updated version for artifacts --- .github/workflows/build.yml | 30 ++++++++++++++++++++++++++---- code.json | 2 +- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 116b601..5edf01b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,13 +23,12 @@ on: - README.md env: - DIST_DIR: mvmf6-1.1.0-prerelease.${{github.run_number}} - USER_DIST_DIR: mvmf6-${{github.repository_owner}}-1.1.0-prerelease.${{github.run_number}} VTK_VERSION: 6.3.0 RELEASES_URL: ${{github.api_url}}/repos/${{github.repository}}/releases VTK_6_3_0_VS2017_X64_URL: https://github.com/MODFLOW-USGS/modelviewer-mf6/releases/download/vtk-6.3.0-vs2017-x64/vtk-6.3.0-vs2017-x64.7z HTMLHELP_URL: http://web.archive.org/web/20160201063255/http://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe SEM_VER_REGEX: ^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ + SEM_VER_REGEX_2: (?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))? jobs: @@ -52,6 +51,20 @@ jobs: echo "::error::Bad version in code.json -- $ver (see https://semver.org/)" exit 1 } + if ($Matches["prerelease"] -and $Matches["prerelease"] -match "runnumber") { + $runnumber = ${{github.run_number}} + $version = $Matches.0 -replace "runnumber", $runnumber + } + else { + $version = $Matches.0 + } + $name = ${{github.repository_owner}} + $DIST_DIR = "mvmf6-${version}" + $USER_DIST_DIR = "${name}-mvmf6-${version}" + # export + Write-Output "SEMVER=$version" >> $env:GITHUB_ENV + Write-Output "DIST_DIR=$DIST_DIR" >> $env:GITHUB_ENV + Write-Output "USER_DIST_DIR=$USER_DIST_DIR" >> $env:GITHUB_ENV - name: Cache vtk id: cache-vtk @@ -167,14 +180,23 @@ jobs: } Write-Output "NEXT_VERSION=$next_version" >> $env:GITHUB_ENV - - name: Update build date + - name: Update About dialog version + shell: pwsh + run: | + # sed ModelViewer.rc + $file = ".\ModelViewer\ModelViewer.rc" + (Get-Content $file) | Foreach-Object { + $_ -replace "Version $env:SEM_VER_REGEX_2", "Version $env:SEMVER" + } | Set-Content $file + + - name: Update About dialog build date shell: pwsh run: | # sed ModelViewer.rc $date_compiled = "$((Get-Date -UFormat '%m/%d/%Y (compiled %b %d %Y %T)'))" $file = ".\ModelViewer\ModelViewer.rc" (Get-Content $file) | Foreach-Object { - $_ -replace '"(?[0-1][1-9])\/(?[0-3][1-9])\/(?\d{4}) \(.*\)"', """$date_compiled"""` + $_ -replace '"(?[0-1][1-9])\/(?[0-3][1-9])\/(?\d{4}) \(.*\)"', """$date_compiled""" } | Set-Content $file # @TODO Only on push to main on MODFLOW-USGS/modelviewer-mf6 diff --git a/code.json b/code.json index 338b643..64db20c 100644 --- a/code.json +++ b/code.json @@ -3,7 +3,7 @@ "name": "modelviewer-mf6", "organization": "U.S. Geological Survey", "description": "Model Viewer for Modflow 6: A Program For Three-Dimensional Visualization of Ground-water Model Results", - "version": "1.1.0-prerelease.x", + "version": "1.1.0-prerelease.runnumber", "status": "Development", "permissions": { From 46c6d76d9e3259e9860d99b7b73db32dceb7248f Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 15:11:32 -0600 Subject: [PATCH 29/51] added quotes to $name var --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5edf01b..1a9daa4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: else { $version = $Matches.0 } - $name = ${{github.repository_owner}} + $name = "${{github.repository_owner}}" $DIST_DIR = "mvmf6-${version}" $USER_DIST_DIR = "${name}-mvmf6-${version}" # export From 114b711b1de62b8b9bd817a61607829d81bd1fc2 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 15:20:31 -0600 Subject: [PATCH 30/51] added quotes around $runnumber var --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a9daa4..cddce31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: exit 1 } if ($Matches["prerelease"] -and $Matches["prerelease"] -match "runnumber") { - $runnumber = ${{github.run_number}} + $runnumber = "${{github.run_number}}" $version = $Matches.0 -replace "runnumber", $runnumber } else { From bfed8f81c54a4371f0e5c2ed6b3331b8575626bf Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 15:43:53 -0600 Subject: [PATCH 31/51] fixed overwrite of $Matches hash --- .github/workflows/build.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cddce31..7ba6578 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,20 +51,19 @@ jobs: echo "::error::Bad version in code.json -- $ver (see https://semver.org/)" exit 1 } - if ($Matches["prerelease"] -and $Matches["prerelease"] -match "runnumber") { - $runnumber = "${{github.run_number}}" - $version = $Matches.0 -replace "runnumber", $runnumber + if ($Matches["prerelease"] -and $Matches["prerelease"] -like "*runnumber*") { + $version = $Matches.0 -replace "runnumber", "${{github.run_number}}" } else { - $version = $Matches.0 + $version = $Matches.0 } $name = "${{github.repository_owner}}" - $DIST_DIR = "mvmf6-${version}" - $USER_DIST_DIR = "${name}-mvmf6-${version}" + $dist_dir = "mvmf6-${version}" + $user_dist_dir = "${name}-mvmf6-${version}" # export Write-Output "SEMVER=$version" >> $env:GITHUB_ENV - Write-Output "DIST_DIR=$DIST_DIR" >> $env:GITHUB_ENV - Write-Output "USER_DIST_DIR=$USER_DIST_DIR" >> $env:GITHUB_ENV + Write-Output "DIST_DIR=$dist_dir" >> $env:GITHUB_ENV + Write-Output "USER_DIST_DIR=$user_dist_dir" >> $env:GITHUB_ENV - name: Cache vtk id: cache-vtk From 6b557fb589996c03a85cc6ee2f875d1c0b35b575 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 11 May 2022 16:12:23 -0600 Subject: [PATCH 32/51] merge from github.com:scharlton2/modelviewer-mf6 --- .github/workflows/build-vtk-leaks.yml | 54 +++++++++++++++++++++++++++ .github/workflows/build-vtk.yml | 54 +++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/.github/workflows/build-vtk-leaks.yml b/.github/workflows/build-vtk-leaks.yml index bfe5f4e..d838174 100644 --- a/.github/workflows/build-vtk-leaks.yml +++ b/.github/workflows/build-vtk-leaks.yml @@ -25,6 +25,33 @@ jobs: - uses: actions/checkout@v2 + - name: Install vs2017 build tools + shell: pwsh + run: | + $downloaded = $false + while (-Not $downloaded) { + try { + Invoke-WebRequest "https://aka.ms/vs/15/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe" -UseBasicParsing + $downloaded = $true + } + catch { + Write-Output "Retry" + } + } + $arg = @( + "--add", "Microsoft.VisualStudio.Workload.VCTools", ` + "--add", "Microsoft.VisualStudio.Workload.MSBuildTools", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATL", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATLMFC", ` + "--includeRecommended", ` + "--passive", ` + "--wait", ` + "--norestart", ` + "--noUpdateInstaller" + ) + $process = Start-Process -FilePath $env:TEMP\vs_buildtools.exe -ArgumentList $arg -Wait -PassThru + Write-Output $process.ExitCode + - name: Export env env: type: debug @@ -123,6 +150,33 @@ jobs: - uses: actions/checkout@v2 + - name: Install vs2017 build tools + shell: pwsh + run: | + $downloaded = $false + while (-Not $downloaded) { + try { + Invoke-WebRequest "https://aka.ms/vs/15/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe" -UseBasicParsing + $downloaded = $true + } + catch { + Write-Output "Retry" + } + } + $arg = @( + "--add", "Microsoft.VisualStudio.Workload.VCTools", ` + "--add", "Microsoft.VisualStudio.Workload.MSBuildTools", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATL", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATLMFC", ` + "--includeRecommended", ` + "--passive", ` + "--wait", ` + "--norestart", ` + "--noUpdateInstaller" + ) + $process = Start-Process -FilePath $env:TEMP\vs_buildtools.exe -ArgumentList $arg -Wait -PassThru + Write-Output $process.ExitCode + - name: Export env env: type: release diff --git a/.github/workflows/build-vtk.yml b/.github/workflows/build-vtk.yml index a6e1b63..132a878 100644 --- a/.github/workflows/build-vtk.yml +++ b/.github/workflows/build-vtk.yml @@ -25,6 +25,33 @@ jobs: - uses: actions/checkout@v2 + - name: Install vs2017 build tools + shell: pwsh + run: | + $downloaded = $false + while (-Not $downloaded) { + try { + Invoke-WebRequest "https://aka.ms/vs/15/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe" -UseBasicParsing + $downloaded = $true + } + catch { + Write-Output "Retry" + } + } + $arg = @( + "--add", "Microsoft.VisualStudio.Workload.VCTools", ` + "--add", "Microsoft.VisualStudio.Workload.MSBuildTools", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATL", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATLMFC", ` + "--includeRecommended", ` + "--passive", ` + "--wait", ` + "--norestart", ` + "--noUpdateInstaller" + ) + $process = Start-Process -FilePath $env:TEMP\vs_buildtools.exe -ArgumentList $arg -Wait -PassThru + Write-Output $process.ExitCode + - name: Export env env: type: debug @@ -110,6 +137,33 @@ jobs: - uses: actions/checkout@v2 + - name: Install vs2017 build tools + shell: pwsh + run: | + $downloaded = $false + while (-Not $downloaded) { + try { + Invoke-WebRequest "https://aka.ms/vs/15/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe" -UseBasicParsing + $downloaded = $true + } + catch { + Write-Output "Retry" + } + } + $arg = @( + "--add", "Microsoft.VisualStudio.Workload.VCTools", ` + "--add", "Microsoft.VisualStudio.Workload.MSBuildTools", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATL", ` + "--add", "Microsoft.VisualStudio.Component.VC.ATLMFC", ` + "--includeRecommended", ` + "--passive", ` + "--wait", ` + "--norestart", ` + "--noUpdateInstaller" + ) + $process = Start-Process -FilePath $env:TEMP\vs_buildtools.exe -ArgumentList $arg -Wait -PassThru + Write-Output $process.ExitCode + - name: Export env env: type: release From 848e842176c8d1a93ad24c4d40f0aeedd314e0f1 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 18 May 2022 18:51:41 -0600 Subject: [PATCH 33/51] fixed for vtkLookupTable::MapValue returning const now --- mv/mvColorBar.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/mv/mvColorBar.cpp b/mv/mvColorBar.cpp index 0af9fde..3cd5a5a 100644 --- a/mv/mvColorBar.cpp +++ b/mv/mvColorBar.cpp @@ -258,13 +258,10 @@ int mvColorBar::RenderOpaqueGeometry(vtkViewport *viewport) } // polygons & cell colors -#if 0 - unsigned char *rgba, *rgb; -#endif vtkIdType ptIds[4]; for (i = 0; i < m_NumberOfColors; i++) { - ptIds[0] = 2 * i; + ptIds[0] = 2 * (vtkIdType)i; ptIds[1] = ptIds[0] + 1; ptIds[2] = ptIds[1] + 2; ptIds[3] = ptIds[0] + 2; @@ -277,14 +274,10 @@ int mvColorBar::RenderOpaqueGeometry(vtkViewport *viewport) double logRange1 = log(range[1]) / log(10.0); double e = logRange0 + (logRange1 - logRange0) * ((double)i / (m_NumberOfColors - 1.0)); -#if 0 - unsigned char* rgba = m_LookupTable->MapValue(pow(10.0, e)); -#else const unsigned char *rgba = m_LookupTable->MapValue(pow(10.0, e)); rgb[0] = rgba[0]; rgb[1] = rgba[1]; rgb[2] = rgba[2]; -#endif } else { @@ -294,12 +287,6 @@ int mvColorBar::RenderOpaqueGeometry(vtkViewport *viewport) rgb[1] = rgba[1]; rgb[2] = rgba[2]; } -#if 0 - rgb = colors->GetPointer(3 * i); // write into array directly - rgb[0] = rgba[0]; - rgb[1] = rgba[1]; - rgb[2] = rgba[2]; -#endif } // Now position everything properly From 6974676949d3d7555f780a1b829481b4fdfdc5eb Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 18 May 2022 19:46:08 -0600 Subject: [PATCH 34/51] ifdef'd for vtk_6.3-vtk_9.1 and vtkMFCWindow --- CMakeLists.txt | 16 +- CMakePresets.json | 29 +- ModelViewer/CMakeLists.txt | 15 +- ModelViewer/MvView.cpp | 649 +++++++++++++++++++++++++------------ ModelViewer/MvView.h | 21 +- mv/CMakeLists.txt | 5 +- 6 files changed, 522 insertions(+), 213 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab718f0..009c8a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) project ( - MvProject + MvProject${VTK_SUFFIX} VERSION 1.1.0 LANGUAGES CXX C ) @@ -68,12 +68,14 @@ if (${VTK_VERSION} VERSION_EQUAL "9.1") CommonMisc CommonSystem CommonTransforms + DICOMParser doubleconversion expat FiltersCore FiltersExtraction FiltersGeneral FiltersGeometry + FiltersHybrid FiltersModeling FiltersSources FiltersStatistics @@ -81,24 +83,31 @@ if (${VTK_VERSION} VERSION_EQUAL "9.1") freetype glew GUISupportMFC + ImagingCore + ImagingSources InteractionStyle IOCore + IOImage IOLegacy IOXML IOXMLParser + jpeg kissfft loguru lz4 lzma + metaio ParallelCore ParallelDIY + png pugixml RenderingCore RenderingFreeType RenderingLOD RenderingOpenGL2 RenderingUI - vtksys # had to add vtk + vtksys + tiff zlib REQUIRED ) @@ -133,3 +142,6 @@ add_subdirectory(doc) add_subdirectory(examples) add_subdirectory(mv) add_subdirectory(ModelViewer) + +# set default startup directory +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ModelViewer) diff --git a/CMakePresets.json b/CMakePresets.json index 5b69c61..48e9699 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -13,7 +13,8 @@ "architecture": "x64", "binaryDir": "${sourceDir}/_${presetName}", "cacheVariables": { - "VTK_DIR" : "C:/VTK-6.3.0-vs2017-x64/lib/cmake/vtk-6.3" + "VTK_DIR" : "C:/VTK-6.3.0-vs2017-x64/lib/cmake/vtk-6.3", + "VTK_SUFFIX" : "-vtk-6.3" } }, { @@ -24,7 +25,31 @@ "binaryDir": "${sourceDir}/_${presetName}", "cacheVariables": { "VTK_DIR" : "C:/VTK-6.3.0-leaks-vs2017-x64/lib/cmake/vtk-6.3", - "MV_DEBUG_MEMORY_LEAKS": "ON" + "MV_DEBUG_MEMORY_LEAKS": "ON", + "VTK_SUFFIX" : "-vtk-6.3" + } + }, + { + "name": "vtk-9.1.0-vs2019-x64", + "displayName": "vs2019 x64 with vtk-9.1.0-vs2019-x64 (builds in _vtk-9.1.0-vs2019-x64)", + "generator": "Visual Studio 16 2019", + "architecture": "x64", + "binaryDir": "${sourceDir}/_${presetName}", + "cacheVariables": { + "VTK_DIR" : "C:/VTK-9.1.0-vs2019-x64/lib/cmake/vtk-9.1", + "VTK_SUFFIX" : "-vtk-9.1" + } + }, + { + "name": "vtk-9.1.0-leaks-vs2019-x64", + "displayName": "vs2019 x64 with VTK-9.1.0-leaks-vs2019-x64 (builds in _vtk-9.1.0-leaks-vs2019-x64)", + "generator": "Visual Studio 16 2019", + "architecture": "x64", + "binaryDir": "${sourceDir}/_${presetName}", + "cacheVariables": { + "VTK_DIR" : "C:/VTK-9.1.0-leaks-vs2019-x64/lib/cmake/vtk-9.1", + "MV_DEBUG_MEMORY_LEAKS": "ON", + "VTK_SUFFIX" : "-vtk-9.1" } } ] diff --git a/ModelViewer/CMakeLists.txt b/ModelViewer/CMakeLists.txt index cd80932..00ec80a 100644 --- a/ModelViewer/CMakeLists.txt +++ b/ModelViewer/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20) project ( ModelViewer - VERSION ${MvProject_VERSION_MAJOR}.${MvProject_VERSION_MINOR}.${MvProject_VERSION_PATCH} + VERSION ${MvProject${VTK_SUFFIX}_VERSION_MAJOR}.${MvProject${VTK_SUFFIX}_VERSION_MINOR}.${MvProject${VTK_SUFFIX}_VERSION_PATCH} LANGUAGES CXX ) @@ -154,12 +154,18 @@ if (${VTK_VERSION} VERSION_GREATER_EQUAL "9.0") # # Before adding, vtkWindowInteractor was broken (mouse did nothing) # + # vtk_module_autoinit( + # TARGETS + # ModelViewer + # MODULES + # VTK::RenderingFreeType # Fixes ERROR: In C:\VTK-9.1.0\Rendering\Core\vtkTextMapper.cxx, line 522 + # VTK::InteractionStyle # Fixes nothing happens when interacting with the mouse + # ) vtk_module_autoinit( TARGETS ModelViewer MODULES - VTK::RenderingFreeType # Fixes ERROR: In C:\VTK-9.1.0\Rendering\Core\vtkTextMapper.cxx, line 522 - VTK::InteractionStyle # Fixes nothing happens when interacting with the mouse + ${VTK_LIBRARIES} ) endif() @@ -168,6 +174,9 @@ set_target_properties(ModelViewer PROPERTIES OUTPUT_NAME mvmf6) target_compile_definitions(ModelViewer PRIVATE $<$:_DEBUG>) +# @TODO clean this up +target_compile_definitions(ModelViewer PRIVATE MV_USE_VTKMFCWINDOW) + if (MV_DEBUG_MEMORY_LEAKS) # set for all configs target_compile_definitions(ModelViewer PRIVATE MV_DEBUG_MEMORY_LEAKS) diff --git a/ModelViewer/MvView.cpp b/ModelViewer/MvView.cpp index e17c3cb..339c4b5 100644 --- a/ModelViewer/MvView.cpp +++ b/ModelViewer/MvView.cpp @@ -11,9 +11,15 @@ #include "BitmapResolutionDlg.h" #include "ExportAnimationDlg.h" -#if 1 +#if defined(MV_USE_VTKMFCWINDOW) #include "vtkMFCWindow.h" #endif + +#if !((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) +#include +#include +#endif + #include "vtkRenderer.h" #include "vtkLight.h" #include "vtkLightCollection.h" @@ -92,7 +98,7 @@ END_MESSAGE_MAP() CMvView::CMvView() { -#if 1 +#if defined(MV_USE_VTKMFCWINDOW) m_MFCWindow = nullptr; #endif // vtk rendering @@ -101,7 +107,7 @@ CMvView::CMvView() #ifdef NDEBUG m_Renderer->GlobalWarningDisplayOff(); #endif -#if 0 +#if !defined(MV_USE_VTKMFCWINDOW) m_RenderWindow = vtkWin32OpenGLRenderWindow::New(); // @done in vtkMFCWindow ctor m_RenderWindow->AddRenderer(m_Renderer); // @moved to OnInitialUpdate m_Interactor = vtkWin32RenderWindowInteractor::New(); // @done in vtkMFCWindow::SetRenderWindow @@ -130,10 +136,12 @@ CMvView::CMvView() m_HeadlightIntensity = 1.0; m_AuxiliaryLightIntensity = 0.0; +#if !defined(MV_USE_VTKMFCWINDOW) // printing m_PrintDPI = 100; m_PreviewDPI = 100; m_DPI = 100; +#endif // bitmap exporting m_BitmapResolutionOption = 0; @@ -147,19 +155,19 @@ CMvView::CMvView() CMvView::~CMvView() { -#if 0 - m_Interactor->Delete(); // @todo +#if !defined(MV_USE_VTKMFCWINDOW) + m_Interactor->Delete(); // @todo #endif m_Renderer->SetRenderWindow(NULL); m_Renderer->RemoveLight(m_Headlight); m_Renderer->RemoveLight(m_AuxiliaryLight); -#if 0 - m_RenderWindow->Delete(); // @todo +#if !defined(MV_USE_VTKMFCWINDOW) + m_RenderWindow->Delete(); // @todo #endif m_Renderer->Delete(); m_Headlight->Delete(); m_AuxiliaryLight->Delete(); -#if 1 +#if defined(MV_USE_VTKMFCWINDOW) if (m_MFCWindow) delete m_MFCWindow; #endif } @@ -191,7 +199,7 @@ void CMvView::OnDraw(CDC *pDC) CMvDoc *pDoc = GetDocument(); ASSERT_VALID(pDoc); // Initialize the interactor the first time this method is called -#if 0 +#if !defined(MV_USE_VTKMFCWINDOW) if (!m_Interactor->GetInitialized()) // @todo { m_Interactor->SetRenderWindow(m_RenderWindow); @@ -203,9 +211,70 @@ void CMvView::OnDraw(CDC *pDC) // Printing code if (pDC->IsPrinting()) { +#if defined(MV_USE_VTKMFCWINDOW) BeginWaitCursor(); m_MFCWindow->DrawDC(pDC); EndWaitCursor(); +#else + int size[2]; + float scale; + + BeginWaitCursor(); + memcpy(size, m_RenderWindow->GetSize(), sizeof(int) * 2); + + float cxDIB = (float)size[0]; // Size of DIB - x + float cyDIB = (float)size[1]; // Size of DIB - y + CRect rcDest; + + // get size of printer page (in pixels) + float cxPage = (float)pDC->GetDeviceCaps(HORZRES); + float cyPage = (float)pDC->GetDeviceCaps(VERTRES); + // get printer pixels per inch + float cxInch = (float)pDC->GetDeviceCaps(LOGPIXELSX); + float cyInch = (float)pDC->GetDeviceCaps(LOGPIXELSY); + scale = cxInch / m_DPI; + + // + // Best Fit case -- create a rectangle which preserves + // the DIB's aspect ratio, and fills the page horizontally. + // + // The formula in the "->bottom" field below calculates the Y + // position of the printed bitmap, based on the size of the + // bitmap, the width of the page, and the relative size of + // a printed pixel (cyInch / cxInch). + // + rcDest.bottom = rcDest.left = 0; + if ((cyDIB * cxPage / cxInch) > (cxDIB * cyPage / cyInch)) + { + rcDest.top = cyPage; + rcDest.right = (cyPage * cxInch * cxDIB) / (cyInch * cyDIB); + } + else + { + rcDest.right = cxPage; + rcDest.top = (cxPage * cyInch * cyDIB) / (cxInch * cxDIB); + } + + CRect rcDestLP(rcDest); + pDC->DPtoLP(rcDestLP); + int DPI = m_RenderWindow->GetDPI(); + + m_RenderWindow->SetupMemoryRendering(rcDest.right / scale, + rcDest.top / scale, pDC->GetSafeHdc()); + + m_RenderWindow->Render(); + + pDC->SetStretchBltMode(HALFTONE); + ::SetBrushOrgEx(pDC->GetSafeHdc(), 0, 0, NULL); + + StretchBlt(pDC->GetSafeHdc(), 0, 0, + rcDest.right, rcDest.top, + m_RenderWindow->GetMemoryDC(), + 0, 0, rcDest.right / scale, rcDest.top / scale, SRCCOPY); + + m_RenderWindow->ResumeScreenRendering(); + EndWaitCursor(); +#endif } // Screen drawing code else @@ -229,10 +298,10 @@ void CMvView::OnDraw(CDC *pDC) { BeginWaitCursor(); } -#if 0 - m_RenderWindow->Render(); +#if defined(MV_USE_VTKMFCWINDOW) + m_MFCWindow->GetRenderWindow()->Render(); // @replaces m_RenderWindow->Render() #else - m_MFCWindow->GetRenderWindow()->Render(); // @replaces m_RenderWindow->Render() + m_RenderWindow->Render(); #endif if (!GetDocument()->IsAnimating()) { @@ -266,6 +335,7 @@ BOOL CMvView::OnPreparePrinting(CPrintInfo *pInfo) void CMvView::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo) { +#if !defined(MV_USE_VTKMFCWINDOW) if (pInfo->m_bPreview) { m_DPI = m_PreviewDPI; @@ -278,6 +348,7 @@ void CMvView::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo) m_PrintDPI = (dlg.m_ImageQuality == 1) ? 300 : 100; m_DPI = m_PrintDPI; } +#endif } void CMvView::OnEndPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) @@ -321,9 +392,9 @@ CMvDoc *CMvView::GetDocument() // non-debug version is inline } #endif //_DEBUG +#if !defined(MV_USE_VTKMFCWINDOW) ///////////////////////////////////////////////////////////////////////////// // The Window Function -- overrides the one implemented in the base class -#if 0 // @todo LRESULT CMvView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -353,10 +424,10 @@ LRESULT CMvView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) void CMvView::SetInteractorStyle(int interactorStyle) { // This assumes that the interactor style is an vtkInteractorStyleSwitch -#if 0 - vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::SafeDownCast(m_Interactor->GetInteractorStyle()); +#if defined(MV_USE_VTKMFCWINDOW) + vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::SafeDownCast(m_MFCWindow->GetInteractor()->GetInteractorStyle()); // @replaces m_Interactor->GetInteractorStyle() #else - vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::SafeDownCast(m_MFCWindow->GetInteractor()->GetInteractorStyle()); // @replaces m_Interactor->GetInteractorStyle() + vtkInteractorStyleSwitch *iss = vtkInteractorStyleSwitch::SafeDownCast(m_Interactor->GetInteractorStyle()); #endif if (iss) { @@ -516,164 +587,294 @@ void CMvView::PlaceHeadlightWithCamera() light->SetFocalPoint(camera->GetFocalPoint()); } +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) void CMvView::WriteBmp(ofstream *file, BOOL useScreenResolution) { - //int *size = m_RenderWindow->GetSize(); - - //// Parameters for writing bitmap at screen resolution - //int width = size[0]; - //int height = size[1]; - //int XPelsPerMeter = 0; - //int YPelsPerMeter = 0; - //float magnification = 1; - - //if (!useScreenResolution) - //{ - // if (m_BitmapResolutionOption == 1) - // { - // XPelsPerMeter = 5904; // 150 ppi - // YPelsPerMeter = 5904; - // if (m_BitmapSideOption == 0) - // { - // width = m_BitmapWidthInInches * 150; - // height = (((long)width) * size[1]) / size[0]; - // magnification = ((float)width) / size[0]; - // } - // else - // { - // height = m_BitmapHeightInInches * 150; - // width = (((long)height) * size[0]) / size[1]; - // magnification = ((float)height) / size[1]; - // } - // } - // else if (m_BitmapResolutionOption == 2) - // { - // XPelsPerMeter = 11808; // 300 ppi - // YPelsPerMeter = 11808; - // if (m_BitmapSideOption == 0) - // { - // width = m_BitmapWidthInInches * 300; - // height = (((long)width) * size[1]) / size[0]; - // magnification = ((float)width) / size[0]; - // } - // else - // { - // height = m_BitmapHeightInInches * 300; - // width = (((long)height) * size[0]) / size[1]; - // magnification = ((float)height) / size[1]; - // } - // } - //} - //int dataWidth = ((width * 3 + 3) / 4) * 4; - - //// write the bitmap file header - //file->put((char)66); - //file->put((char)77); - //long temp = (long)(dataWidth * height) + 54L; - //file->put((char)(temp % 256)); - //file->put((char)((temp % 65536L) / 256)); - //file->put((char)(temp / 65536L)); - //for (int row = 0; row < 5; row++) - //{ - // file->put((char)0); - //} - //file->put((char)54); - //file->put((char)0); - //file->put((char)0); - //file->put((char)0); - - //// write the bitmap info header - //file->put((char)40); // biSize - //file->put((char)0); - //file->put((char)0); - //file->put((char)0); - - //file->put((char)(width % 256)); // biWidth - //file->put((char)(width / 256)); - //file->put((char)0); - //file->put((char)0); - - //file->put((char)(height % 256)); // biHeight - //file->put((char)(height / 256)); - //file->put((char)0); - //file->put((char)0); - - //file->put((char)1); // biPlanes - //file->put((char)0); - //file->put((char)24); // biBitCount - //file->put((char)0); - - //for (int row = 0; row < 8; row++) // biCompression and biSizeImage - //{ - // file->put((char)0); - //} - - //file->put((char)(XPelsPerMeter % 256)); // biXPelsPerMeter - //file->put((char)(XPelsPerMeter / 256)); - //file->put((char)0); - //file->put((char)0); - - //file->put((char)(XPelsPerMeter % 256)); // biYPelsPerMeter - //file->put((char)(XPelsPerMeter / 256)); - //file->put((char)0); - //file->put((char)0); - - //for (int row = 0; row < 8; row++) // biClrUsed and biClrImportant - //{ - // file->put((char)0); - //} - - //// temporarily change color bar and text size - //CMvDoc *pDoc = GetDocument(); - //int colorBarWidth = pDoc->GetColorBarWidth(); - //int colorBarHeight = pDoc->GetColorBarHeight(); - //int colorBarOffset = pDoc->GetColorBarOffset(); - //int colorBarFontSize = pDoc->GetColorBarFontSize(); - //int timeLabelFontSize = pDoc->GetTimeLabelFontSize(); - //const double *pos = pDoc->GetTimeLabelPosition(); - //double timeLabelPos[2]; - //timeLabelPos[0] = pos[0]; - //timeLabelPos[1] = pos[1]; - //if (magnification != 1) - //{ - // pDoc->SetColorBarSize((int)(colorBarWidth * magnification), - // (int)(colorBarHeight * magnification), - // (int)(colorBarOffset * magnification), FALSE); - // pDoc->SetColorBarFontSize((int)(colorBarFontSize * magnification), FALSE); - // pDoc->SetTimeLabelFontSize((int)(timeLabelFontSize * magnification), FALSE); - // pDoc->SetTimeLabelPosition(timeLabelPos[0] * magnification, - // timeLabelPos[1] * magnification, FALSE); - //} - //// render to memory and write bitmap data - //m_RenderWindow->SetupMemoryRendering(width, height, GetDC()->GetSafeHdc()); - //m_RenderWindow->Render(); - //file->write((char *)m_RenderWindow->GetMemoryData(), dataWidth * height); - //if (magnification != 1) - //{ - // pDoc->SetColorBarSize(colorBarWidth, colorBarHeight, colorBarOffset, FALSE); - // pDoc->SetColorBarFontSize(colorBarFontSize, FALSE); - // pDoc->SetTimeLabelFontSize(timeLabelFontSize, FALSE); - // pDoc->SetTimeLabelPosition(timeLabelPos[0], timeLabelPos[1], FALSE); - //} - //m_RenderWindow->ResumeScreenRendering(); +#if defined(MV_USE_VTKMFCWINDOW) + int *size = m_MFCWindow->GetRenderWindow()->GetSize(); +#else + int *size = m_RenderWindow->GetSize(); +#endif + + // Parameters for writing bitmap at screen resolution + int width = size[0]; + int height = size[1]; + int XPelsPerMeter = 0; + int YPelsPerMeter = 0; + float magnification = 1; + + if (!useScreenResolution) + { + if (m_BitmapResolutionOption == 1) + { + XPelsPerMeter = 5904; // 150 ppi + YPelsPerMeter = 5904; + if (m_BitmapSideOption == 0) + { + width = m_BitmapWidthInInches * 150; + height = (((long)width) * size[1]) / size[0]; + magnification = ((float)width) / size[0]; + } + else + { + height = m_BitmapHeightInInches * 150; + width = (((long)height) * size[0]) / size[1]; + magnification = ((float)height) / size[1]; + } + } + else if (m_BitmapResolutionOption == 2) + { + XPelsPerMeter = 11808; // 300 ppi + YPelsPerMeter = 11808; + if (m_BitmapSideOption == 0) + { + width = m_BitmapWidthInInches * 300; + height = (((long)width) * size[1]) / size[0]; + magnification = ((float)width) / size[0]; + } + else + { + height = m_BitmapHeightInInches * 300; + width = (((long)height) * size[0]) / size[1]; + magnification = ((float)height) / size[1]; + } + } + } + int dataWidth = ((width * 3 + 3) / 4) * 4; + + // write the bitmap file header + file->put((char)66); + file->put((char)77); + long temp = (long)(dataWidth * height) + 54L; + file->put((char)(temp % 256)); + file->put((char)((temp % 65536L) / 256)); + file->put((char)(temp / 65536L)); + for (int row = 0; row < 5; row++) + { + file->put((char)0); + } + file->put((char)54); + file->put((char)0); + file->put((char)0); + file->put((char)0); + + // write the bitmap info header + file->put((char)40); // biSize + file->put((char)0); + file->put((char)0); + file->put((char)0); + + file->put((char)(width % 256)); // biWidth + file->put((char)(width / 256)); + file->put((char)0); + file->put((char)0); + + file->put((char)(height % 256)); // biHeight + file->put((char)(height / 256)); + file->put((char)0); + file->put((char)0); + + file->put((char)1); // biPlanes + file->put((char)0); + file->put((char)24); // biBitCount + file->put((char)0); + + for (int row = 0; row < 8; row++) // biCompression and biSizeImage + { + file->put((char)0); + } + + file->put((char)(XPelsPerMeter % 256)); // biXPelsPerMeter + file->put((char)(XPelsPerMeter / 256)); + file->put((char)0); + file->put((char)0); + + file->put((char)(XPelsPerMeter % 256)); // biYPelsPerMeter + file->put((char)(XPelsPerMeter / 256)); + file->put((char)0); + file->put((char)0); + + for (int row = 0; row < 8; row++) // biClrUsed and biClrImportant + { + file->put((char)0); + } + + // temporarily change color bar and text size + CMvDoc *pDoc = GetDocument(); + int colorBarWidth = pDoc->GetColorBarWidth(); + int colorBarHeight = pDoc->GetColorBarHeight(); + int colorBarOffset = pDoc->GetColorBarOffset(); + int colorBarFontSize = pDoc->GetColorBarFontSize(); + int timeLabelFontSize = pDoc->GetTimeLabelFontSize(); + const double *pos = pDoc->GetTimeLabelPosition(); + double timeLabelPos[2]; + timeLabelPos[0] = pos[0]; + timeLabelPos[1] = pos[1]; + if (magnification != 1) + { + pDoc->SetColorBarSize((int)(colorBarWidth * magnification), + (int)(colorBarHeight * magnification), + (int)(colorBarOffset * magnification), FALSE); + pDoc->SetColorBarFontSize((int)(colorBarFontSize * magnification), FALSE); + pDoc->SetTimeLabelFontSize((int)(timeLabelFontSize * magnification), FALSE); + pDoc->SetTimeLabelPosition(timeLabelPos[0] * magnification, + timeLabelPos[1] * magnification, FALSE); + } + // render to memory and write bitmap data +#if defined(MV_USE_VTKMFCWINDOW) + m_MFCWindow->GetRenderWindow()->SetupMemoryRendering(width, height, GetDC()->GetSafeHdc()); + m_MFCWindow->GetRenderWindow()->Render(); + file->write((char *)m_MFCWindow->GetRenderWindow()->GetMemoryData(), dataWidth * height); +#else + m_RenderWindow->SetupMemoryRendering(width, height, GetDC()->GetSafeHdc()); + m_RenderWindow->Render(); + file->write((char *)m_RenderWindow->GetMemoryData(), dataWidth * height); +#endif + if (magnification != 1) + { + pDoc->SetColorBarSize(colorBarWidth, colorBarHeight, colorBarOffset, FALSE); + pDoc->SetColorBarFontSize(colorBarFontSize, FALSE); + pDoc->SetTimeLabelFontSize(timeLabelFontSize, FALSE); + pDoc->SetTimeLabelPosition(timeLabelPos[0], timeLabelPos[1], FALSE); + } +#if defined(MV_USE_VTKMFCWINDOW) + m_MFCWindow->GetRenderWindow()->ResumeScreenRendering(); +#else + m_RenderWindow->ResumeScreenRendering(); +#endif +} +#else +void CMvView::WriteBmp(const char *filename, BOOL useScreenResolution) +{ + //SetRedraw(FALSE); + m_MFCWindow->GetRenderWindow()->SetUseOffScreenBuffers(true); + + int size[2]; + size[0] = m_MFCWindow->GetRenderWindow()->GetSize()[0]; + size[1] = m_MFCWindow->GetRenderWindow()->GetSize()[1]; + + // Parameters for writing bitmap at screen resolution + int width = size[0]; + int height = size[1]; + float magnification = 1; + + if (!useScreenResolution) + { + if (m_BitmapResolutionOption == 1) + { + // 150 ppi + if (m_BitmapSideOption == 0) + { + width = m_BitmapWidthInInches * 150; + height = (((long)width) * size[1]) / size[0]; + magnification = ((float)width) / size[0]; + } + else + { + height = m_BitmapHeightInInches * 150; + width = (((long)height) * size[0]) / size[1]; + magnification = ((float)height) / size[1]; + } + } + else if (m_BitmapResolutionOption == 2) + { + // 300 ppi + if (m_BitmapSideOption == 0) + { + width = m_BitmapWidthInInches * 300; + height = (((long)width) * size[1]) / size[0]; + magnification = ((float)width) / size[0]; + } + else + { + height = m_BitmapHeightInInches * 300; + width = (((long)height) * size[0]) / size[1]; + magnification = ((float)height) / size[1]; + } + } + } + int dataWidth = ((width * 3 + 3) / 4) * 4; + + // temporarily change color bar and text size + CMvDoc *pDoc = GetDocument(); + int colorBarWidth = pDoc->GetColorBarWidth(); + int colorBarHeight = pDoc->GetColorBarHeight(); + int colorBarOffset = pDoc->GetColorBarOffset(); + int colorBarFontSize = pDoc->GetColorBarFontSize(); + int timeLabelFontSize = pDoc->GetTimeLabelFontSize(); + const double *pos = pDoc->GetTimeLabelPosition(); + double timeLabelPos[2]; + timeLabelPos[0] = pos[0]; + timeLabelPos[1] = pos[1]; + if (magnification != 1) + { + pDoc->SetColorBarSize((int)(colorBarWidth * magnification), + (int)(colorBarHeight * magnification), + (int)(colorBarOffset * magnification), FALSE); + pDoc->SetColorBarFontSize((int)(colorBarFontSize * magnification), FALSE); + pDoc->SetTimeLabelFontSize((int)(timeLabelFontSize * magnification), FALSE); + pDoc->SetTimeLabelPosition(timeLabelPos[0] * magnification, + timeLabelPos[1] * magnification, FALSE); + } + // render to memory and write bitmap data +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) + m_MFCWindow->GetRenderWindow()->SetupMemoryRendering(width, height, GetDC()->GetSafeHdc()); +#endif + m_MFCWindow->GetRenderWindow()->Render(); +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) + file->write((char *)m_MFCWindow->GetRenderWindow()->GetMemoryData(), dataWidth * height); +#else + { + // vtkRenderLargeImage + m_MFCWindow->GetRenderWindow()->SetSize(width, height); + + vtkNew renderLarge; + renderLarge->SetInput(m_Renderer); + renderLarge->SetMagnification(1); + + vtkNew bmpWriter; + bmpWriter->SetFileName(filename); + bmpWriter->SetInputConnection(renderLarge->GetOutputPort()); + bmpWriter->Write(); + } +#endif + if (magnification != 1) + { + pDoc->SetColorBarSize(colorBarWidth, colorBarHeight, colorBarOffset, FALSE); + pDoc->SetColorBarFontSize(colorBarFontSize, FALSE); + pDoc->SetTimeLabelFontSize(timeLabelFontSize, FALSE); + pDoc->SetTimeLabelPosition(timeLabelPos[0], timeLabelPos[1], FALSE); + } +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) + m_MFCWindow->GetRenderWindow()->ResumeScreenRendering(); +#else + if (magnification != 1) + { + m_MFCWindow->GetRenderWindow()->SetSize(size); + } + m_MFCWindow->GetRenderWindow()->SetUseOffScreenBuffers(false); + //SetRedraw(TRUE); +#endif } +#endif + ///////////////////////////////////////////////////////////////////////////// // Overrides void CMvView::OnInitialUpdate() { CView::OnInitialUpdate(); -#if 1 +#if defined(MV_USE_VTKMFCWINDOW) if (m_MFCWindow) { - ASSERT(_CrtIsValidHeapPointer(this->m_MFCWindow)); - delete this->m_MFCWindow; + ASSERT(_CrtIsValidHeapPointer(m_MFCWindow)); + delete m_MFCWindow; } m_MFCWindow = new vtkMFCWindow(this); - ASSERT(this->m_Renderer && _CrtIsValidHeapPointer(this->m_Renderer)); - m_MFCWindow->GetRenderWindow()->AddRenderer(this->m_Renderer); // @from CMvView ctor + ASSERT(m_Renderer && _CrtIsValidHeapPointer(m_Renderer)); + m_MFCWindow->GetRenderWindow()->AddRenderer(m_Renderer); // @from CMvView ctor #else m_RenderWindow->SetWindowId(m_hWnd); // @done in vtkMFCWindow::SetRenderWindow m_RenderWindow->WindowInitialize(); @@ -710,7 +911,7 @@ int CMvView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; -#if 0 +#if !defined(MV_USE_VTKMFCWINDOW) m_RenderWindow->SetParentId(lpCreateStruct->hwndParent); // @done in vtkMFCWindow::SetRenderWindow #endif return 0; @@ -724,58 +925,94 @@ BOOL CMvView::OnEraseBkgnd(CDC *pDC) void CMvView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); -#if 0 +#if !defined(MV_USE_VTKMFCWINDOW) if (m_Interactor->GetInitialized()) { m_Interactor->SetSize(cx, cy); } #else - if (this->m_MFCWindow) + if (m_MFCWindow) { - this->m_MFCWindow->MoveWindow(0, 0, cx, cy); // @replaces m_Interactor->SetSize(cx, cy) + m_MFCWindow->MoveWindow(0, 0, cx, cy); // @replaces m_Interactor->SetSize(cx, cy) } #endif } void CMvView::OnCopyDisplayToClipboard() { - //LPBITMAPINFOHEADER lpbi; - //DWORD dwLen; - //HANDLE hDIB = NULL; - //int *size = m_RenderWindow->GetSize(); - //int dataWidth = ((size[0] * 3 + 3) / 4) * 4; - - //if (OpenClipboard()) - //{ - // BeginWaitCursor(); - // EmptyClipboard(); - - // dwLen = sizeof(BITMAPINFOHEADER) + dataWidth * size[1]; - // hDIB = ::GlobalAlloc(GHND, dwLen); - // lpbi = (LPBITMAPINFOHEADER)::GlobalLock(hDIB); - - // lpbi->biSize = sizeof(BITMAPINFOHEADER); - // lpbi->biWidth = size[0]; - // lpbi->biHeight = size[1]; - // lpbi->biPlanes = 1; - // lpbi->biBitCount = 24; - // lpbi->biCompression = BI_RGB; - // lpbi->biClrUsed = 0; - // lpbi->biClrImportant = 0; - // lpbi->biSizeImage = dataWidth * size[1]; - - // m_RenderWindow->SetupMemoryRendering(size[0], size[1], GetDC()->GetSafeHdc()); - // m_RenderWindow->Render(); - - // memcpy((LPSTR)lpbi + lpbi->biSize, m_RenderWindow->GetMemoryData(), - // dataWidth * size[1]); - - // SetClipboardData(CF_DIB, hDIB); - // ::GlobalUnlock(hDIB); - // CloseClipboard(); - // m_RenderWindow->ResumeScreenRendering(); - // EndWaitCursor(); - //} +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) + LPBITMAPINFOHEADER lpbi; + DWORD dwLen; + HANDLE hDIB = NULL; +#if defined(MV_USE_VTKMFCWINDOW) + int *size = m_MFCWindow->GetRenderWindow()->GetSize(); +#else + int *size = m_RenderWindow->GetSize(); +#endif + int dataWidth = ((size[0] * 3 + 3) / 4) * 4; + + if (OpenClipboard()) + { + BeginWaitCursor(); + EmptyClipboard(); + + dwLen = sizeof(BITMAPINFOHEADER) + dataWidth * size[1]; + hDIB = ::GlobalAlloc(GHND, dwLen); + lpbi = (LPBITMAPINFOHEADER)::GlobalLock(hDIB); + + lpbi->biSize = sizeof(BITMAPINFOHEADER); + lpbi->biWidth = size[0]; + lpbi->biHeight = size[1]; + lpbi->biPlanes = 1; + lpbi->biBitCount = 24; + lpbi->biCompression = BI_RGB; + lpbi->biClrUsed = 0; + lpbi->biClrImportant = 0; + lpbi->biSizeImage = dataWidth * size[1]; + +#if defined(MV_USE_VTKMFCWINDOW) + m_MFCWindow->GetRenderWindow()->SetupMemoryRendering(size[0], size[1], GetDC()->GetSafeHdc()); + m_MFCWindow->GetRenderWindow()->Render(); + + memcpy((LPSTR)lpbi + lpbi->biSize, m_MFCWindow->GetRenderWindow()->GetMemoryData(), + dataWidth * size[1]); +#else + m_RenderWindow->SetupMemoryRendering(size[0], size[1], GetDC()->GetSafeHdc()); + m_RenderWindow->Render(); + + memcpy((LPSTR)lpbi + lpbi->biSize, m_RenderWindow->GetMemoryData(), + dataWidth * size[1]); +#endif + + SetClipboardData(CF_DIB, hDIB); + ::GlobalUnlock(hDIB); + CloseClipboard(); +#if !defined(MV_USE_VTKMFCWINDOW) + m_RenderWindow->ResumeScreenRendering(); +#endif + EndWaitCursor(); + } +#else + CClientDC clientDC(this); + + CDC memDC; + memDC.CreateCompatibleDC(&clientDC); + + int *size = m_MFCWindow->GetRenderWindow()->GetSize(); + int cx = size[0]; + int cy = size[1]; + + CBitmap memBmp; + memBmp.CreateCompatibleBitmap(&clientDC, cx, cy); + CBitmap *pOldBmp = memDC.SelectObject(&memBmp); + memDC.BitBlt(0, 0, cx, cy, &clientDC, 0, 0, SRCCOPY); + + // Copy to clipboard + OpenClipboard(); + EmptyClipboard(); + SetClipboardData(CF_BITMAP, memBmp.Detach()); + CloseClipboard(); +#endif } void CMvView::OnUpdateCopyDisplayToClipboard(CCmdUI *pCmdUI) @@ -897,7 +1134,9 @@ void CMvView::OnExportAnimation() int i = StartIndex; int fill; +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) ofstream *file = new ofstream; +#endif while (1) { if (!dlg.m_Preview) @@ -909,9 +1148,13 @@ void CMvView::OnExportAnimation() { strcat(b1, "0"); } +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) file->open((LPCTSTR)(path + b1 + b2 + ".bmp"), ios::out | ios::binary); WriteBmp(file, TRUE); file->close(); +#else + WriteBmp(path + b1 + b2 + ".bmp", TRUE); +#endif fileNumber++; } i++; @@ -935,7 +1178,9 @@ void CMvView::OnExportAnimation() pDoc->AdvanceOneTimePoint(); } } +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) delete file; +#endif pDoc->EndWaitCursor(); } @@ -994,10 +1239,14 @@ void CMvView::OnExportAsBmp() light->SetFocalPoint(camera->GetFocalPoint()); BeginWaitCursor(); +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) ofstream *file = new ofstream((LPCTSTR)fileName, ios::out | ios::binary); WriteBmp(file, m_BitmapResolutionOption == 0); file->close(); delete file; +#else + WriteBmp((LPCTSTR)fileName, m_BitmapResolutionOption == 0); +#endif EndWaitCursor(); } diff --git a/ModelViewer/MvView.h b/ModelViewer/MvView.h index 7f8403e..9632301 100644 --- a/ModelViewer/MvView.h +++ b/ModelViewer/MvView.h @@ -16,7 +16,7 @@ using std::ofstream; class vtkLight; class vtkRenderer; -#if 1 +#if defined(MV_USE_VTKMFCWINDOW) class vtkMFCWindow; // @replaces vtkWin32OpenGLRenderWindow and vtkWin32RenderWindowInteractor #else class vtkWin32OpenGLRenderWindow; @@ -36,8 +36,13 @@ class CMvView : public CView // Operations public: - void SetPrintDPI(int dpi) { m_PrintDPI = dpi; }; +#if !defined(MV_USE_VTKMFCWINDOW) + void SetPrintDPI(int dpi) + { + m_PrintDPI = dpi; + }; int GetPrintDPI() { return m_PrintDPI; }; +#endif void ResetExportImageParameters(); void RotateCamera(double angle); void ElevateCamera(double angle); @@ -87,8 +92,8 @@ class CMvView : public CView // Objects for vtk rendering vtkRenderer* m_Renderer; -#if 1 - vtkMFCWindow* m_MFCWindow; // @replaces m_RenderWindow and m_Interactor +#if defined(MV_USE_VTKMFCWINDOW) + vtkMFCWindow* m_MFCWindow; // @replaces m_RenderWindow and m_Interactor #else vtkWin32OpenGLRenderWindow* m_RenderWindow; // replaced by m_MFCWindow->GetRenderWindow() vtkWin32RenderWindowInteractor* m_Interactor; // replaced by m_MFCWindow->GetInteractor() @@ -104,10 +109,12 @@ class CMvView : public CView int m_ViewFromDirection; BOOL m_DoResetViewpoint; +#if !defined(MV_USE_VTKMFCWINDOW) // Parameters for printing int m_PrintDPI; int m_PreviewDPI; int m_DPI; +#endif // Parameters for exporting bitmap int m_BitmapResolutionOption; @@ -127,11 +134,15 @@ class CMvView : public CView CString m_FileStartNumber; // Protected methods -#if 0 +#if !defined(MV_USE_VTKMFCWINDOW) virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); // @todo #endif void PlaceHeadlightWithCamera(); +#if ((VTK_MAJOR_VERSION == 6) && (VTK_MINOR_VERSION <= 3) || (VTK_MAJOR_VERSION < 6)) void WriteBmp(ofstream* file, BOOL useScreenResolution); +#else + void WriteBmp(const char *filename, BOOL useScreenResolution); +#endif // Generated message map functions protected: diff --git a/mv/CMakeLists.txt b/mv/CMakeLists.txt index bb646d4..db3c6db 100644 --- a/mv/CMakeLists.txt +++ b/mv/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20) project ( mv - VERSION ${MvProject_VERSION_MAJOR}.${MvProject_VERSION_MINOR}.${MvProject_VERSION_PATCH} + VERSION ${MvProject${VTK_SUFFIX}_VERSION_MAJOR}.${MvProject${VTK_SUFFIX}_VERSION_MINOR}.${MvProject${VTK_SUFFIX}_VERSION_PATCH} LANGUAGES CXX C ) @@ -74,6 +74,9 @@ generate_export_header(mv target_compile_definitions(mv PRIVATE $<$:_DEBUG>) +# @TODO clean this up +target_compile_definitions(mv PRIVATE MV_USE_VTKMFCWINDOW) + if (MV_DEBUG_MEMORY_LEAKS) # set for all configs target_compile_definitions(mv PRIVATE MV_DEBUG_MEMORY_LEAKS) From cca4633e7de1ed2c5df1792957ee0ef3531b849a Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 18 May 2022 19:47:23 -0600 Subject: [PATCH 35/51] Updated for threshold deprecation in vtk_9.1 --- mv/mvGridLayer.cpp | 17 +++++++++++++++-- mv/mvGridLines.cpp | 7 ++++++- mv/mvManager.cpp | 23 ++++++++++++++++++++--- mv/mvModelFeatures.cpp | 16 ++++++++++++++-- 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/mv/mvGridLayer.cpp b/mv/mvGridLayer.cpp index 650596d..0e47fde 100644 --- a/mv/mvGridLayer.cpp +++ b/mv/mvGridLayer.cpp @@ -93,13 +93,26 @@ void mvGridLayer::Build() m_Threshold->SetInputData(polyData); polyData->Delete(); m_LayerPosition = 0; - m_Threshold->ThresholdBetween(-0.5, 0.5); +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_Threshold->ThresholdBetween(-0.5, 0.5); // deprecated as of VTK 9.1 +#else + m_Threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN); + m_Threshold->SetLowerThreshold(-0.5); + m_Threshold->SetUpperThreshold(0.5); +#endif } void mvGridLayer::SetLayerPosition(int layerPosition) { m_LayerPosition = layerPosition; - m_Threshold->ThresholdBetween(layerPosition - 0.5, layerPosition + 0.5); + +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_Threshold->ThresholdBetween(layerPosition - 0.5, layerPosition + 0.5); // deprecated as of VTK 9.1 +#else + m_Threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN); + m_Threshold->SetLowerThreshold(layerPosition - 0.5); + m_Threshold->SetUpperThreshold(layerPosition + 0.5); +#endif } int mvGridLayer::GetLayerPosition() const diff --git a/mv/mvGridLines.cpp b/mv/mvGridLines.cpp index ec24754..500669b 100644 --- a/mv/mvGridLines.cpp +++ b/mv/mvGridLines.cpp @@ -76,7 +76,12 @@ void mvGridLines::SetInputData(vtkUnstructuredGrid *dataSet, int numCol, int num void mvGridLines::SetThresholdMin(double value) { - m_Threshold->ThresholdByLower(value); +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_Threshold->ThresholdByLower(value); // deprecated as of VTK 9.1 +#else + m_Threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_LOWER); + m_Threshold->SetLowerThreshold(value); +#endif } const int *mvGridLines::GetExtent() const diff --git a/mv/mvManager.cpp b/mv/mvManager.cpp index 238d431..3ee2629 100644 --- a/mv/mvManager.cpp +++ b/mv/mvManager.cpp @@ -947,7 +947,12 @@ char *mvManager::LoadData(char *modelName, char *dataFileList) // Define the cutoff value that indicates inactive cells. double cutoff = m_DataSource->GetInactiveCellValue() * 0.999; - m_ActiveScalarDataSet->ThresholdByLower(cutoff); +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_ActiveScalarDataSet->ThresholdByLower(cutoff); // deprecated as of VTK 9.1 +#else + m_ActiveScalarDataSet->SetThresholdFunction(vtkThreshold::THRESHOLD_LOWER); + m_ActiveScalarDataSet->SetLowerThreshold(cutoff); +#endif // Bounding box SetBoundingBoxBounds(); @@ -4133,13 +4138,25 @@ void mvManager::SolidThresholdOff() void mvManager::SetSolidThresholdLimits(double minValue, double maxValue) { - m_BlockySolidThreshold->ThresholdBetween(minValue, maxValue); +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_BlockySolidThreshold->ThresholdBetween(minValue, maxValue); // deprecated as of VTK 9.1 +#else + m_BlockySolidThreshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN); + m_BlockySolidThreshold->SetLowerThreshold(minValue); + m_BlockySolidThreshold->SetUpperThreshold(maxValue); +#endif m_GridShellClipMin->SetValue(minValue); m_GridShellClipMax->SetValue(maxValue); m_SmoothSolidIsosurface->GenerateValues(2, minValue, maxValue); m_FacesClipMin->SetValue(minValue); m_FacesClipMax->SetValue(maxValue); - m_FacesThreshold->ThresholdBetween(minValue, maxValue); +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_FacesThreshold->ThresholdBetween(minValue, maxValue); // deprecated as of VTK 9.1 +#else + m_FacesThreshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN); + m_FacesThreshold->SetLowerThreshold(minValue); + m_FacesThreshold->SetUpperThreshold(maxValue); +#endif m_SolidThresholdMin[m_ActiveDataType] = minValue; m_SolidThresholdMax[m_ActiveDataType] = maxValue; } diff --git a/mv/mvModelFeatures.cpp b/mv/mvModelFeatures.cpp index 4db354a..f028ac7 100644 --- a/mv/mvModelFeatures.cpp +++ b/mv/mvModelFeatures.cpp @@ -36,7 +36,13 @@ mvModelFeatures::mvModelFeatures() m_UnstructuredGrid = 0; m_ThresholdCells = vtkSmartPointer::New(); m_ThresholdCells->SetInputData(m_StructuredGrid); - m_ThresholdCells->ThresholdBetween(0.5, 10000); +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_ThresholdCells->ThresholdBetween(0.5, 10000); // deprecated as of VTK 9.1 +#else + m_ThresholdCells->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN); + m_ThresholdCells->SetLowerThreshold(0.5); + m_ThresholdCells->SetUpperThreshold(10000); +#endif m_ThresholdCells->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, vtkDataSetAttributes::SCALARS); SetMapperInputConnection(m_ThresholdCells->GetOutputPort()); @@ -250,7 +256,13 @@ void mvModelFeatures::Build() else { SetMapperInputConnection(m_ThresholdCells->GetOutputPort()); - m_ThresholdCells->ThresholdBetween(0.5, m_NumberOfModelFeatureTypes + 0.5); +#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9)) + m_ThresholdCells->ThresholdBetween(0.5, m_NumberOfModelFeatureTypes + 0.5); // deprecated as of VTK 9.1 +#else + m_ThresholdCells->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN); + m_ThresholdCells->SetLowerThreshold(0.5); + m_ThresholdCells->SetUpperThreshold(m_NumberOfModelFeatureTypes + 0.5); +#endif if (m_UnstructuredGrid) { m_UnstructuredGrid->SetCells(m_CellTypes, m_CellLocations, m_Cells); From 00d3c9b4979b1942fda8867260fce00e3c26104f Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 19 May 2022 11:47:08 -0600 Subject: [PATCH 36/51] added build with vtk-9.1.0 CI --- .github/workflows/build.yml | 353 +++++++++++++++++++++++++++++++++++- CMakePresets.json | 24 ++- 2 files changed, 361 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ba6578..03e762f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,16 +23,16 @@ on: - README.md env: - VTK_VERSION: 6.3.0 RELEASES_URL: ${{github.api_url}}/repos/${{github.repository}}/releases VTK_6_3_0_VS2017_X64_URL: https://github.com/MODFLOW-USGS/modelviewer-mf6/releases/download/vtk-6.3.0-vs2017-x64/vtk-6.3.0-vs2017-x64.7z + VTK_9_1_0_VS2019_X64_URL: https://github.com/MODFLOW-USGS/modelviewer-mf6/releases/download/vtk-9.1.0-vs2019-x64/vtk-9.1.0-vs2019-x64.7z HTMLHELP_URL: http://web.archive.org/web/20160201063255/http://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe SEM_VER_REGEX: ^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ SEM_VER_REGEX_2: (?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))? jobs: - build: + build-6.3: runs-on: windows-2019 steps: @@ -257,16 +257,16 @@ jobs: - name: Configure shell: pwsh - run: cmake --preset vs2019 + run: cmake --preset vtk-6.3.0-vs2017-x64 - name: Build shell: pwsh - run: cmake --build --preset vs2019 --config release + run: cmake --build --preset vtk-6.3.0-vs2017-x64 --config release - name: Install if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') shell: pwsh - run: cmake --install _vs2019 --prefix ${{env.DIST_DIR}} --config release + run: cmake --install _vtk-6.3.0-vs2017-x64 --prefix ${{env.DIST_DIR}} --config release - name: Build mvmf6 zip if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') @@ -278,13 +278,13 @@ jobs: if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: - name: dist + name: dist-vtk-6.3 path: ${{env.DIST_DIR}}.zip - name: Install (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') shell: pwsh - run: cmake --install _vs2019 --prefix ${{env.USER_DIST_DIR}} --config release + run: cmake --install _vtk-6.3.0-vs2017-x64 --prefix ${{env.USER_DIST_DIR}} --config release - name: Build mvmf6 zip (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') @@ -296,7 +296,344 @@ jobs: if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: - name: ${{env.USER_DIST_DIR}}.zip + name: dist-vtk-6.3 + path: ${{env.USER_DIST_DIR}}.zip + + # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch + - name: Create release + # if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') || (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + if: ${{ false }} # skip for now + run: | + # store new commit + $target_commitish = (git log -n1 --format=format:"%H") + + if (! ($env:NEXT_VERSION -match "^(?0|[1-9]\d*)\.(?[0|1-9]\d*)\.(?[0|1-9]\d*)$") ) { + throw "Bad version" + } + $version = $env:NEXT_VERSION + + # create headers dictionary + $h = @{"Authorization" = "token ${{secrets.GITHUB_TOKEN}}"} + + $releases_url = "${{env.releases_url}}" + + # create release + # POST /repos/{owner}/{repo}/releases + # see https://docs.github.com/en/rest/reference/repos#create-a-release + # + $create = @{ + "tag_name" = $version + "target_commitish" = "$target_commitish" + "name" = "Model Viewer for Modflow 6 Version " + $version + "body" = "Model Viewer for Modflow 6 Version " + $version + "draft" = $true + } + $create_json = $create | ConvertTo-Json + $release = Invoke-WebRequest -Uri $releases_url -Headers $h -Method POST -Body $create_json + + # upload artifact (asset) + # POST /repos/{owner}/{repo}/releases/{release_id}/assets + # see https://docs.github.com/en/rest/reference/repos#upload-a-release-asset + # + $upload_uri = ($release.Content | ConvertFrom-Json).upload_url + if (! ($upload_uri -match "(.*)\{\?name,label\}") ) { + # expecting URI{?name,label} + # ie https://uploads.github.com/repos/MODFLOW-USGS/modelviewer-mf6/releases/24058628/assets{?name,label} + throw "Bad upload_url" + } + + # upload + $upload_uri = $Matches[1] + "?name=$env:DIST_DIR.zip" + $h["Content-type"] = "application/zip" + $bytes = [System.IO.File]::ReadAllBytes("$env:DIST_DIR.zip") + $upload = Invoke-WebRequest -Uri $upload_uri -Headers $h -Method POST -Body $bytes + + # update release + # PATCH /repos/{owner}/{repo}/releases/{release_id} + # see https://docs.github.com/en/rest/reference/repos#update-a-release + # + $release_id = ($release.Content | ConvertFrom-Json).id + $h.Remove("Content-type") + $update = @{ "draft" = $false } + $update_json = $update | ConvertTo-Json + $release = Invoke-WebRequest -Uri "$releases_url/$release_id" -Headers $h -Method PATCH -Body $update_json + + # display download url + Write-Output "$((($release.Content | ConvertFrom-Json).assets).browser_download_url)" + Get-FileHash "$env:DIST_DIR.zip" + Remove-Item "$env:DIST_DIR.zip" + +################################################################################################### + +################################################################################################### + +################################################################################################### + + build-9.1: + runs-on: windows-2019 + + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Verify version in code.json + shell: pwsh + run: | + $file = ".\code.json" + $ver = ((Get-Content $file) | ConvertFrom-Json).version + echo "::debug::version = $ver" + echo "::debug::SEM_VER_REGEX = $env:SEM_VER_REGEX" + if ($ver -notmatch $env:SEM_VER_REGEX) { + echo "::error::Bad version in code.json -- $ver (see https://semver.org/)" + exit 1 + } + if ($Matches["prerelease"] -and $Matches["prerelease"] -like "*runnumber*") { + $version = $Matches.0 -replace "runnumber", "${{github.run_number}}" + } + else { + $version = $Matches.0 + } + $name = "${{github.repository_owner}}" + $dist_dir = "mvmf6-${version}" + $user_dist_dir = "${name}-mvmf6-${version}" + # export + Write-Output "SEMVER=$version" >> $env:GITHUB_ENV + Write-Output "DIST_DIR=$dist_dir" >> $env:GITHUB_ENV + Write-Output "USER_DIST_DIR=$user_dist_dir" >> $env:GITHUB_ENV + + - name: Cache vtk + id: cache-vtk + uses: actions/cache@v2 + with: + path: C:\VTK-9.1.0-vs2019-x64 + key: windows-2019-vtk-${{hashFiles('misc/CMakePresets-vtk-9.1.0.json')}} + + - name: Download and install vtk + if: steps.cache-vtk.outputs.cache-hit != 'true' + shell: pwsh + run: | + $file = "vtk-9.1.0-vs2019-x64.7z" + curl -L -O "${{env.VTK_9_1_0_VS2019_X64_URL}}" + Get-FileHash $file + cd C:\ + 7z x ${{github.workspace}}\$file + rm ${{github.workspace}}\$file + + - name: Install htmlhelp + shell: pwsh + run: | + curl -L -O http://web.archive.org/web/20160201063255/http://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe + cmd /c start /wait .\htmlhelp.exe /q /c /t:$(Get-Location)\tmp + # These changes allow htmlhelp to be installed without user input + $file = "$(Get-Location)\tmp\htmlhelp.inf" + (Get-Content $file) | Foreach-Object { $_ ` + -replace '^BeginPrompt', ';;BeginPrompt' ` + -replace '^EndPrompt', ';;EndPrompt' ` + -replace '^49000=CustomLDID49000, 1', '49000=CustomLDID49000, 5' ` + -replace '^"hhupd.exe', ';;hhupd.exe' ` + -replace '^DefaultInstallDir="C:\\Program Files\\HTML Help Workshop"', 'DefaultInstallDir="%ProgramFiles%\\HTML Help Workshop"' + } | Set-Content $file + cmd /c start /wait .\tmp\setup.exe + Remove-Item -Recurse -Force .\tmp + Remove-Item -Recurse -Force .\htmlhelp.exe + Write-Output 'C:\Program Files (x86)\HTML Help Workshop' >> $env:GITHUB_PATH + + - name: Compile chm + shell: bash + run: | + pushd Help + # hhc returns 1 on success + set +e + hhc mvmf6.hhp | tee mvmf6.out + status=${PIPESTATUS[0]} + set -e + if [ "$status" -eq 1 ]; then + echo "[OK]" + exit 0 + else + echo "[FAILED]" + exit 1 + fi + popd + + - name: Export next mvmf6 version + if: ${{ false }} + shell: pwsh + run: | + # create headers dictionary + $h = @{"Authorization" = "token ${{secrets.GITHUB_TOKEN}}"} + + try { + $response = Invoke-WebRequest -Uri ${{env.RELEASES_URL}}/latest -Headers $h -Method GET + $json = $response.Content | ConvertFrom-Json + $tag_name = $json.tag_name + } + catch { + # none so far + $tag_name = "0.0" + } + + $next_version = "1.0.0" + if ($tag_name -match '(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:\.(?0|[1-9]\d*))?$') { + if ($Matches.ContainsKey('patch')) { + $patch = 1 + $Matches['patch'] + } + else { + $patch = 0 + } + $next_version = $Matches['major'] + "." + $Matches['minor'] + "." + $patch + } + + # major.minor.patch.build + $build = ${{github.run_number}} + $fullversion = "$next_version.$build" + $fullversion_commas = $fullversion.Replace(".", ",") + $date_compiled = "$((Get-Date -UFormat '%m/%d/%Y (compiled %b %d %Y %T)'))" + + # sed CMakeLists.txt + $file = ".\CMakeLists.txt" + (Get-Content $file) | Foreach-Object { + $_ -replace 'VERSION (?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:\.(?0|[1-9]\d*))', "VERSION $next_version" + } | Set-Content $file + + # sed ModelViewer.rc + $file = ".\ModelViewer\ModelViewer.rc" + (Get-Content $file) | Foreach-Object { + $_ -replace 'Version (?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:\.(?0|[1-9]\d*))', "Version $next_version"` + -replace 'FILEVERSION (?0|[1-9]\d*),(?0|[1-9]\d*),(?0|[1-9]\d*),(?0|[1-9]\d*)', "FILEVERSION $fullversion_commas"` + -replace 'PRODUCTVERSION (?0|[1-9]\d*),(?0|[1-9]\d*),(?0|[1-9]\d*),(?0|[1-9]\d*)', "PRODUCTVERSION $fullversion_commas"` + -replace 'VALUE "FileVersion", "(?0|[1-9]\d*)\.(?0|[1-9]\d)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)"', "VALUE ""FileVersion"", ""$fullversion"""` + -replace 'VALUE "ProductVersion", "(?0|[1-9]\d*)\.(?0|[1-9]\d)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)"', "VALUE ""ProductVersion"", ""$fullversion"""` + -replace '"(?[0-1][1-9])\/(?[0-3][1-9])\/(?\d{4}) \(.*\)"', """$date_compiled"""` + } | Set-Content $file + + # set env for remaining steps + if ($env:GITHUB_REPOSITORY -eq 'MODFLOW-USGS/modelviewer-mf6') { + Write-Output "DIST_DIR=mvmf6-$next_version" >> $env:GITHUB_ENV + } else { + Write-Output "DIST_DIR=mvmf6-$env:GITHUB_REPOSITORY_OWNER-$next_version" >> $env:GITHUB_ENV + } + Write-Output "NEXT_VERSION=$next_version" >> $env:GITHUB_ENV + + - name: Update About dialog version + shell: pwsh + run: | + # sed ModelViewer.rc + $file = ".\ModelViewer\ModelViewer.rc" + (Get-Content $file) | Foreach-Object { + $_ -replace "Version $env:SEM_VER_REGEX_2", "Version $env:SEMVER" + } | Set-Content $file + + - name: Update About dialog build date + shell: pwsh + run: | + # sed ModelViewer.rc + $date_compiled = "$((Get-Date -UFormat '%m/%d/%Y (compiled %b %d %Y %T)'))" + $file = ".\ModelViewer\ModelViewer.rc" + (Get-Content $file) | Foreach-Object { + $_ -replace '"(?[0-1][1-9])\/(?[0-3][1-9])\/(?\d{4}) \(.*\)"', """$date_compiled""" + } | Set-Content $file + + # @TODO Only on push to main on MODFLOW-USGS/modelviewer-mf6 + - name: Update About + if: ${{ false }} # skip for now + shell: pwsh + run: | + $prelim_pt1 = '"This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey \(USGS\).",.*$' + $prelim_pt2 = '"No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty.",.*$' + $prelim_pt3 = '"The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software.",.*$' + + $approved_pt1 = '"This software has been approved for release by the U.S. Geological Survey (USGS). Although the software has been subjected to rigorous review, the USGS reserves the right to update the software as needed pursuant to further analysis and review.",IDC_STATIC,15,110,189,40' + $approved_pt2 = '"No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty.",IDC_STATIC,15,152,190,34' + $approved_pt3 = '"Furthermore, the software is released on condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from its authorized or unauthorized use.",IDC_STATIC,15,187,190,26' + + # sed ModelViewer.rc + $file = ".\ModelViewer\ModelViewer.rc" + (Get-Content $file) | Foreach-Object { + $_ -replace $prelim_pt1, $approved_pt1` + -replace $prelim_pt2, $approved_pt2` + -replace $prelim_pt3, $approved_pt3` + } | Set-Content $file + + # @TODO Only on push to main on MODFLOW-USGS/modelviewer-mf6 + - name: Update README.md + if: ${{ false }} # skip for now + shell: pwsh + run: | + $approved = ("Disclaimer`n" + + "----------`n" + + "`n" + + "This software has been approved for release by the U.S. Geological Survey`n" + + "(USGS). Although the software has been subjected to rigorous review, the USGS`n" + + "reserves the right to update the software as needed pursuant to further analysis`n" + + "and review. No warranty, expressed or implied, is made by the USGS or the U.S.`n" + + "Government as to the functionality of the software and related material nor`n" + + "shall the fact of release constitute any such warranty. Furthermore, the`n" + + "software is released on condition that neither the USGS nor the U.S. Government`n" + + "shall be held liable for any damages resulting from its authorized or`n" + + "unauthorized use.") + $file = ".\README.md" + (Get-Content -Raw $file) -replace "(?ms)Disclaimer.*", $approved | Set-Content $file + + - name: Commit and push + # if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6' && github.ref_name == 'main' && github.ref_type == 'branch') + if: ${{ false }} # skip for now + uses: actions-js/push@master + with: + github_token: ${{secrets.GITHUB_TOKEN}} + branch: main + + - name: Commit and push branch + # if: (! (github.repository == 'MODFLOW-USGS/modelviewer-mf6') ) + if: ${{ false }} # skip for now + uses: actions-js/push@master + with: + github_token: ${{secrets.GITHUB_TOKEN}} + branch: __${{env.NEXT_VERSION}}.${{github.run_number}} + + - name: Configure + shell: pwsh + run: cmake --preset vtk-9.1.0-vs2019-x64 + + - name: Build + shell: pwsh + run: cmake --build --preset vtk-9.1.0-vs2019-x64 --config release + + - name: Install + if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') + shell: pwsh + run: cmake --install _vtk-9.1.0-vs2019-x64 --prefix ${{env.DIST_DIR}} --config release + + - name: Build mvmf6 zip + if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') + run: | + Copy-Item .\Help\mvmf6.chm ${{env.DIST_DIR}}\bin\. + 7z a -tzip ${{env.DIST_DIR}}.zip .\${{env.DIST_DIR}}\ + + - name: Upload artifact + if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') + uses: actions/upload-artifact@v3 + with: + name: dist-vtk-9.1 + path: ${{env.DIST_DIR}}.zip + + - name: Install (user) + if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + shell: pwsh + run: cmake --install _vtk-9.1.0-vs2019-x64 --prefix ${{env.USER_DIST_DIR}} --config release + + - name: Build mvmf6 zip (user) + if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + run: | + Copy-Item .\Help\mvmf6.chm ${{env.USER_DIST_DIR}}\bin\. + 7z a -tzip ${{env.USER_DIST_DIR}}.zip .\${{env.USER_DIST_DIR}}\ + + - name: Upload artifact (user) + if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') + uses: actions/upload-artifact@v3 + with: + name: dist-vtk-9.1 path: ${{env.USER_DIST_DIR}}.zip # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch diff --git a/CMakePresets.json b/CMakePresets.json index 48e9699..afa44fd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,8 +7,8 @@ }, "configurePresets": [ { - "name": "vs2019", - "displayName": "vs2019 x64 with vtk-6.3.0-vs2017 (builds in _vs2019)", + "name": "vtk-6.3.0-vs2017-x64", + "displayName": "vs2019 x64 with vtk-6.3.0-vs2017 (builds in _vtk-6.3.0-vs2017-x64)", "generator": "Visual Studio 16 2019", "architecture": "x64", "binaryDir": "${sourceDir}/_${presetName}", @@ -18,8 +18,8 @@ } }, { - "name": "vs2019_leaks", - "displayName": "vs2019 x64 with vtk-6.3.0-vs2017 (builds in _vs2019_leaks)", + "name": "vtk-6.3.0-leaks-vs2017-x64", + "displayName": "vs2019 x64 with vtk-6.3.0-vs2017 (builds in _vtk-6.3.0-leaks-vs2017-x64)", "generator": "Visual Studio 16 2019", "architecture": "x64", "binaryDir": "${sourceDir}/_${presetName}", @@ -56,12 +56,20 @@ , "buildPresets": [ { - "name": "vs2019", - "configurePreset": "vs2019" + "name": "vtk-6.3.0-vs2017-x64", + "configurePreset": "vtk-6.3.0-vs2017-x64" }, { - "name": "vs2019_leaks", - "configurePreset": "vs2019_leaks" + "name": "vtk-6.3.0-leaks-vs2017-x64", + "configurePreset": "vtk-6.3.0-leaks-vs2017-x64" + }, + { + "name": "vtk-9.1.0-vs2019-x64", + "configurePreset": "vtk-9.1.0-vs2019-x64" + }, + { + "name": "vtk-9.1.0-leaks-vs2019-x64", + "configurePreset": "vtk-9.1.0-leaks-vs2019-x64" } ], "vendor": { From 68b36fabe86c94523babcf878adbc1e60b1173f8 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 19 May 2022 11:50:19 -0600 Subject: [PATCH 37/51] fixed bad build names --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03e762f..e37e31b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ env: jobs: - build-6.3: + build-6_3: runs-on: windows-2019 steps: @@ -369,7 +369,7 @@ jobs: ################################################################################################### - build-9.1: + build-9_1: runs-on: windows-2019 steps: From ec349907a7f34c47475e55c5b75bed9b38ee4f1a Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 19 May 2022 12:33:54 -0600 Subject: [PATCH 38/51] Fixed zip inside zip artifacts --- .github/workflows/build.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e37e31b..c7ce0cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -268,36 +268,36 @@ jobs: shell: pwsh run: cmake --install _vtk-6.3.0-vs2017-x64 --prefix ${{env.DIST_DIR}} --config release - - name: Build mvmf6 zip + - name: Build mvmf6 if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') run: | Copy-Item .\Help\mvmf6.chm ${{env.DIST_DIR}}\bin\. - 7z a -tzip ${{env.DIST_DIR}}.zip .\${{env.DIST_DIR}}\ + # 7z a -tzip ${{env.DIST_DIR}}.zip .\${{env.DIST_DIR}}\ - name: Upload artifact if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: name: dist-vtk-6.3 - path: ${{env.DIST_DIR}}.zip + path: ${{env.DIST_DIR}} - name: Install (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') shell: pwsh run: cmake --install _vtk-6.3.0-vs2017-x64 --prefix ${{env.USER_DIST_DIR}} --config release - - name: Build mvmf6 zip (user) + - name: Build mvmf6 (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') run: | Copy-Item .\Help\mvmf6.chm ${{env.USER_DIST_DIR}}\bin\. - 7z a -tzip ${{env.USER_DIST_DIR}}.zip .\${{env.USER_DIST_DIR}}\ + # 7z a -tzip ${{env.USER_DIST_DIR}}.zip .\${{env.USER_DIST_DIR}}\ - name: Upload artifact (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: name: dist-vtk-6.3 - path: ${{env.USER_DIST_DIR}}.zip + path: ${{env.USER_DIST_DIR}} # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch - name: Create release @@ -605,36 +605,36 @@ jobs: shell: pwsh run: cmake --install _vtk-9.1.0-vs2019-x64 --prefix ${{env.DIST_DIR}} --config release - - name: Build mvmf6 zip + - name: Build mvmf6 if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') run: | Copy-Item .\Help\mvmf6.chm ${{env.DIST_DIR}}\bin\. - 7z a -tzip ${{env.DIST_DIR}}.zip .\${{env.DIST_DIR}}\ + # 7z a -tzip ${{env.DIST_DIR}}.zip .\${{env.DIST_DIR}}\ - name: Upload artifact if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: name: dist-vtk-9.1 - path: ${{env.DIST_DIR}}.zip + path: ${{env.DIST_DIR}} - name: Install (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') shell: pwsh run: cmake --install _vtk-9.1.0-vs2019-x64 --prefix ${{env.USER_DIST_DIR}} --config release - - name: Build mvmf6 zip (user) + - name: Build mvmf6 (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') run: | Copy-Item .\Help\mvmf6.chm ${{env.USER_DIST_DIR}}\bin\. - 7z a -tzip ${{env.USER_DIST_DIR}}.zip .\${{env.USER_DIST_DIR}}\ + # 7z a -tzip ${{env.USER_DIST_DIR}}.zip .\${{env.USER_DIST_DIR}}\ - name: Upload artifact (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: name: dist-vtk-9.1 - path: ${{env.USER_DIST_DIR}}.zip + path: ${{env.USER_DIST_DIR}} # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch - name: Create release From 399d404ba1b11160d74de4db4488dfb936c6f4d5 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 19 May 2022 13:17:47 -0600 Subject: [PATCH 39/51] updated name of artifacts --- .github/workflows/build.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7ce0cf..7e19de6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,6 +53,7 @@ jobs: } if ($Matches["prerelease"] -and $Matches["prerelease"] -like "*runnumber*") { $version = $Matches.0 -replace "runnumber", "${{github.run_number}}" + $version = $version -replace "prerelease.", "prerelease-vtk-6.3-" } else { $version = $Matches.0 @@ -278,8 +279,8 @@ jobs: if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: - name: dist-vtk-6.3 - path: ${{env.DIST_DIR}} + name: ${{env.DIST_DIR}} + path: ${{env.DIST_DIR}} - name: Install (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') @@ -296,7 +297,7 @@ jobs: if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: - name: dist-vtk-6.3 + name: ${{env.USER_DIST_DIR}} path: ${{env.USER_DIST_DIR}} # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch @@ -390,6 +391,7 @@ jobs: } if ($Matches["prerelease"] -and $Matches["prerelease"] -like "*runnumber*") { $version = $Matches.0 -replace "runnumber", "${{github.run_number}}" + $version = $version -replace "prerelease.", "prerelease-vtk-9.1-" } else { $version = $Matches.0 @@ -615,8 +617,8 @@ jobs: if: (github.repository == 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: - name: dist-vtk-9.1 - path: ${{env.DIST_DIR}} + name: ${{env.DIST_DIR}} + path: ${{env.DIST_DIR}} - name: Install (user) if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') @@ -633,7 +635,7 @@ jobs: if: (github.repository != 'MODFLOW-USGS/modelviewer-mf6') uses: actions/upload-artifact@v3 with: - name: dist-vtk-9.1 + name: ${{env.USER_DIST_DIR}} path: ${{env.USER_DIST_DIR}} # when on the MODFLOW-USGS/modelviewer-mf6 repo only release from the main branch From 435cf2bf2cbfc5ea24d217ea8f926af18a48e44e Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 19 May 2022 15:38:22 -0600 Subject: [PATCH 40/51] updated suffixes for leak versions --- CMakePresets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index afa44fd..15caa30 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -26,7 +26,7 @@ "cacheVariables": { "VTK_DIR" : "C:/VTK-6.3.0-leaks-vs2017-x64/lib/cmake/vtk-6.3", "MV_DEBUG_MEMORY_LEAKS": "ON", - "VTK_SUFFIX" : "-vtk-6.3" + "VTK_SUFFIX" : "-vtk-6.3-leaks" } }, { @@ -49,7 +49,7 @@ "cacheVariables": { "VTK_DIR" : "C:/VTK-9.1.0-leaks-vs2019-x64/lib/cmake/vtk-9.1", "MV_DEBUG_MEMORY_LEAKS": "ON", - "VTK_SUFFIX" : "-vtk-9.1" + "VTK_SUFFIX" : "-vtk-9.1-leaks" } } ] From 3de63160490e57edef1ca169e20478d4086f93fc Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 19 May 2022 15:40:00 -0600 Subject: [PATCH 41/51] fixed regexp replacement --- .github/workflows/build.yml | 2 +- misc/update-about-dialog-build-date.ps1 | 8 ++++++ misc/update-about-dialog-version.ps1 | 37 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 misc/update-about-dialog-build-date.ps1 create mode 100644 misc/update-about-dialog-version.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e19de6..de6432e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -186,7 +186,7 @@ jobs: # sed ModelViewer.rc $file = ".\ModelViewer\ModelViewer.rc" (Get-Content $file) | Foreach-Object { - $_ -replace "Version $env:SEM_VER_REGEX_2", "Version $env:SEMVER" + $_ -replace "`"Version $env:SEM_VER_REGEX_2`"", "`"Version $env:SEMVER`"" } | Set-Content $file - name: Update About dialog build date diff --git a/misc/update-about-dialog-build-date.ps1 b/misc/update-about-dialog-build-date.ps1 new file mode 100644 index 0000000..6701352 --- /dev/null +++ b/misc/update-about-dialog-build-date.ps1 @@ -0,0 +1,8 @@ +# Update About dialog build date (build.yml) + +# sed ModelViewer.rc +$date_compiled = "$((Get-Date -UFormat '%m/%d/%Y (compiled %b %d %Y %T)'))" +$file = "$PSScriptRoot\ModelViewer\ModelViewer.rc" +(Get-Content $file) | Foreach-Object { + $_ -replace '"(?[0-1][1-9])\/(?[0-3][1-9])\/(?\d{4}) \(.*\)"', """$date_compiled""" +} | Set-Content $file diff --git a/misc/update-about-dialog-version.ps1 b/misc/update-about-dialog-version.ps1 new file mode 100644 index 0000000..6b18dfb --- /dev/null +++ b/misc/update-about-dialog-version.ps1 @@ -0,0 +1,37 @@ +# Update About dialog version (build.yml) + +$env:SEM_VER_REGEX = "^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" +$env:SEM_VER_REGEX_2 = "(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?" + +${github.run_number} = "127" +${github.repository_owner} = $env:USERNAME + +${file.json} = "$PSScriptRoot\..\code.json" +$ver = ((Get-Content ${file.json}) | ConvertFrom-Json).version +##echo "::debug::version = $ver" +##echo "::debug::SEM_VER_REGEX = $env:SEM_VER_REGEX" +if ($ver -notmatch $env:SEM_VER_REGEX) { + echo "::error::Bad version in code.json -- $ver (see https://semver.org/)" + exit 1 +} +if ($Matches["prerelease"] -and $Matches["prerelease"] -like "*runnumber*") { + $version = $Matches.0 -replace "runnumber", "${github.run_number}" + $version = $version -replace "prerelease.", "prerelease-vtk-9.1-" +} +else { + $version = $Matches.0 +} +$name = "${github.repository_owner}" +$dist_dir = "mvmf6-${version}" +$user_dist_dir = "${name}-mvmf6-${version}" +# export +$env:SEMVER=$version +$env:DIST_DIR=$dist_dir +$env:USER_DIST_DIR=$user_dist_dir + + +# sed ModelViewer.rc +${file.rc} = "$PSScriptRoot\..\ModelViewer\ModelViewer.rc" +(Get-Content ${file.rc}) | Foreach-Object { + $_ -replace "`"Version $env:SEM_VER_REGEX_2`"", "`"Version $env:SEMVER`"" +} | Set-Content ${file.rc} From d1663e49afb2aad505bfe449eae714f7306e9e07 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 19 May 2022 15:44:14 -0600 Subject: [PATCH 42/51] resized captions in about dialog --- ModelViewer/ModelViewer.rc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ModelViewer/ModelViewer.rc b/ModelViewer/ModelViewer.rc index 73bf670..c2bcb64 100644 --- a/ModelViewer/ModelViewer.rc +++ b/ModelViewer/ModelViewer.rc @@ -768,9 +768,9 @@ FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN DEFPUSHBUTTON "OK",IDOK,161,7,50,14,WS_GROUP ICON IDR_MAINFRAME,IDC_STATIC,7,7,20,20 - LTEXT "Model Viewer for Modflow 6",IDC_MV_VERSION,45,7,107,10,SS_NOPREFIX - LTEXT "Version 1.1.0-prerelease.1",IDC_STATIC,45,20,107,10 - LTEXT "05/04/2022 (compiled May 04 2022 16:35:19)",IDC_MV_RELEASE,45,33,166,8 + LTEXT "Model Viewer for Modflow 6",IDC_MV_VERSION,42,7,107,10,SS_NOPREFIX + LTEXT "Version 1.1.0-prerelease.1",IDC_STATIC,42,20,166,10 + LTEXT "05/04/2022 (compiled May 04 2022 16:35:19)",IDC_MV_RELEASE,42,33,166,8 GROUPBOX "Notice",IDC_STATIC,7,47,204,49 LTEXT "This software uses the Visualization Toolkit (vtk), written and copyrighted by Ken Martin, Will Schroeder and Bill Lorensen. The authors of vtk have granted permission to use, copy, and distribute vtk while retaining their copyright. ",IDC_STATIC,15,59,191,34 GROUPBOX "Disclaimer",IDC_STATIC,7,98,204,119 From 5bd613abd2a403e059897edce8fc5dc40279eabc Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Fri, 20 May 2022 14:36:30 -0600 Subject: [PATCH 43/51] updated preliminary text layout in about dialog --- ModelViewer/ModelViewer.rc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ModelViewer/ModelViewer.rc b/ModelViewer/ModelViewer.rc index c2bcb64..0815c93 100644 --- a/ModelViewer/ModelViewer.rc +++ b/ModelViewer/ModelViewer.rc @@ -774,9 +774,9 @@ BEGIN GROUPBOX "Notice",IDC_STATIC,7,47,204,49 LTEXT "This software uses the Visualization Toolkit (vtk), written and copyrighted by Ken Martin, Will Schroeder and Bill Lorensen. The authors of vtk have granted permission to use, copy, and distribute vtk while retaining their copyright. ",IDC_STATIC,15,59,191,34 GROUPBOX "Disclaimer",IDC_STATIC,7,98,204,119 - LTEXT "This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey (USGS).",IDC_STATIC,15,110,189,34 - LTEXT "No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty.",IDC_STATIC,15,148,190,34 - LTEXT "The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software.",IDC_STATIC,15,187,190,26 + LTEXT "This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey (USGS).",IDC_STATIC,15,107,189,34 + LTEXT "No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty.",IDC_STATIC,15,142,190,34 + LTEXT "The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software.",IDC_STATIC,15,177,190,32 GROUPBOX "Credits",IDC_STATIC,7,220,204,42 LTEXT "Model Viewer for Modflow 6 was developed by\nPaul A. Hsieh (pahsieh@usgs.gov) and \nScott Charlton (charlton@usgs.gov)",IDC_STATIC,15,231,189,25 END From 595b0995f16ae1f34420cd82d3a8111de68f94b9 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 26 May 2022 07:59:37 -0600 Subject: [PATCH 44/51] Modified and added some error handling --- ModelViewer/MvDoc.cpp | 7 +++---- mv/mvManager.cpp | 29 ++++++++++++++++++++--------- mv/mvManager.h | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ModelViewer/MvDoc.cpp b/ModelViewer/MvDoc.cpp index 35adcc1..ac667c3 100644 --- a/ModelViewer/MvDoc.cpp +++ b/ModelViewer/MvDoc.cpp @@ -243,12 +243,11 @@ BOOL CMvDoc::OnOpenDocument(LPCTSTR lpszPathName) mvGUISettings *gui = new mvGUISettings; // Deserialization is done by the visualization pipeline manager - char errorMsg[100]; - errorMsg[0] = '\0'; + std::string errorMsg; m_Manager->Deserialize(lpszPathName, gui, errorMsg); - if (strlen(errorMsg) > 0) + if (errorMsg.size()) { - AfxMessageBox(errorMsg); + AfxMessageBox(errorMsg.c_str()); delete gui; return FALSE; } diff --git a/mv/mvManager.cpp b/mv/mvManager.cpp index 3ee2629..fcad29d 100644 --- a/mv/mvManager.cpp +++ b/mv/mvManager.cpp @@ -61,6 +61,8 @@ #include "mvDefine.h" +#include + using std::log; using std::ofstream; using std::pow; @@ -5124,19 +5126,18 @@ char *mvManager::Serialize(const char *fileName, mvGUISettings *gui) const } // Read parameters from file -void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *errorMsg) +void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, std::string &errorMsg) { int i, ivalue, i1, i2, i3, i4, i5, i6, i7, i8, i9; double fvalue, f1, f2, f3, f4, f5, f6; char key[100], buffer[1024]; - errorMsg[0] = '\0'; // Open an input stream ifstream in(fileName, std::ifstream::in); if (!in.is_open()) { - strcpy(errorMsg, "Unable to open the Model Viewer file."); + errorMsg = "Unable to open the Model Viewer file."; return; } @@ -5169,7 +5170,7 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro if (strcmp(buffer, "Model Viewer") != 0) { delete hashTable; - strcpy(errorMsg, "This file does not contain data for Model Viewer"); + errorMsg = "This file does not contain data for Model Viewer"; return; } buffer[0] = '\0'; @@ -5177,7 +5178,9 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro if (strcmp(buffer, MV_VERSION) != 0) { delete hashTable; - sprintf(errorMsg, "This file does not contain data for Model Viewer version %s", MV_VERSION); + std::ostringstream oss; + oss << "This file does not contain data for Model Viewer version " << MV_VERSION; + errorMsg = oss.str(); return; } @@ -5190,7 +5193,7 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro if (ncode == 0) { delete hashTable; - strcpy(errorMsg, "The Model Viewer file is damaged and cannot be loaded."); + errorMsg = "The Model Viewer file is damaged and cannot be loaded."; return; } @@ -5208,7 +5211,7 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro { delete hashTable; delete[] dataFileList; - strcpy(errorMsg, "The Model Viewer file is damaged and cannot be loaded."); + errorMsg = "The Model Viewer file is damaged and cannot be loaded."; return; } if (strlen(buffer)) @@ -5216,7 +5219,15 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro strcpy(szDest, dirname.c_str()); VERIFY(PathAppend(szDest, buffer)); VERIFY(PathCanonicalize(fullpath, szDest)); - VERIFY(PathFileExists(fullpath)); + if (!PathFileExists(fullpath)) + { + delete hashTable; + delete[] dataFileList; + std::ostringstream oss; + oss << "Unable to open \"" << fullpath << "\"."; + errorMsg = oss.str(); + return; + } strcat(dataFileList, fullpath); } else @@ -5234,7 +5245,7 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, char *erro if (err != 0) { delete hashTable; - strcpy(errorMsg, err); + errorMsg = err; return; } diff --git a/mv/mvManager.h b/mv/mvManager.h index 31f4fc0..1322c53 100644 --- a/mv/mvManager.h +++ b/mv/mvManager.h @@ -381,7 +381,7 @@ class MV_EXPORT mvManager // Serialization char *Serialize(const char *fileName, mvGUISettings *gui) const; - void Deserialize(const char *fileName, mvGUISettings *gui, char *errorMsg); + void Deserialize(const char *fileName, mvGUISettings *gui, std::string &errorMsg); protected: int m_ActivatedGridLinesVisibility; From ac4e2295d048c76d5a0de41820c59b400fd1e160 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 1 Jun 2022 19:14:53 -0600 Subject: [PATCH 45/51] added assertion --- ModelViewer/AnimationControlsPage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ModelViewer/AnimationControlsPage.cpp b/ModelViewer/AnimationControlsPage.cpp index e06e5f0..20f7ed5 100644 --- a/ModelViewer/AnimationControlsPage.cpp +++ b/ModelViewer/AnimationControlsPage.cpp @@ -164,6 +164,7 @@ void CAnimationControlsPage::OnSetToTimePoint() void CAnimationControlsPage::SetAndDisplayCurrentTime(int timePointIndex) { + assert(m_TimePointLabels != nullptr); m_CurrentTimePointIndex = timePointIndex; GetDlgItem(IDC_CURRENT_TIME)->SetWindowText(m_TimePointLabels[timePointIndex]); } From f1701c93b34590a0f8b37f67e648cc10fd5c5641 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 1 Jun 2022 19:15:46 -0600 Subject: [PATCH 46/51] added some wait cursor feedback --- ModelViewer/MvDoc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ModelViewer/MvDoc.cpp b/ModelViewer/MvDoc.cpp index ac667c3..8cb2655 100644 --- a/ModelViewer/MvDoc.cpp +++ b/ModelViewer/MvDoc.cpp @@ -543,8 +543,10 @@ void CMvDoc::OnLoadData() } // Load data + BeginWaitCursor(); char *errorMsg = m_Manager->LoadData(selectedModel, dataFileList); delete[] dataFileList; + EndWaitCursor(); // Check for error in reading data files if (errorMsg != 0) @@ -562,6 +564,8 @@ void CMvDoc::OnLoadData() dlg2.m_TimeLabelOption = m_Manager->GetTimeLabelOption(); dlg2.m_InitialDisplayTimePoint = m_Manager->GetInitialDisplayTimePoint(); dlg2.DoModal(); // Cancel not allowed. + + BeginWaitCursor(); m_Manager->SetTimePointTo(dlg2.m_SelectedTimePoint); m_Manager->SetScalarDataTypeTo(dlg2.m_SelectedDataType); @@ -596,6 +600,7 @@ void CMvDoc::OnLoadData() // Redraw the view; UpdateAllViews(NULL); + EndWaitCursor(); } void CMvDoc::OnUpdateFileSave(CCmdUI *pCmdUI) From 2e9926a21cf636cedfe8d2f920e40de7c8b24787 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 1 Jun 2022 19:16:44 -0600 Subject: [PATCH 47/51] modfied to compile with vtk 7.1 --- ModelViewer/MvView.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ModelViewer/MvView.cpp b/ModelViewer/MvView.cpp index 339c4b5..32329aa 100644 --- a/ModelViewer/MvView.cpp +++ b/ModelViewer/MvView.cpp @@ -825,6 +825,21 @@ void CMvView::WriteBmp(const char *filename, BOOL useScreenResolution) file->write((char *)m_MFCWindow->GetRenderWindow()->GetMemoryData(), dataWidth * height); #else { +#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION == 1)) + // vtkRenderLargeImage + m_MFCWindow->GetRenderWindow()->SetSize(width, height); + + //vtkNew renderLarge; + vtkSmartPointer renderLarge = vtkSmartPointer::New(); + renderLarge->SetInput(m_Renderer); + renderLarge->SetMagnification(1); + + //vtkNew bmpWriter; + vtkSmartPointer bmpWriter = vtkSmartPointer::New(); + bmpWriter->SetFileName(filename); + bmpWriter->SetInputConnection(renderLarge->GetOutputPort()); + bmpWriter->Write(); +#else // vtkRenderLargeImage m_MFCWindow->GetRenderWindow()->SetSize(width, height); @@ -836,6 +851,7 @@ void CMvView::WriteBmp(const char *filename, BOOL useScreenResolution) bmpWriter->SetFileName(filename); bmpWriter->SetInputConnection(renderLarge->GetOutputPort()); bmpWriter->Write(); +#endif } #endif if (magnification != 1) From dd2340aa2e8d0fada6e85f00d218d3e4fbc8802e Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Wed, 1 Jun 2022 19:25:37 -0600 Subject: [PATCH 48/51] Closes MODFLOW-USGS#48 --- mv/mvColorTable.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mv/mvColorTable.cpp b/mv/mvColorTable.cpp index dd045e1..b6fd5f6 100644 --- a/mv/mvColorTable.cpp +++ b/mv/mvColorTable.cpp @@ -152,6 +152,9 @@ void mvColorTable::Build() c_rgba[3] = static_cast(rgba[3] * 255.0f + 0.5f); } } +#if ((VTK_MAJOR_VERSION == 7) && (VTK_MINOR_VERSION >= 1)) || (VTK_MAJOR_VERSION > 7) + this->BuildSpecialColors(); +#endif this->BuildTime.Modified(); } } From 822714112a6f1216b9b804826d052ebbd478e81d Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 2 Jun 2022 13:46:22 -0600 Subject: [PATCH 49/51] added include for assert --- ModelViewer/AnimationControlsPage.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ModelViewer/AnimationControlsPage.cpp b/ModelViewer/AnimationControlsPage.cpp index 20f7ed5..118fea2 100644 --- a/ModelViewer/AnimationControlsPage.cpp +++ b/ModelViewer/AnimationControlsPage.cpp @@ -6,6 +6,8 @@ #include "AnimationOptionsPage.h" #include "MvDoc.h" +#include + #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE From 2ccb223a8a7c58979d19b32f9095f91659c48a87 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 2 Jun 2022 13:49:11 -0600 Subject: [PATCH 50/51] set _WIN32_WINNT to Windows 7 --- ModelViewer/CMakeLists.txt | 1 + mv/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/ModelViewer/CMakeLists.txt b/ModelViewer/CMakeLists.txt index 00ec80a..03960f1 100644 --- a/ModelViewer/CMakeLists.txt +++ b/ModelViewer/CMakeLists.txt @@ -176,6 +176,7 @@ target_compile_definitions(ModelViewer PRIVATE $<$:_DEBUG>) # @TODO clean this up target_compile_definitions(ModelViewer PRIVATE MV_USE_VTKMFCWINDOW) +target_compile_definitions(ModelViewer PRIVATE _WIN32_WINNT=_WIN32_WINNT_WIN7) if (MV_DEBUG_MEMORY_LEAKS) # set for all configs diff --git a/mv/CMakeLists.txt b/mv/CMakeLists.txt index db3c6db..5002e0b 100644 --- a/mv/CMakeLists.txt +++ b/mv/CMakeLists.txt @@ -76,6 +76,7 @@ target_compile_definitions(mv PRIVATE $<$:_DEBUG>) # @TODO clean this up target_compile_definitions(mv PRIVATE MV_USE_VTKMFCWINDOW) +target_compile_definitions(mv PRIVATE _WIN32_WINNT=_WIN32_WINNT_WIN7) if (MV_DEBUG_MEMORY_LEAKS) # set for all configs From 70ada41e19f8b9bf6034025ccf9363431f07373f Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Thu, 2 Jun 2022 16:57:10 -0600 Subject: [PATCH 51/51] added notebooks to determine req'd vtk dlls --- .gitattributes | 3 +- misc/vtk-6.3.0-vs2017-x64.ipynb | 145 +++++++++++++++++++++++++++ misc/vtk-9.1.0-vs2019-x64.ipynb | 167 ++++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+), 1 deletion(-) create mode 100644 misc/vtk-6.3.0-vs2017-x64.ipynb create mode 100644 misc/vtk-9.1.0-vs2019-x64.ipynb diff --git a/.gitattributes b/.gitattributes index 991959d..1348d69 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ -misc/0001-update-for-memory-leaks.patch text eol=lf \ No newline at end of file +misc/0001-update-for-memory-leaks.patch text eol=lf +*.ipynb text eol=lf diff --git a/misc/vtk-6.3.0-vs2017-x64.ipynb b/misc/vtk-6.3.0-vs2017-x64.ipynb new file mode 100644 index 0000000..5d31480 --- /dev/null +++ b/misc/vtk-6.3.0-vs2017-x64.ipynb @@ -0,0 +1,145 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "9b752108", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "# check for vtk\n", + "find_package(VTK REQUIRED)\n", + "if (${VTK_VERSION} VERSION_EQUAL \"6.3\")\n", + " find_package(VTK\n", + " COMPONENTS\n", + " vtkalglib\n", + " vtkCommonColor\n", + " vtkCommonComputationalGeometry\n", + " vtkCommonCore\n", + " vtkCommonDataModel\n", + " vtkCommonExecutionModel\n", + " vtkCommonMath\n", + " vtkCommonMisc\n", + " vtkCommonSystem\n", + " vtkCommonTransforms\n", + " vtkDICOMParser\n", + " vtkFiltersCore\n", + " vtkFiltersExtraction\n", + " vtkFiltersGeneral\n", + " vtkFiltersGeometry\n", + " vtkFiltersModeling\n", + " vtkFiltersSources\n", + " vtkFiltersStatistics\n", + " vtkfreetype\n", + " vtkftgl\n", + " vtkGUISupportMFC\n", + " vtkImagingCore\n", + " vtkImagingFourier\n", + " vtkImagingHybrid\n", + " vtkInteractionStyle\n", + " vtkIOImage\n", + " vtkjpeg\n", + " vtkmetaio\n", + " vtkpng\n", + " vtkRenderingCore\n", + " vtkRenderingFreeType\n", + " vtkRenderingLOD\n", + " vtkRenderingOpenGL\n", + " vtksys\n", + " vtktiff\n", + " vtkzlib\n", + " REQUIRED\n", + " )\n", + "endif()\n" + ] + } + ], + "source": [ + "# checked with http://pep8online.com/checkresult\n", + "# cmake --preset vtk-6.3.0-vs2017-x64\n", + "#\n", + "import subprocess\n", + "import re\n", + "import os\n", + "\n", + "DUMPBIN = (os.environ['VS2019INSTALLDIR'] +\n", + " '\\\\VC\\\\Tools\\\\MSVC\\\\14.29.30133\\\\bin\\\\HostX86\\\\x86\\\\dumpbin.exe')\n", + "MVMF6_EXE = '..\\\\_vtk-6.3.0-vs2017-x64\\\\ModelViewer\\\\Release\\\\mvmf6.exe'\n", + "MV_DLL = '..\\\\_vtk-6.3.0-vs2017-x64\\\\ModelViewer\\\\Release\\\\mv.dll'\n", + "VTK_BIN = 'C:\\\\VTK-6.3.0-vs2017-x64\\\\bin'\n", + "DLL_RE = re.compile('[ ].*vtk.*-6.3.dll')\n", + "\n", + "\n", + "def depends(dll_dict, exe_or_dll):\n", + " if exe_or_dll in dll_dict and dll_dict[exe_or_dll]:\n", + " return dll_dict\n", + " dll_dict[exe_or_dll] = True\n", + " # print(f\"dumpbin /IMPORTS {exe_or_dll}\")\n", + " command = [DUMPBIN, '/IMPORTS', exe_or_dll]\n", + " result = subprocess.run(command, stdout=subprocess.PIPE)\n", + " for line in result.stdout.decode().split('\\r\\n'):\n", + " if DLL_RE.match(line):\n", + " dll = line.strip()\n", + " dll = f\"{VTK_BIN}\\\\{dll}\"\n", + " if dll not in dll_dict:\n", + " dll_dict[dll] = False\n", + " for x in dll_dict:\n", + " if not dll_dict[x]:\n", + " return depends(dll_dict, x)\n", + " return dll_dict\n", + "\n", + "dlls = depends(dict(), MV_DLL)\n", + "dlls = depends(dlls, MVMF6_EXE)\n", + "\n", + "dlls.pop(MV_DLL)\n", + "dlls.pop(MVMF6_EXE)\n", + "\n", + "split_re = re.compile('.*(vtk.*)-6.3.dll')\n", + "\n", + "print('# check for vtk')\n", + "print('find_package(VTK REQUIRED)')\n", + "print('if (${VTK_VERSION} VERSION_EQUAL \"6.3\")')\n", + "print(\" find_package(VTK\")\n", + "print(\" COMPONENTS\")\n", + "for k in sorted(dlls.keys(), key=str.lower):\n", + " m = split_re.match(k)\n", + " print(f\" {m.group(1)}\")\n", + "print(\" REQUIRED\")\n", + "print(\" )\")\n", + "print(\"endif()\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "13c7630c", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/misc/vtk-9.1.0-vs2019-x64.ipynb b/misc/vtk-9.1.0-vs2019-x64.ipynb new file mode 100644 index 0000000..b0e408b --- /dev/null +++ b/misc/vtk-9.1.0-vs2019-x64.ipynb @@ -0,0 +1,167 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "f3ee8cf0", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "# check for vtk\n", + "find_package(VTK REQUIRED)\n", + "if (${VTK_VERSION} VERSION_EQUAL \"9.1\")\n", + " find_package(VTK\n", + " COMPONENTS\n", + " CommonColor\n", + " CommonComputationalGeometry\n", + " CommonCore\n", + " CommonDataModel\n", + " CommonExecutionModel\n", + " CommonMath\n", + " CommonMisc\n", + " CommonSystem\n", + " CommonTransforms\n", + " DICOMParser\n", + " doubleconversion\n", + " expat\n", + " FiltersCore\n", + " FiltersExtraction\n", + " FiltersGeneral\n", + " FiltersGeometry\n", + " FiltersHybrid\n", + " FiltersModeling\n", + " FiltersSources\n", + " FiltersStatistics\n", + " fmt\n", + " freetype\n", + " glew\n", + " GUISupportMFC\n", + " ImagingCore\n", + " ImagingSources\n", + " InteractionStyle\n", + " IOCore\n", + " IOImage\n", + " IOLegacy\n", + " IOXML\n", + " IOXMLParser\n", + " jpeg\n", + " kissfft\n", + " loguru\n", + " lz4\n", + " lzma\n", + " metaio\n", + " ParallelCore\n", + " ParallelDIY\n", + " png\n", + " pugixml\n", + " RenderingCore\n", + " RenderingFreeType\n", + " RenderingLOD\n", + " RenderingOpenGL2\n", + " RenderingUI\n", + " sys\n", + " tiff\n", + " zlib\n", + " REQUIRED\n", + " )\n", + "endif()\n" + ] + } + ], + "source": [ + "# checked with http://pep8online.com/checkresult\n", + "# cmake --preset vtk-9.1.0-vs2019-x64\n", + "#\n", + "import subprocess\n", + "import re\n", + "import os\n", + "\n", + "DUMPBIN = (os.environ['VS2019INSTALLDIR'] +\n", + " '\\\\VC\\\\Tools\\\\MSVC\\\\14.29.30133\\\\bin\\\\HostX86\\\\x86\\\\dumpbin.exe')\n", + "MVMF6_EXE = '..\\\\_vtk-9.1.0-vs2019-x64\\\\ModelViewer\\\\Release\\\\mvmf6.exe'\n", + "MV_DLL = '..\\\\_vtk-9.1.0-vs2019-x64\\\\ModelViewer\\\\Release\\\\mv.dll'\n", + "VTK_BIN = 'C:\\\\VTK-9.1.0-vs2019-x64\\\\bin'\n", + "DLL_RE = re.compile('[ ].*vtk.*-9.1.dll')\n", + "\n", + "\n", + "def depends(dll_dict, exe_or_dll):\n", + " if exe_or_dll in dll_dict and dll_dict[exe_or_dll]:\n", + " return dll_dict\n", + " dll_dict[exe_or_dll] = True\n", + " # print(f\"dumpbin /IMPORTS {exe_or_dll}\")\n", + " command = [DUMPBIN, '/IMPORTS', exe_or_dll]\n", + " result = subprocess.run(command, stdout=subprocess.PIPE)\n", + " for line in result.stdout.decode().split('\\r\\n'):\n", + " if DLL_RE.match(line):\n", + " dll = line.strip()\n", + " dll = f\"{VTK_BIN}\\\\{dll}\"\n", + " if dll not in dll_dict:\n", + " dll_dict[dll] = False\n", + " for x in dll_dict:\n", + " if not dll_dict[x]:\n", + " return depends(dll_dict, x)\n", + " return dll_dict\n", + "\n", + "dlls = depends(dict(), MV_DLL)\n", + "dlls = depends(dlls, MVMF6_EXE)\n", + "\n", + "dlls.pop(MV_DLL)\n", + "dlls.pop(MVMF6_EXE)\n", + "\n", + "split_re = re.compile('.*vtk(.*)-9.1.dll')\n", + "\n", + "print('# check for vtk')\n", + "print('find_package(VTK REQUIRED)')\n", + "print('if (${VTK_VERSION} VERSION_EQUAL \"9.1\")')\n", + "print(\" find_package(VTK\")\n", + "print(\" COMPONENTS\")\n", + "for k in sorted(dlls.keys(), key=str.lower):\n", + " m = split_re.match(k)\n", + " print(f\" {m.group(1)}\")\n", + "print(\" REQUIRED\")\n", + "print(\" )\")\n", + "print(\"endif()\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a9376e15", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a729c2b0", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}