Commit 309a4aa7 authored by LE BRETON Come's avatar LE BRETON Come

First attempt to use dtk-widgets linking onto dtk-themes

parent 6dd8a558
......@@ -84,6 +84,7 @@ include_directories(${Qt5Multimedia_PRIVATE_INCLUDE_DIRS})
find_package(dtkCore 2.3.0 REQUIRED)
find_package(dtkFonts 2.0.0 REQUIRED)
find_package(dtkWidgets 2.7.0 REQUIRED)
find_package(dtkThemes 2.0.0 REQUIRED)
find_package(dtkLog 2.1.0 REQUIRED)
if(WIN32)
......@@ -103,6 +104,7 @@ include(${VTK_USE_FILE})
include_directories(${dtkCore_INCLUDE_DIRS})
include_directories(${dtkLog_INCLUDE_DIRS})
include_directories(${dtkFonts_INCLUDE_DIRS})
include_directories(${dtkThemes_INCLUDE_DIRS})
include_directories(${dtkWidgets_INCLUDE_DIRS})
## #################################################################
......
......@@ -13,7 +13,6 @@
// Code:
#include "dtkVisualizationViewer.h"
#include "dtkVisualizationViewerSidePane.h"
#include "dtkVisualizationViewerStack.h"
#include <dtkCore>
......@@ -53,59 +52,52 @@ QString dtkReadFile(const QString& path);
class dtkVisualizationViewerPrivate
{
public:
dtkVisualizationViewerSidePane *side = nullptr;
dtkVisualizationViewerStack *stack = nullptr;
public:
dtkWidgetsOverlayRope *rope = nullptr;
public:
QWidget *source = nullptr;
QWidget *target = nullptr;
};
// ///////////////////////////////////////////////////////////////////
// dtkVisualizationViewer
// ///////////////////////////////////////////////////////////////////
dtkVisualizationViewer::dtkVisualizationViewer(QWidget *parent) : QMainWindow(parent)
dtkVisualizationViewer::dtkVisualizationViewer(QWidget *parent) : dtkWidgetsMainWindow(parent)
{
d = new dtkVisualizationViewerPrivate;
QWidget *widget = new QWidget(this);
d->stack = new dtkVisualizationViewerStack(this);
d->side = new dtkVisualizationViewerSidePane(this);
connect(d->side, SIGNAL(currentIndex(int)), d->stack, SLOT(setCurrentIndex(int)));
// connect(d->side, SIGNAL(currentIndex(int)), d->stack, SLOT(setCurrentIndex(int)));
QHBoxLayout *layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *layout = new QHBoxLayout(widget);
layout->setContentsMargins(this->menubar()->width(), 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(d->side);
// layout->addWidget(this->menubar());
layout->addWidget(d->stack);
QWidget *widget = new QWidget(this);
widget->setLayout(layout);
// this->restackMenu(d->stack);
this->menubar()->build();
d->rope = new dtkWidgetsOverlayRope(widget);
d->rope->setVisible(false);
// dtkWidgetsMenu *menu_file = new dtkWidgetsMenu(fa::circlethin, "File");
connect(d->rope, SIGNAL(source(QWidget *)), this, SLOT(setRopeSource(QWidget *)));
connect(d->rope, SIGNAL(target(QWidget *)), this, SLOT(setRopeTarget(QWidget *)));
// this->menubar()->addMenu(menu_file);
QMenu *file_menu = this->menuBar()->addMenu("File");
// this->menubar()->build();
// QMenu *file_menu = this->menuBar()->addMenu("File");
connect(file_menu->addAction("Import"), SIGNAL(triggered()), this, SLOT(importDataSet()));
// connect(file_menu->addAction("Import"), SIGNAL(triggered()), this, SLOT(importDataSet()));
QMenu *layout_menu = this->menuBar()->addMenu("Layout");
// QMenu *layout_menu = this->menuBar()->addMenu("Layout");
layout_menu->addAction("Show linking overlay", d->rope, SLOT(toggle()), Qt::Key_Space);
// layout_menu->addAction("Show linking overlay", d->rope, SLOT(toggle()), Qt::Key_Space);
QMenu *window_menu = this->menuBar()->addMenu("Window");
// QMenu *window_menu = this->menuBar()->addMenu("Window");
connect(window_menu->addAction("Hide"), SIGNAL(triggered()), this, SLOT(hide()));
connect(window_menu->addAction("Show"), SIGNAL(triggered()), this, SLOT(show()));
window_menu->addSeparator();
connect(window_menu->addAction("Toggle side pane"), SIGNAL(triggered()), d->side, SLOT(toggle()));
// connect(window_menu->addAction("Hide"), SIGNAL(triggered()), this, SLOT(hide()));
// connect(window_menu->addAction("Show"), SIGNAL(triggered()), this, SLOT(show()));
// window_menu->addSeparator();
// connect(window_menu->addAction("Toggle side pane"), SIGNAL(triggered()), d->side, SLOT(toggle()));
this->setAttribute(Qt::WA_DeleteOnClose);
this->setCentralWidget(widget);
......@@ -173,24 +165,6 @@ void dtkVisualizationViewer::importDataSet(const QString& path)
decorator_scalar_color_map->render();
}
void dtkVisualizationViewer::setRopeSource(QWidget *source)
{
d->source = source;
}
void dtkVisualizationViewer::setRopeTarget(QWidget *target)
{
d->target = target;
if(dtkVisualizationView3D *target_view = dynamic_cast<dtkVisualizationView3D *>(d->target->parentWidget()->parentWidget())) {
if(dtkVisualizationView3D *source_view = dynamic_cast<dtkVisualizationView3D *>(d->source->parentWidget()->parentWidget())) {
target_view->link(static_cast<dtkVisualizationCanvas *>(source_view));
}
}
}
void dtkVisualizationViewer::setup(void)
{
QSettings settings;
......@@ -211,26 +185,12 @@ void dtkVisualizationViewer::setdw(void)
void dtkVisualizationViewer::keyPressEvent(QKeyEvent *event)
{
switch(event->key()) {
case Qt::Key_Space:
d->rope->setVisible(!d->rope->isVisible());
event->accept();
break;
default:
if (d->rope->isVisible()) {
event->accept();
qApp->postEvent(d->rope, new QKeyEvent(event->type(), event->key(), event->modifiers(), event->text()));
}
event->ignore();
break;
};
QMainWindow::keyPressEvent(event);
}
void dtkVisualizationViewer::resizeEvent(QResizeEvent *event)
{
d->rope->resize(event->size());
dtkWidgetsMainWindow::resizeEvent(event);
}
// ///////////////////////////////////////////////////////////////////
......
......@@ -14,9 +14,9 @@
#pragma once
#include <QtWidgets>
#include <dtkWidgets>
class dtkVisualizationViewer : public QMainWindow
class dtkVisualizationViewer : public dtkWidgetsMainWindow
{
Q_OBJECT
......@@ -33,19 +33,15 @@ public slots:
void importDataSet(void);
void importDataSet(const QString& path);
protected slots:
void setRopeSource(QWidget *);
void setRopeTarget(QWidget *);
protected:
void setup(void);
void setdw(void);
protected:
void keyPressEvent(QKeyEvent *);
void keyPressEvent(QKeyEvent *) override;
protected:
void resizeEvent(QResizeEvent *);
void resizeEvent(QResizeEvent *) override;
private:
class dtkVisualizationViewerPrivate *d;
......
......@@ -19,9 +19,7 @@
#include <QVTKOpenGLWidget.h>
#include <dtkFonts>
#include <dtkWidgets/dtkWidgetsController>
#include <dtkWidgets/dtkWidgetsLayoutItem>
#include <dtkWidgets>
#include "dtkVisualizationViewer.h"
#include "dtkVisualizationViewerStyle.h"
......@@ -29,10 +27,14 @@
#include <vtkUnstructuredGrid.h>
#include <dtkVisualization/dtkVisualizationDecorator>
int main(int argc, char **argv)
{
QMetaType::registerConverter<vtkUnstructuredGrid *, vtkDataSet *>();
dtk::core::registerParameters();
dtk::widgets::initialize();
#if defined(Q_OS_UNIX) and !defined(Q_OS_MAC)
qputenv("XDG_CURRENT_DESKTOP", "GNOME");
#endif
......@@ -40,11 +42,11 @@ int main(int argc, char **argv)
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication application(argc, argv);
application.setApplicationName("dtkVisualizationViewer");
application.setOrganizationName("inria");
application.setOrganizationDomain("fr");
application.setApplicationVersion("2.5.0");
dtkApplication *application = dtkApplication::create(argc, argv);
application->setApplicationName("dtkVisualizationViewer");
application->setApplicationVersion("2.5.0");
application->setOrganizationName("inria");
application->setOrganizationDomain("fr");
dtkWidgetsLayoutItem::Actions actions;
actions.insert("Plot2D", "Plot 2D");
......@@ -56,15 +58,11 @@ int main(int argc, char **argv)
dtkWidgetsLayoutItem::setActions(actions);
dtkVisualizationViewer *viewer = new dtkVisualizationViewer;
viewer->show();
viewer->raise();
dtkFontSourceSansPro::instance()->initFontSourceSansPro();
application.setFont(dtkFontSourceSansPro::instance()->font(12));
application.setStyle(new dtkVisualizationViewerStyle);
application->setWindow(viewer);
application->initialize();
int status = application.exec();
int status = application->exec();
dtkWidgetsController::instance()->clear();
......
......@@ -17,9 +17,7 @@
#include "dtkVisualizationDecoratorClutEditor.h"
#include "dtkVisualizationView2D.h"
#include <dtkWidgets/dtkWidgetsOverlayPane>
#include <dtkWidgets/dtkWidgetsOverlayPaneItem>
#include <dtkWidgets>
#include <dtkLog>
#include <QColor>
......@@ -196,6 +194,8 @@ void dtkVisualizationDecoratorScalarColorMap::setCanvas(dtkVisualizationCanvas *
return;
}
static_cast<dtkApplication *>(QApplication::instance())->window()->menubar()->addMenu(fa::file, "Files");
dtkWidgetsOverlayPane *canvas_pane = canvas->overlay();
QCheckBox *show_cb = new QCheckBox;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment