From 9046a98aa2f082128c44c4b5f27f417351c83da4 Mon Sep 17 00:00:00 2001 From: eoudejans Date: Mon, 25 Sep 2023 13:27:02 +0200 Subject: [PATCH 1/5] Spatial reference check rework which followed from issue #524. - Simplified logic in GdalGridSM::DoUpdateTree. - Rework of CheckCompatibility(srs* A, srs* B) to use gdal IsSame method. - Added item context to spatial reference check failure message. --- stg/dll/src/gdal/gdal_base.cpp | 44 ++++++++++------------------------ stg/dll/src/gdal/gdal_base.h | 4 ++-- stg/dll/src/gdal/gdal_grid.cpp | 32 ++++++++++--------------- 3 files changed, 27 insertions(+), 53 deletions(-) diff --git a/stg/dll/src/gdal/gdal_base.cpp b/stg/dll/src/gdal/gdal_base.cpp index f30f4b585..1ae1b7bf9 100644 --- a/stg/dll/src/gdal/gdal_base.cpp +++ b/stg/dll/src/gdal/gdal_base.cpp @@ -280,7 +280,7 @@ void ValidateSpatialReferenceFromWkt(OGRSpatialReference* ogrSR, CharPtr wkt_prj reportF(SeverityTypeID::ST_MinorTrace, "PROJ reinterpreted user input wkt projection definition: %s", wkt_prj_str); } -void GDALDatasetHandle::UpdateBaseProjection(const AbstrUnit* uBase) const +void GDALDatasetHandle::UpdateBaseProjection(const TreeItem* treeitem, const AbstrUnit* uBase) const { assert(uBase); assert(dsh_); @@ -381,25 +381,19 @@ SharedStr GetWktProjectionFromValuesUnit(const AbstrDataItem* adi) return GetWktProjectionFromBaseProjectionUnit(baseProjectionUnit); } -/* REMOVE -void sr_releaser::operator ()(OGRSpatialReference* p) const -{ - OSRRelease(p); -} -*/ - -void CheckCompatibility(OGRSpatialReference* fromGDAL, OGRSpatialReference* fromConfig) +void CheckCompatibility(const TreeItem* treeitem, OGRSpatialReference* fromGDAL, OGRSpatialReference* fromConfig) { assert(fromGDAL); assert(fromConfig); - if (GetAsWkt(fromGDAL) != GetAsWkt(fromConfig)) + if (!fromGDAL->IsSame(fromConfig)) { - /*reportF(SeverityTypeID::ST_Warning, "GDAL: SpatialReferenceSystem that GDAL obtained from Dataset differs from baseProjectionUnit's SpatialReference." - "\nDataset's SpatialReference:\n%s" - "\nbaseProjectionUnit's SpatialReference:\n%s" - , GetAsWkt(fromGDAL).c_str() - , GetAsWkt(fromConfig).c_str() - );*/ // TODO: make this message more specific and user readable, for instance refer to dataset and epsg code it encompasses. + SharedStr authority_code_from_gdal = SharedStr(fromGDAL->GetAuthorityName(NULL)) + ":" + fromGDAL->GetAuthorityCode(NULL); + SharedStr authority_code_from_value_unit = SharedStr(fromConfig->GetAuthorityName(NULL)) + ":" + fromConfig->GetAuthorityCode(NULL);; + reportF(SeverityTypeID::ST_Warning, "GDAL: item %s spatial reference (%s) differs from the spatial reference (%s) GDAL obtained from dataset" + , treeitem->GetFullName().c_str() + , authority_code_from_gdal.c_str() + , authority_code_from_value_unit.c_str() + ); } } @@ -408,33 +402,19 @@ auto ConvertProjectionStrToAuthorityIdentifierAndCode(const std::string projecti return {}; } -void CheckSpatialReference(std::optional& ogrSR, const AbstrUnit* uBase) +void CheckSpatialReference(std::optional& ogrSR, const TreeItem* treeitem, const AbstrUnit* uBase) { if (!ogrSR) // dataset spatial reference does not exist, no check possible. return; - // TODO: check of the sr provider code matches the geodms projection assert(IsMainThread()); assert(uBase); auto projection = uBase->GetProjectionStr(FormattingFlags::None); SharedStr wktPrjStr(uBase->GetSpatialReference()); - - /*if (!projection.empty()) - { - auto authority_identifier_and_code = ConvertProjectionStrToAuthorityIdentifierAndCode(projection.c_str()); - auto srs = GetSpatialReferenceFromUserInput(authority_identifier_and_code); - srs.first.IsSame(ogrSR.value()); - }*/ - - if (wktPrjStr.empty()) - { - //TODO: reconsider implementation of this error message, message is unclear as of now. - //auto fullName = SharedStr(uBase->GetFullName()); - //reportF(SeverityTypeID::ST_Warning, "BaseProjection %s has no projection", fullName); return; - } + auto spOrErr = GetSpatialReferenceFromUserInput(wktPrjStr); if (spOrErr.second != OGRERR_NONE) { diff --git a/stg/dll/src/gdal/gdal_base.h b/stg/dll/src/gdal/gdal_base.h index 3b1fe4203..4a85578f0 100644 --- a/stg/dll/src/gdal/gdal_base.h +++ b/stg/dll/src/gdal/gdal_base.h @@ -180,7 +180,7 @@ auto GetGeometryTypeFromGeometryDataItem(const TreeItem* subItem) -> OGRwkbGeome auto GetAsWkt(const OGRSpatialReference* sr) -> SharedStr; auto GetAffineTransformationFromDataItem(const TreeItem* storageHolder) -> std::vector; auto GetOGRSpatialReferenceFromDataItems(const TreeItem* storageHolder) -> std::optional; -void CheckSpatialReference(std::optional& ogrSR, const AbstrUnit* mutBase); +void CheckSpatialReference(std::optional& ogrSR, const TreeItem* treeitem, const AbstrUnit* mutBase); STGDLL_CALL auto GetUnitSizeInMeters(const AbstrUnit* projectionBaseUnit) -> Float64; STGDLL_CALL void ValidateSpatialReferenceFromWkt(OGRSpatialReference* ogrSR, CharPtr wkt_prj_str); @@ -205,7 +205,7 @@ struct GDALDatasetHandle }; }; - void UpdateBaseProjection(const AbstrUnit* uBase) const; + void UpdateBaseProjection(const TreeItem* treeitem, const AbstrUnit* uBase) const; std::unique_ptr < GDALDataset, deleter > dsh_; }; diff --git a/stg/dll/src/gdal/gdal_grid.cpp b/stg/dll/src/gdal/gdal_grid.cpp index f83c42b01..38eb57c4b 100644 --- a/stg/dll/src/gdal/gdal_grid.cpp +++ b/stg/dll/src/gdal/gdal_grid.cpp @@ -516,29 +516,23 @@ void GdalGridSM::DoUpdateTree(const TreeItem* storageHolder, TreeItem* curr, Syn StorageReadHandle storageHandle(this, storageHolder, curr, StorageAction::updatetree); - if (uBase) + if (uBase && IsOpen() && m_hDS->GetRasterCount()) { - if (IsOpen()) - { - if (m_hDS->GetRasterCount()) - { - try { - GDAL_ErrorFrame frame; - gdal_transform gdalTr; - m_hDS->GetGeoTransform(gdalTr); + try { + GDAL_ErrorFrame frame; + gdal_transform gdalTr; + m_hDS->GetGeoTransform(gdalTr); - gridDataDomain->SetProjection(new UnitProjection(uBase, GetTransformation(gdalTr))); + gridDataDomain->SetProjection(new UnitProjection(uBase, GetTransformation(gdalTr))); - // spatial ref info - m_hDS.UpdateBaseProjection(uBase); + // spatial ref info + m_hDS.UpdateBaseProjection(curr, uBase); - frame.ThrowUpWhateverCameUp(); - } - catch (...) - { - gridDataDomain->CatchFail(FR_MetaInfo); - } - } + frame.ThrowUpWhateverCameUp(); + } + catch (...) + { + gridDataDomain->CatchFail(FR_MetaInfo); } } From 15d70301c6254c4d5a49b24be28e8c6015bce915 Mon Sep 17 00:00:00 2001 From: eoudejans Date: Mon, 25 Sep 2023 14:12:45 +0200 Subject: [PATCH 2/5] Supplemental implementation/fix for issue #524. --- stg/dll/src/gdal/gdal_base.cpp | 4 ++-- stg/dll/src/gdal/gdal_vect.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/stg/dll/src/gdal/gdal_base.cpp b/stg/dll/src/gdal/gdal_base.cpp index 1ae1b7bf9..d0904cea7 100644 --- a/stg/dll/src/gdal/gdal_base.cpp +++ b/stg/dll/src/gdal/gdal_base.cpp @@ -304,7 +304,7 @@ void GDALDatasetHandle::UpdateBaseProjection(const TreeItem* treeitem, const Abs std::optional ogrSR; if (ogrSR_ptr) ogrSR = *ogrSR_ptr; // make a copy if necessary as UpdateBaseProjection may return another one that must be destructed - CheckSpatialReference(ogrSR, uBase); // update based on this external ogrSR, but use base's Format-specified EPGS when available + CheckSpatialReference(ogrSR, treeitem, uBase); // update based on this external ogrSR, but use base's Format-specified EPGS when available } SharedStr GetAsWkt(const OGRSpatialReference* sr) @@ -424,7 +424,7 @@ void CheckSpatialReference(std::optional& ogrSR, const Tree if (ogrSR) { ValidateSpatialReferenceFromWkt(&spOrErr.first, wktPrjStr.c_str()); - CheckCompatibility(&*ogrSR, &spOrErr.first); + CheckCompatibility(treeitem, &*ogrSR, &spOrErr.first); } else ogrSR = spOrErr.first; diff --git a/stg/dll/src/gdal/gdal_vect.cpp b/stg/dll/src/gdal/gdal_vect.cpp index 433748220..595f7839e 100644 --- a/stg/dll/src/gdal/gdal_vect.cpp +++ b/stg/dll/src/gdal/gdal_vect.cpp @@ -1557,14 +1557,16 @@ bool IsVatDomain(const AbstrUnit* au) #include "Unit.h" #include "UnitClass.h" -void UpdateSpatialRef(const GDALDatasetHandle& hDS, AbstrDataItem* geometry, std::optional& spatialRef) +void UpdateSpatialRef(const GDALDatasetHandle& hDS, TreeItem* geometry_item, std::optional& spatialRef) { + AbstrDataItem* geometry = AsDynamicDataItem(geometry_item); + if (!spatialRef) return; assert(geometry); auto gvu = GetBaseProjectionUnitFromValuesUnit(geometry); - CheckSpatialReference(spatialRef, const_cast(gvu)); + CheckSpatialReference(spatialRef, geometry_item, const_cast(gvu)); auto wkt = GetAsWkt(&*spatialRef); if (!wkt.empty()) @@ -1589,7 +1591,8 @@ void GdalVectSM::DoUpdateTable(const TreeItem* storageHolder, AbstrUnit* layerDo if (!(layer->GetGeomType() == OGRwkbGeometryType::wkbNone)) { - AbstrDataItem* geometry = AsDynamicDataItem(layerDomain->GetSubTreeItemByID(token::geometry)); + auto geometry_item = layerDomain->GetSubTreeItemByID(token::geometry); + AbstrDataItem* geometry = AsDynamicDataItem(geometry_item); if (geometry) { ValueComposition configured_vc = geometry->GetValueComposition(); @@ -1616,7 +1619,7 @@ void GdalVectSM::DoUpdateTable(const TreeItem* storageHolder, AbstrUnit* layerDo std::optional ogrSR; if (ogrSR_ptr) ogrSR = *ogrSR_ptr; - UpdateSpatialRef(m_hDS, geometry, ogrSR); + UpdateSpatialRef(m_hDS, geometry_item, ogrSR); } } From 08f2032e2062b1963ab57ab463cfc50c5dac3360 Mon Sep 17 00:00:00 2001 From: eoudejans Date: Mon, 25 Sep 2023 15:01:25 +0200 Subject: [PATCH 3/5] Supplemental fix for spatial reference compatibility check. Geometry_item in gdal.vect UpdateMetaInfo could be null --- stg/dll/src/gdal/gdal_vect.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stg/dll/src/gdal/gdal_vect.cpp b/stg/dll/src/gdal/gdal_vect.cpp index 595f7839e..63ebbe1ef 100644 --- a/stg/dll/src/gdal/gdal_vect.cpp +++ b/stg/dll/src/gdal/gdal_vect.cpp @@ -1557,16 +1557,14 @@ bool IsVatDomain(const AbstrUnit* au) #include "Unit.h" #include "UnitClass.h" -void UpdateSpatialRef(const GDALDatasetHandle& hDS, TreeItem* geometry_item, std::optional& spatialRef) +void UpdateSpatialRef(const GDALDatasetHandle& hDS, AbstrDataItem* geometry, std::optional& spatialRef) { - AbstrDataItem* geometry = AsDynamicDataItem(geometry_item); - if (!spatialRef) return; assert(geometry); auto gvu = GetBaseProjectionUnitFromValuesUnit(geometry); - CheckSpatialReference(spatialRef, geometry_item, const_cast(gvu)); + CheckSpatialReference(spatialRef, geometry, const_cast(gvu)); auto wkt = GetAsWkt(&*spatialRef); if (!wkt.empty()) @@ -1619,7 +1617,7 @@ void GdalVectSM::DoUpdateTable(const TreeItem* storageHolder, AbstrUnit* layerDo std::optional ogrSR; if (ogrSR_ptr) ogrSR = *ogrSR_ptr; - UpdateSpatialRef(m_hDS, geometry_item, ogrSR); + UpdateSpatialRef(m_hDS, geometry, ogrSR); } } From 074574a95e990aec229f7c5a847c319996d517fe Mon Sep 17 00:00:00 2001 From: eoudejans Date: Tue, 26 Sep 2023 11:51:21 +0200 Subject: [PATCH 4/5] Added sizehint to DmsTreeView for default width of 300 logical pixels. Reverted detail pages widget size policy to expanding, expanding to be more in line and less interfering with other docks. See issue #521. --- qtgui/exe/src/DmsEventLog.cpp | 3 ++- qtgui/exe/src/DmsMainWindow.cpp | 31 +++++++++++++++++++------------ qtgui/exe/src/DmsMainWindow.h | 1 + qtgui/exe/src/DmsTreeView.cpp | 5 +++++ qtgui/exe/src/DmsTreeView.h | 2 ++ qtgui/exe/src/DmsValueInfo.cpp | 3 ++- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/qtgui/exe/src/DmsEventLog.cpp b/qtgui/exe/src/DmsEventLog.cpp index 684ff3174..ee756db53 100644 --- a/qtgui/exe/src/DmsEventLog.cpp +++ b/qtgui/exe/src/DmsEventLog.cpp @@ -492,7 +492,8 @@ void DmsEventLog::toggleFilter(bool toggled) if (toggled) default_height = current_height; else - main_window->resizeDocks({ main_window->m_eventlog_dock }, { default_height }, Qt::Vertical); + main_window->resizeDocksToNaturalSize(); + //main_window->resizeDocks({ main_window->m_eventlog_dock }, { default_height }, Qt::Vertical); } diff --git a/qtgui/exe/src/DmsMainWindow.cpp b/qtgui/exe/src/DmsMainWindow.cpp index c11fd5fe1..9dae7469d 100644 --- a/qtgui/exe/src/DmsMainWindow.cpp +++ b/qtgui/exe/src/DmsMainWindow.cpp @@ -233,10 +233,10 @@ MainWindow::MainWindow(CmdLineSetttings& cmdLineSettings) updateCaption(); setUnifiedTitleAndToolBarOnMac(true); - scheduleUpdateToolbar(); - LoadColors(); + + resizeDocksToNaturalSize(); } MainWindow::~MainWindow() @@ -908,10 +908,9 @@ bool MainWindow::event(QEvent* event) if (event->type() == QEvent::WindowStateChange && windowState() == Qt::WindowState::WindowMaximized) { int default_treeview_treshold = 100; - int default_treeview_width = 200; auto curr_treeview_dock_width = m_treeview_dock->width(); if (curr_treeview_dock_width < default_treeview_treshold) - resizeDocks({ m_treeview_dock }, { default_treeview_width }, Qt::Horizontal); + resizeDocksToNaturalSize(); } return QMainWindow::event(event); @@ -1609,6 +1608,18 @@ void MainWindow::addRecentFilesMenu(std::string_view recent_file) // TODO: renam connect(new_recent_file_entry, &DmsRecentFileEntry::toggled, new_recent_file_entry, &DmsRecentFileEntry::onFileEntryPressed); } +void MainWindow::resizeDocksToNaturalSize() +{ + //int default_treeview_width = 500; + //int default_detail_pages_width = 500; + //int default_value_info_width = 500; + //int default_eventlog_height = 600; + //resizeDocks({ m_treeview_dock, m_detailpages_dock, m_value_info_dock }, { default_treeview_width, default_detail_pages_width, default_value_info_width }, Qt::Horizontal); + + //resizeDocks({ m_treeview_dock}, { default_treeview_width}, Qt::Horizontal); + //resizeDocks({ m_eventlog_dock }, { default_eventlog_height }, Qt::Vertical); +} + void AnyTreeItemStateHasChanged(ClientHandle clientHandle, const TreeItem* self, NotificationCode notificationCode) { auto mainWindow = reinterpret_cast(clientHandle); @@ -2320,9 +2331,10 @@ void MainWindow::createValueInfoDock() //m_value_info_dock->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); m_value_info_mdi_area = new QDmsMdiArea(m_value_info_dock); - m_value_info_mdi_area->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); - m_value_info_mdi_area->resize(500, 0); - m_value_info_dock->resize(500, 0); + //m_value_info_mdi_area->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); + m_value_info_mdi_area->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + //m_value_info_mdi_area->resize(500, 0); + //m_value_info_dock->resize(500, 0); m_value_info_dock->setWidget(m_value_info_mdi_area); m_value_info_dock->setVisible(true); addDockWidget(Qt::RightDockWidgetArea, m_value_info_dock); @@ -2334,16 +2346,11 @@ void MainWindow::createDmsHelperWindowDocks() createDetailPagesDock(); -// m_detail_pages->setDummyText(); - m_treeview = createTreeview(this); m_eventlog = createEventLog(this); auto sz_test1 = m_value_info_dock->minimumSize(); auto sz_test2 = m_value_info_mdi_area->minimumSize(); - // connections below need constructed treeview and filters to work - // TODO: refactor action/pushbutton logic - } void MainWindow::back() diff --git a/qtgui/exe/src/DmsMainWindow.h b/qtgui/exe/src/DmsMainWindow.h index a685b97ed..5370d5937 100644 --- a/qtgui/exe/src/DmsMainWindow.h +++ b/qtgui/exe/src/DmsMainWindow.h @@ -206,6 +206,7 @@ class MainWindow : public QMainWindow auto getIconFromViewstyle(ViewStyle vs) -> QIcon; void hideDetailPagesRadioButtonWidgets(bool hide_properties_buttons, bool hide_source_descr_buttons); void addRecentFilesMenu(std::string_view recent_file); + void resizeDocksToNaturalSize(); static auto TheOne() -> MainWindow*; static bool IsExisting(); diff --git a/qtgui/exe/src/DmsTreeView.cpp b/qtgui/exe/src/DmsTreeView.cpp index 4bd117e7c..a014a11c3 100644 --- a/qtgui/exe/src/DmsTreeView.cpp +++ b/qtgui/exe/src/DmsTreeView.cpp @@ -478,6 +478,11 @@ bool DmsTreeView::expandRecursiveFromCurrentItem() return true; } +QSize DmsTreeView::sizeHint() const +{ + return QSize(m_default_size, 0); +} + DmsTreeView::DmsTreeView(QWidget* parent) : QTreeView(parent) { diff --git a/qtgui/exe/src/DmsTreeView.h b/qtgui/exe/src/DmsTreeView.h index d8d5dedad..64dcda11d 100644 --- a/qtgui/exe/src/DmsTreeView.h +++ b/qtgui/exe/src/DmsTreeView.h @@ -84,6 +84,8 @@ class DmsTreeView : public QTreeView void setNewCurrentItem(TreeItem* new_current_item); bool expandActiveNode(bool doExpand); bool expandRecursiveFromCurrentItem(); + QSize sizeHint() const override; + int m_default_size = 300; private slots: void onDoubleClick(const QModelIndex& index); diff --git a/qtgui/exe/src/DmsValueInfo.cpp b/qtgui/exe/src/DmsValueInfo.cpp index 299aafdfb..9f60d6690 100644 --- a/qtgui/exe/src/DmsValueInfo.cpp +++ b/qtgui/exe/src/DmsValueInfo.cpp @@ -29,7 +29,8 @@ ValueInfoPanel::~ValueInfoPanel() main_window->m_value_info_dock->setVisible(false); main_window->m_detailpages_dock->setVisible(true); } - main_window->resizeDocks({main_window->m_detailpages_dock}, {500, 0}, Qt::Horizontal); + main_window->resizeDocksToNaturalSize(); + //main_window->resizeDocks({main_window->m_detailpages_dock}, {500, 0}, Qt::Horizontal); } From 12ed0f127cdce25c5086782909a276f57b5d8b3f Mon Sep 17 00:00:00 2001 From: eoudejans Date: Tue, 26 Sep 2023 13:53:53 +0200 Subject: [PATCH 5/5] Summary: rework of docking window sizes and resizing. - Closing the last value info panel will now properly resize the detail pages to its original intended size of 500 logical pixels. - Removed unnecessary borders in detailpages and eventlog. - Eventlog filter will now resize up and down the eventlog height by 150 logical pixels in order to make the eventlog filter fit properly. See issue: #521 --- qtgui/exe/src/DmsDetailPages.cpp | 7 ++++++- qtgui/exe/src/DmsDetailPages.h | 2 ++ qtgui/exe/src/DmsEventLog.cpp | 27 ++++++++++++++++++++++----- qtgui/exe/src/DmsEventLog.h | 1 + qtgui/exe/src/DmsMainWindow.cpp | 12 +++--------- qtgui/exe/src/DmsTreeView.cpp | 5 +++++ qtgui/exe/src/DmsTreeView.h | 3 ++- qtgui/exe/src/DmsValueInfo.cpp | 12 +++++++++++- qtgui/exe/src/DmsValueInfo.h | 2 ++ 9 files changed, 54 insertions(+), 17 deletions(-) diff --git a/qtgui/exe/src/DmsDetailPages.cpp b/qtgui/exe/src/DmsDetailPages.cpp index c0463749a..0c7351b62 100644 --- a/qtgui/exe/src/DmsDetailPages.cpp +++ b/qtgui/exe/src/DmsDetailPages.cpp @@ -452,7 +452,12 @@ DmsDetailPages::DmsDetailPages(QWidget* parent) QSize DmsDetailPages::sizeHint() const { - return QSize(500, 0); + return QSize(m_default_width, 0); +} + +QSize DmsDetailPages::minimumSizeHint() const +{ + return QSize(m_default_width, 0); } void DmsDetailPages::resizeEvent(QResizeEvent* event) diff --git a/qtgui/exe/src/DmsDetailPages.h b/qtgui/exe/src/DmsDetailPages.h index 37b1dc3ce..ed6b12a42 100644 --- a/qtgui/exe/src/DmsDetailPages.h +++ b/qtgui/exe/src/DmsDetailPages.h @@ -25,10 +25,12 @@ class DmsDetailPages : public QTextBrowser public: DmsDetailPages(QWidget* parent = nullptr); QSize sizeHint() const override; + QSize minimumSizeHint() const override; void connectDetailPagesAnchorClicked(); ActiveDetailPage m_active_detail_page = ActiveDetailPage::GENERAL; ActiveDetailPage m_last_active_detail_page = ActiveDetailPage::GENERAL; + int m_default_width = 500; public slots: void show(ActiveDetailPage new_active_detail_page); diff --git a/qtgui/exe/src/DmsEventLog.cpp b/qtgui/exe/src/DmsEventLog.cpp index ee756db53..14ecd9ec8 100644 --- a/qtgui/exe/src/DmsEventLog.cpp +++ b/qtgui/exe/src/DmsEventLog.cpp @@ -383,6 +383,7 @@ DmsEventLog::DmsEventLog(QWidget* parent) grid_layout->addWidget(m_log.get(), 0, 0); grid_layout->addLayout(eventlog_toolbar, 0, 1); vertical_layout->addLayout(grid_layout); + vertical_layout->setContentsMargins(0, 0, 0, 0); setLayout(vertical_layout); toggleFilter(false); } @@ -486,14 +487,22 @@ void DmsEventLog::scrollToBottomThrottled() void DmsEventLog::toggleFilter(bool toggled) { auto main_window = MainWindow::TheOne(); - m_eventlog_filter->setVisible(toggled); auto current_height = height(); if (toggled) - default_height = current_height; + default_height = current_height + 150; else - main_window->resizeDocksToNaturalSize(); - //main_window->resizeDocks({ main_window->m_eventlog_dock }, { default_height }, Qt::Vertical); + { + default_height = current_height - 150; + //main_window->resizeDocksToNaturalSize(); + + } + main_window->resizeDocks({ main_window->m_eventlog_dock }, { default_height }, Qt::Vertical); + + m_eventlog_filter->setVisible(toggled); + + + } @@ -518,6 +527,11 @@ void DmsEventLog::clearTextFilter() MainWindow::TheOne()->m_eventlog_model->refilter(); } +QSize DmsEventLog::sizeHint() const +{ + return QSize(0, default_height); +} + void geoDMSMessage(ClientHandle /*clientHandle*/, const MsgData* msgData) { assert(msgData); @@ -542,9 +556,12 @@ auto createEventLog(MainWindow* dms_main_window) -> std::unique_ptr dms_main_window->m_eventlog_model = std::make_unique(); auto dms_eventlog_pointer = std::make_unique(MainWindow::TheOne()->m_eventlog_dock); + dms_eventlog_pointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + MainWindow::TheOne()->m_eventlog_dock->setWidget(dms_eventlog_pointer.get()); MainWindow::TheOne()->m_eventlog_dock->setTitleBarWidget(new QWidget(MainWindow::TheOne()->m_eventlog_dock)); - dms_main_window->addDockWidget(Qt::BottomDockWidgetArea, MainWindow::TheOne()->m_eventlog_dock);; + + dms_main_window->addDockWidget(Qt::BottomDockWidgetArea, MainWindow::TheOne()->m_eventlog_dock); dms_eventlog_pointer->m_log->setModel(dms_main_window->m_eventlog_model.get()); return dms_eventlog_pointer; diff --git a/qtgui/exe/src/DmsEventLog.h b/qtgui/exe/src/DmsEventLog.h index fb5fb3e6d..b52512a00 100644 --- a/qtgui/exe/src/DmsEventLog.h +++ b/qtgui/exe/src/DmsEventLog.h @@ -73,6 +73,7 @@ class DmsEventLog : public QWidget std::unique_ptr m_copy_selected_to_clipboard, m_scroll_to_bottom_toggle, m_event_filter_toggle, m_clear; bool m_scroll_to_bottom = true; bool m_text_filter_active = false; + QSize sizeHint() const override; public slots: diff --git a/qtgui/exe/src/DmsMainWindow.cpp b/qtgui/exe/src/DmsMainWindow.cpp index 9dae7469d..b2d65e944 100644 --- a/qtgui/exe/src/DmsMainWindow.cpp +++ b/qtgui/exe/src/DmsMainWindow.cpp @@ -1454,7 +1454,6 @@ void MainWindow::showStatisticsDirectly(const TreeItem* tiContext) void MainWindow::showValueInfo(const AbstrDataItem* studyObject, SizeT index) { assert(studyObject); - auto* mdiSubWindow = new ValueInfoPanel(m_value_info_mdi_area.get()); auto* textWidget = new ValueInfoBrowser(mdiSubWindow, studyObject, index); @@ -2303,7 +2302,7 @@ void MainWindow::createDetailPagesDock() m_detail_pages = new DmsDetailPages(m_detailpages_dock); m_detail_pages->connectDetailPagesAnchorClicked(); - m_detail_pages->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); + m_detail_pages->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); vertical_layout->addWidget(m_detail_page_properties_buttons->gridLayoutWidget); vertical_layout->addWidget(m_detail_page_source_description_buttons->gridLayoutWidget); @@ -2314,6 +2313,7 @@ void MainWindow::createDetailPagesDock() hideDetailPagesRadioButtonWidgets(true, true); vertical_layout->addWidget(m_detail_pages.get()); + vertical_layout->setContentsMargins(0, 0, 0, 0); detail_pages_holder->setLayout(vertical_layout); m_detailpages_dock->setWidget(detail_pages_holder); @@ -2327,14 +2327,9 @@ void MainWindow::createValueInfoDock() { m_value_info_dock = new QDockWidget(QObject::tr("Value Info"), this); m_value_info_dock->setTitleBarWidget(new QWidget(m_value_info_dock)); - //m_value_info_dock->setMinimumWidth(0); - - //m_value_info_dock->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); m_value_info_mdi_area = new QDmsMdiArea(m_value_info_dock); - //m_value_info_mdi_area->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); m_value_info_mdi_area->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - //m_value_info_mdi_area->resize(500, 0); - //m_value_info_dock->resize(500, 0); + m_value_info_dock->setWidget(m_value_info_mdi_area); m_value_info_dock->setVisible(true); addDockWidget(Qt::RightDockWidgetArea, m_value_info_dock); @@ -2343,7 +2338,6 @@ void MainWindow::createValueInfoDock() void MainWindow::createDmsHelperWindowDocks() { createValueInfoDock(); - createDetailPagesDock(); m_treeview = createTreeview(this); diff --git a/qtgui/exe/src/DmsTreeView.cpp b/qtgui/exe/src/DmsTreeView.cpp index a014a11c3..ba05a7b31 100644 --- a/qtgui/exe/src/DmsTreeView.cpp +++ b/qtgui/exe/src/DmsTreeView.cpp @@ -483,6 +483,11 @@ QSize DmsTreeView::sizeHint() const return QSize(m_default_size, 0); } +QSize DmsTreeView::minimumSizeHint() const +{ + return QSize(m_default_size, 0); +} + DmsTreeView::DmsTreeView(QWidget* parent) : QTreeView(parent) { diff --git a/qtgui/exe/src/DmsTreeView.h b/qtgui/exe/src/DmsTreeView.h index 64dcda11d..cd4ff55c0 100644 --- a/qtgui/exe/src/DmsTreeView.h +++ b/qtgui/exe/src/DmsTreeView.h @@ -85,7 +85,8 @@ class DmsTreeView : public QTreeView bool expandActiveNode(bool doExpand); bool expandRecursiveFromCurrentItem(); QSize sizeHint() const override; - int m_default_size = 300; + QSize minimumSizeHint() const override; + int m_default_size = 200; private slots: void onDoubleClick(const QModelIndex& index); diff --git a/qtgui/exe/src/DmsValueInfo.cpp b/qtgui/exe/src/DmsValueInfo.cpp index 9f60d6690..ddd54b3cb 100644 --- a/qtgui/exe/src/DmsValueInfo.cpp +++ b/qtgui/exe/src/DmsValueInfo.cpp @@ -27,12 +27,22 @@ ValueInfoPanel::~ValueInfoPanel() if (!active_subwindow) { main_window->m_value_info_dock->setVisible(false); - main_window->m_detailpages_dock->setVisible(true); + main_window->resizeDocks({ main_window->m_detailpages_dock }, { main_window->m_detail_pages->m_default_width}, Qt::Horizontal); + //main_window->m_detailpages_dock->setVisible(true); } main_window->resizeDocksToNaturalSize(); //main_window->resizeDocks({main_window->m_detailpages_dock}, {500, 0}, Qt::Horizontal); } +QSize ValueInfoPanel::sizeHint() const +{ + return QSize(500,0); +} + +QSize ValueInfoPanel::minimumSizeHint() const +{ + return QSize(500, 0); +} ValueInfoBrowser::ValueInfoBrowser(QWidget* parent, SharedDataItemInterestPtr studyObject, SizeT index) : QUpdatableTextBrowser(parent) diff --git a/qtgui/exe/src/DmsValueInfo.h b/qtgui/exe/src/DmsValueInfo.h index 6cc37e27b..c70abb77c 100644 --- a/qtgui/exe/src/DmsValueInfo.h +++ b/qtgui/exe/src/DmsValueInfo.h @@ -18,6 +18,8 @@ class ValueInfoPanel : public QMdiSubWindow public: ValueInfoPanel(QWidget* parent); ~ValueInfoPanel(); + QSize sizeHint() const override; + QSize minimumSizeHint() const override; }; struct ValueInfoBrowser : QUpdatableTextBrowser