Skip to content

Commit

Permalink
Merge branch 'qt_before_splash' into v14
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenHilferink committed Sep 26, 2023
2 parents c6ab2c0 + 12ed0f1 commit f8d30f4
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 82 deletions.
7 changes: 6 additions & 1 deletion qtgui/exe/src/DmsDetailPages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions qtgui/exe/src/DmsDetailPages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 22 additions & 4 deletions qtgui/exe/src/DmsEventLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -486,13 +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->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);





}
Expand All @@ -517,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);
Expand All @@ -541,9 +556,12 @@ auto createEventLog(MainWindow* dms_main_window) -> std::unique_ptr<DmsEventLog>
dms_main_window->m_eventlog_model = std::make_unique<EventLogModel>();
auto dms_eventlog_pointer = std::make_unique<DmsEventLog>(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;
Expand Down
1 change: 1 addition & 0 deletions qtgui/exe/src/DmsEventLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class DmsEventLog : public QWidget
std::unique_ptr<QPushButton> 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:
Expand Down
37 changes: 19 additions & 18 deletions qtgui/exe/src/DmsMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ MainWindow::MainWindow(CmdLineSetttings& cmdLineSettings)

updateCaption();
setUnifiedTitleAndToolBarOnMac(true);

scheduleUpdateToolbar();

LoadColors();

resizeDocksToNaturalSize();
}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -926,10 +926,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);
Expand Down Expand Up @@ -1473,7 +1472,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);
Expand Down Expand Up @@ -1627,6 +1625,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<MainWindow*>(clientHandle);
Expand Down Expand Up @@ -2310,7 +2320,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);
Expand All @@ -2321,6 +2331,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);

Expand All @@ -2334,13 +2345,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->resize(500, 0);
m_value_info_dock->resize(500, 0);
m_value_info_mdi_area->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

m_value_info_dock->setWidget(m_value_info_mdi_area);
m_value_info_dock->setVisible(true);
addDockWidget(Qt::RightDockWidgetArea, m_value_info_dock);
Expand All @@ -2349,19 +2356,13 @@ void MainWindow::createValueInfoDock()
void MainWindow::createDmsHelperWindowDocks()
{
createValueInfoDock();

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()
Expand Down
1 change: 1 addition & 0 deletions qtgui/exe/src/DmsMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions qtgui/exe/src/DmsTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,16 @@ bool DmsTreeView::expandRecursiveFromCurrentItem()
return true;
}

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)
{
Expand Down
3 changes: 3 additions & 0 deletions qtgui/exe/src/DmsTreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class DmsTreeView : public QTreeView
void setNewCurrentItem(TreeItem* new_current_item);
bool expandActiveNode(bool doExpand);
bool expandRecursiveFromCurrentItem();
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
int m_default_size = 200;

private slots:
void onDoubleClick(const QModelIndex& index);
Expand Down
15 changes: 13 additions & 2 deletions qtgui/exe/src/DmsValueInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +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->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);
}

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)
Expand Down
2 changes: 2 additions & 0 deletions qtgui/exe/src/DmsValueInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class ValueInfoPanel : public QMdiSubWindow
public:
ValueInfoPanel(QWidget* parent);
~ValueInfoPanel();
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
};

struct ValueInfoBrowser : QUpdatableTextBrowser
Expand Down
48 changes: 14 additions & 34 deletions stg/dll/src/gdal/gdal_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand All @@ -304,7 +304,7 @@ void GDALDatasetHandle::UpdateBaseProjection(const AbstrUnit* uBase) const
std::optional<OGRSpatialReference> 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)
Expand Down Expand Up @@ -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()
);
}
}

Expand All @@ -408,33 +402,19 @@ auto ConvertProjectionStrToAuthorityIdentifierAndCode(const std::string projecti
return {};
}

void CheckSpatialReference(std::optional<OGRSpatialReference>& ogrSR, const AbstrUnit* uBase)
void CheckSpatialReference(std::optional<OGRSpatialReference>& 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)
{
Expand All @@ -444,7 +424,7 @@ void CheckSpatialReference(std::optional<OGRSpatialReference>& ogrSR, const Abst
if (ogrSR)
{
ValidateSpatialReferenceFromWkt(&spOrErr.first, wktPrjStr.c_str());
CheckCompatibility(&*ogrSR, &spOrErr.first);
CheckCompatibility(treeitem, &*ogrSR, &spOrErr.first);
}
else
ogrSR = spOrErr.first;
Expand Down
4 changes: 2 additions & 2 deletions stg/dll/src/gdal/gdal_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ auto GetGeometryTypeFromGeometryDataItem(const TreeItem* subItem) -> OGRwkbGeome
auto GetAsWkt(const OGRSpatialReference* sr) -> SharedStr;
auto GetAffineTransformationFromDataItem(const TreeItem* storageHolder) -> std::vector<double>;
auto GetOGRSpatialReferenceFromDataItems(const TreeItem* storageHolder) -> std::optional<OGRSpatialReference>;
void CheckSpatialReference(std::optional<OGRSpatialReference>& ogrSR, const AbstrUnit* mutBase);
void CheckSpatialReference(std::optional<OGRSpatialReference>& 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);

Expand All @@ -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_;
};
Expand Down
Loading

0 comments on commit f8d30f4

Please sign in to comment.