Towards visualization helper widgets.

parent 45a2c427
......@@ -94,6 +94,7 @@ include_directories(${dtkWidgets_INCLUDE_DIRS})
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/src/dtkVisualization)
include_directories(${CMAKE_SOURCE_DIR}/src/dtkVisualizationWidgets)
## ###################################################################
## Input
......
......@@ -13,6 +13,7 @@
### Code:
add_subdirectory(dtkVisualization)
add_subdirectory(dtkVisualizationWidgets)
## #################################################################
## Target definition
......@@ -21,6 +22,7 @@ add_subdirectory(dtkVisualization)
set(DTKVISUALIZATION_TARGETS)
set(DTKVISUALIZATION_TARGETS ${DTKVISUALIZATION_TARGETS} dtkVisualization)
set(DTKVISUALIZATION_TARGETS ${DTKVISUALIZATION_TARGETS} dtkVisualizationWidgets)
## #################################################################
## Target export
......
......@@ -49,6 +49,8 @@ target_link_libraries(${PROJECT_NAME} Qt5::OpenGL)
target_link_libraries(${PROJECT_NAME} dtkFonts)
target_link_libraries(${PROJECT_NAME} dtkWidgets)
target_link_libraries(${PROJECT_NAME} dtkVisualizationWidgets)
target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})
## #################################################################
......
......@@ -18,6 +18,8 @@
#include <dtkWidgets/dtkWidgetsHUDItem>
#include <dtkWidgets/dtkWidgetsOverlayPane>
#include <dtkVisualizationWidgets/dtkVisualizationWidgetsClutEditor>
#include <vtkCamera.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkRenderer.h>
......@@ -54,6 +56,9 @@ public:
public:
dtkWidgetsHUD *hud;
dtkWidgetsOverlayPane *overlay;
public:
dtkVisualizationWidgetsClutEditor *clut;
};
dtkVisualizationView3DPrivate::dtkVisualizationView3DPrivate(QWidget *parent) : QVTKOpenGLWidget(parent)
......@@ -72,7 +77,16 @@ dtkVisualizationView3DPrivate::dtkVisualizationView3DPrivate(QWidget *parent) :
this->setObjectName(QString("View3D - %1").arg(count++));
this->hud = new dtkWidgetsHUD(this);
this->clut = new dtkVisualizationWidgetsClutEditor(this);
dtkWidgetsOverlayPaneItem *clut_item = new dtkWidgetsOverlayPaneItem(this);
clut_item->setTitle("Color Lookup Table");
clut_item->layout()->setContentsMargins(0, 0, 0, 0);
clut_item->addWidget(this->clut);
this->overlay = new dtkWidgetsOverlayPane(this);
this->overlay->addWidget(clut_item);
}
dtkVisualizationView3DPrivate::~dtkVisualizationView3DPrivate(void)
......
## Version: $Id$
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change Log:
##
######################################################################
##
### Code:
project(dtkVisualizationWidgets)
## #################################################################
## Sources
## #################################################################
set(${PROJECT_NAME}_HEADERS
dtkVisualizationWidgetsClutEditor
dtkVisualizationWidgetsClutEditor.h)
set(${PROJECT_NAME}_SOURCES
dtkVisualizationWidgetsClutEditor.cpp)
## #################################################################
## Build rules
## #################################################################
add_library(${PROJECT_NAME} SHARED
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} Qt5::OpenGL)
target_link_libraries(${PROJECT_NAME} dtkFonts)
target_link_libraries(${PROJECT_NAME} dtkWidgets)
target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})
## #################################################################
## Export header file
## #################################################################
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export")
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export.h")
set(${PROJECT_NAME}_HEADERS
${${PROJECT_NAME}_HEADERS}
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export.h")
## ###################################################################
## Install rules - files
## ###################################################################
install(FILES ${${PROJECT_NAME}_HEADERS}
DESTINATION include/${PROJECT_NAME}
COMPONENT visualization)
## ###################################################################
## Install rules - targets
## ###################################################################
install(TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT visualization
EXPORT dtkVisualizationDepends)
######################################################################
### CMakeLists.txt ends here
#include "dtkVisualizationWidgetsClutEditor.h"
// Version: $Id: 80be09c7cc19c2fc912fa461752bfbc2a211d0d6 $
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtCore>
#include <QtGui>
#include <QtWidgets>
#include <dtkVisualizationWidgetsExport.h>
// /////////////////////////////////////////////////////////////////
// dtkVisualizationWidgetsClutEditorVertex
// /////////////////////////////////////////////////////////////////
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsClutEditorVertex : public QObject, public QGraphicsItem
{
Q_OBJECT
public:
dtkVisualizationWidgetsClutEditorVertex(int x, int y, QColor color = Qt::yellow, QGraphicsItem *parent = 0);
dtkVisualizationWidgetsClutEditorVertex(QPointF point, QColor color = Qt::yellow, QGraphicsItem *parent = 0);
~dtkVisualizationWidgetsClutEditorVertex(void);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QRectF boundingRect(void) const;
QPoint position(void) const;
QColor color(void) const;
void setColor(const QColor& color);
signals:
void moved(const QPointF& position);
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
private:
QColor fgColor;
QColor bgColor;
};
// /////////////////////////////////////////////////////////////////
// dtkVisualizationWidgetsClutEditorScene
// /////////////////////////////////////////////////////////////////
class dtkVisualizationWidgetsClutEditorScenePrivate;
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsClutEditorScene : public QGraphicsScene
{
Q_OBJECT
public:
dtkVisualizationWidgetsClutEditorScene(QObject *parent = 0);
~dtkVisualizationWidgetsClutEditorScene(void);
void addItem(QGraphicsItem *item);
signals:
void moved(const QPointF& position);
void removed(void);
protected:
void keyPressEvent(QKeyEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
private:
dtkVisualizationWidgetsClutEditorScenePrivate *d;
};
// /////////////////////////////////////////////////////////////////
// dtkVisualizationWidgetsClutEditorView
// /////////////////////////////////////////////////////////////////
class dtkVisualizationWidgetsClutEditorViewPrivate;
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsClutEditorView : public QGraphicsView
{
public:
dtkVisualizationWidgetsClutEditorView(QWidget *parent = 0);
~dtkVisualizationWidgetsClutEditorView(void);
private:
dtkVisualizationWidgetsClutEditorViewPrivate *d;
};
// /////////////////////////////////////////////////////////////////
// dtkVisualizationWidgetsClutEditor
// /////////////////////////////////////////////////////////////////
class vtkColorTransferFunction;
class vtkPiecewiseFunction;
class DTKVISUALIZATIONWIDGETS_EXPORT dtkVisualizationWidgetsClutEditor : public QWidget
{
Q_OBJECT
public:
enum ColorSpace {
HSV,
RGB
};
public:
typedef QList<int> Histogram;
public:
dtkVisualizationWidgetsClutEditor(QWidget *parent = 0);
~dtkVisualizationWidgetsClutEditor(void);
void *colorTransferFunction(void);
void *opacityTransferFunction(void);
void setColorTransferFunction(vtkColorTransferFunction *color_transfer_function);
void setOpacityTransferFunction(vtkPiecewiseFunction *opacity_transfer_function);
void setRange(double min, double max);
void setHistogram(const Histogram& histogram);
signals:
void updated(void);
public slots:
void importClut(void);
void exportClut(void);
void toggle(bool);
public:
QSize sizeHint(void) const;
protected slots:
void onApply(void);
void onColorAuto(void);
void onColorChoose(void);
void onSelectionChanged(void);
void onVertexMoved(const QPointF& point);
protected:
void resizeEvent(QResizeEvent *event);
private:
void updateTable(void);
private:
class dtkVisualizationWidgetsClutEditorPrivate *d;
};
//
// dtkVisualizationWidgetsClutEditor.h ends here
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