Commit 1a8bbcc6 authored by Erwan Demairy's avatar Erwan Demairy

Does compile but does not do anything useful yet.

parent 716682b0
......@@ -20,6 +20,7 @@ add_subdirectory(dtkVisualizationOverlayRope)
add_subdirectory(dtkVisualizationViewVideo)
add_subdirectory(dtkVisualizationViewVideoMixed)
add_subdirectory(dtkVisualizationViewHybrid)
add_subdirectory(dtkVisualizationDataManager)
######################################################################
### CMakeLists.txt ends here
## Version: $Id$
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change Log:
##
######################################################################
##
### Code:
project(dtkVisualizationDataManager)
## #################################################################
## Sources
## #################################################################
set(${PROJECT_NAME}_SOURCES main.cpp)
## #################################################################
## Build rules
## #################################################################
add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${${PROJECT_NAME}_SOURCES})
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} dtkVisualization)
target_link_libraries(${PROJECT_NAME} dtkVisualizationWidgets)
target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})
## ###################################################################
## Bundle setup
## ###################################################################
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.plist.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.plist)
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.plist)
endif(APPLE)
######################################################################
### CMakeLists.txt ends here
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>@PROJECT_NAME@</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string>@PROJECT_NAME@</string>
<key>CFBundleIdentifier</key>
<string>fr.inria.@PROJECT_NAME@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>@dtkVisualization_VERSION@</string>
<key>CFBundleName</key>
<string>@PROJECT_NAME@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@dtkVisualization_VERSION@</string>
<key>CFBundleVersion</key>
<string>@dtkVisualization_VERSION@</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Inria</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include <dtkVisualizationWidgetsDataManager>
#include <QtWidgets>
#include <math.h>
#define MAX 5
int main(int argc, char **argv)
{
QApplication application(argc, argv);
application.setApplicationName("dtkVisualizationDataManager");
application.setOrganizationName("inria");
application.setOrganizationDomain("fr");
dtkVisualizationWidgetsDataManager* manager = dtkVisualizationWidgetsDataManager::instance();
manager->show();
manager->raise();
return application.exec();
}
//
// main.cpp ends here
......@@ -30,7 +30,13 @@ set(${PROJECT_NAME}_HEADERS
dtkVisualizationWidgetsFieldScalar.h
dtkVisualizationWidgetsVideoControls
dtkVisualizationWidgetsVideoControls.h
)
dtkVisualizationWidgetsDataManager.h
dtkVisualizationWidgetsDataManagerFocus.h
dtkVisualizationWidgetsDataManagerItemButton.h
dtkVisualizationWidgetsDataSerie.h
# dtkVisualizationWidgetsDataManager_p.h
# dtkVisualizationWidgetsDataManagerData.h
)
set(${PROJECT_NAME}_SOURCES
dtkVisualizationWidgetsActorList.cpp
......@@ -38,6 +44,12 @@ set(${PROJECT_NAME}_SOURCES
dtkVisualizationWidgetsColorMapEditor.cpp
dtkVisualizationWidgetsFieldScalar.cpp
dtkVisualizationWidgetsVideoControls.cpp
dtkVisualizationWidgetsDataManager.cpp
dtkVisualizationWidgetsDataManagerFocus.cpp
dtkVisualizationWidgetsDataManagerItemButton.cpp
dtkVisualizationWidgetsDataSerie.cpp
dtkVisualizationWidgetsDataManagerData.cpp
dtkVisualizationWidgetsDataManagerItem.cpp
)
set(${PROJECT_NAME}_SOURCES_QRC
......
#include "dtkVisualizationWidgetsDataManager.h"
\ No newline at end of file
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <dtkVisualizationExport>
#include <dtkVisualizationWidgetsDataSerie.h>
#include <QtCore>
#include <QtWidgets>
class dtkVisualizationWidgetsDataManagerItem;
class DTKVISUALIZATION_EXPORT dtkVisualizationWidgetsDataManager : public QFrame
{
Q_OBJECT
public:
static dtkVisualizationWidgetsDataManager *instance(void);
signals:
void shrink(void);
void expand(void);
public:
QSize sizeHint(void) const;
public slots:
void addImage(dtkVisualizationWidgetsDataSeriePtr, const QColor&);
public slots:
void present(dtkVisualizationWidgetsDataManagerItem *);
public:
dtkVisualizationWidgetsDataSeriePtr get(int index);
public:
QPixmap thumbnail(int index);
protected:
dtkVisualizationWidgetsDataManager(QWidget *parent = nullptr);
~dtkVisualizationWidgetsDataManager(void);
protected:
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
protected:
void mousePressEvent(QMouseEvent *);
protected:
void paintEvent(QPaintEvent *);
private:
class dtkVisualizationWidgetsDataManagerPrivate *d;
private:
static dtkVisualizationWidgetsDataManager *s_instance;
};
//
// dtkVisualizationWidgetsDataManager.h ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkVisualizationWidgetsDataManagerData.h"
#include "dtkVisualizationWidgetsDataSerie.h"
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
QWidget *dtkVisualizationWidgetsDataManagerDataCreate(const QVariant& v)
{
QLabel *label = new QLabel;
if(v.type() == QVariant::Int)
label->setText(QString::number(v.toInt()));
if(v.type() == QVariant::Double)
label->setText(QString::number(v.toDouble()));
if(v.type() == QVariant::String)
label->setText(v.toString());
if(v.type() == QVariant::Color) {
QPixmap pixmap(16, 16);
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(Qt::white);
painter.setBrush(v.value<QColor>());
painter.drawRoundedRect(0, 0, 16, 16, 8, 8);
label->setPixmap(pixmap);
}
return label;
}
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
class dtkVisualizationWidgetsDataManagerDataPrivate : public QScrollArea
{
public:
dtkVisualizationWidgetsDataManagerDataPrivate(dtkVisualizationWidgetsDataManagerData* data);
~dtkVisualizationWidgetsDataManagerDataPrivate(void);
public:
QWidget *contents;
};
dtkVisualizationWidgetsDataManagerDataPrivate::dtkVisualizationWidgetsDataManagerDataPrivate(dtkVisualizationWidgetsDataManagerData* data) : QScrollArea(0)
{
QFormLayout *layout = new QFormLayout;
for(QString key : data->data.keys())
layout->addRow(key, dtkVisualizationWidgetsDataManagerDataCreate(data->data.value(key)));
this->contents = new QWidget(this);
this->contents->setLayout(layout);
this->setWidget(this->contents);
this->setWidgetResizable(true);
}
dtkVisualizationWidgetsDataManagerDataPrivate::~dtkVisualizationWidgetsDataManagerDataPrivate(void)
{
}
// ///////////////////////////////////////////////////////////////////
//
// ///////////////////////////////////////////////////////////////////
dtkVisualizationWidgetsDataManagerData::dtkVisualizationWidgetsDataManagerData(QObject *parent) : QObject(parent)
{
}
dtkVisualizationWidgetsDataManagerData::~dtkVisualizationWidgetsDataManagerData(void)
{
}
QScrollArea *dtkVisualizationWidgetsDataManagerData::compute(void)
{
return new dtkVisualizationWidgetsDataManagerDataPrivate(this);
}
//
// dtkVisualizationWidgetsDataManagerData.cpp ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtCore>
#include <QtWidgets>
class dtkVisualizationWidgetsDataManagerItem;
class dtkVisualizationWidgetsDataManagerData : public QObject
{
Q_OBJECT
public:
dtkVisualizationWidgetsDataManagerData(QObject *parent = nullptr);
~dtkVisualizationWidgetsDataManagerData(void);
public slots:
QScrollArea *compute(void);
public:
dtkVisualizationWidgetsDataManagerItem *reference;
public:
QVariantMap data;
private:
class dtkVisualizationWidgetsDataManagerDataPrivate *d;
};
//
// dtkVisualizationWidgetsDataManagerData.h ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkVisualizationWidgetsDataManagerFocus.h"
dtkVisualizationWidgetsDataManagerFocus::dtkVisualizationWidgetsDataManagerFocus(QWidget *parent) : QLabel(parent)
{
}
dtkVisualizationWidgetsDataManagerFocus::~dtkVisualizationWidgetsDataManagerFocus(void)
{
}
//
// dtkVisualizationWidgetsDataManagerFocus.cpp ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtWidgets>
class dtkVisualizationWidgetsDataManagerFocus : public QLabel
{
Q_OBJECT
public:
dtkVisualizationWidgetsDataManagerFocus(QWidget *parent = nullptr);
~dtkVisualizationWidgetsDataManagerFocus(void);
public:
QPoint source;
QPoint destnt;
public:
QSize s_size;
QSize d_size;
public:
bool presented = false;
};
//
// dtkVisualizationWidgetsDataManagerFocus.h ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkVisualizationWidgetsDataManager_p.h"
#include "dtkVisualizationWidgetsDataManagerItem.h"
#include "dtkVisualizationWidgetsDataManagerItemButton.h"
#include <dtkFonts>
dtkVisualizationWidgetsDataManagerItem::dtkVisualizationWidgetsDataManagerItem(const QColor& color, const QPixmap& thumbnail, dtkVisualizationWidgetsDataManagerPrivate *parent, bool multi_images) : QLabel(parent)
{
this->parent = parent;
this->button_destroy = new dtkVisualizationWidgetsDataManagerItemButton(color, fa::times, this);
this->button_destroy->move(79, 5);
this->button_destroy->setVisible(false);
this->button_save = new dtkVisualizationWidgetsDataManagerItemButton(color, fa::save, this);
this->button_save->move(5, 5);
this->button_save->setVisible(false);
int size = 100;
int space = 3;
QPixmap pix;
if (multi_images) {
this->setBaseSize(size, size);
pix = thumbnail.scaled(size, size, Qt::KeepAspectRatio);
QPixmap pix2(100,100);
pix2.fill(Qt::transparent);
QImage image = pix.toImage();;
QPainter paint(&pix2);
paint.setPen(color);
paint.drawRect(2*space, 0, size-2*space-1, size-2*space-1);
paint.fillRect(2*space+1, 1, size-2*space-2, size-2*space-2, Qt::black);
paint.drawRect(space, space, size-2*space-1, size-2*space-1);
paint.fillRect(space+1, space+1, size-2*space-2, size-2*space-2, Qt::black);
paint.drawRect(0, 2*space, size-2*space-1, size-2*space-1);
QRectF target(1, 2*space+1, size-2*space-2, size-2*space-2);
QRectF source(0, 0, size-2*space-3, size-2*space-3);
paint.drawImage(target, image, source);
paint.end();
this->setPixmap(pix2);
this->thumbnail = pix2;
this->transparent_thumbnail = pix2;
this->transparent_thumbnail.fill();
} else {
pix = thumbnail.scaled(size, size, Qt::KeepAspectRatio);
this->setPixmap(pix);
this->thumbnail = *this->pixmap();
this->transparent_thumbnail = *this->pixmap();
this->transparent_thumbnail.fill();
}
QPainter painter;
painter.begin(&transparent_thumbnail);
painter.setOpacity(0.5);
painter.drawPixmap(0, 0, *this->pixmap());
painter.end();
if (!multi_images) {
this->setStyleSheet(QString("border: 1px solid rgb(%1, %2, %3);").arg(color.red()).arg(color.green()).arg(color.blue()));
}
connect(this->button_destroy, SIGNAL(clicked()), this, SIGNAL(destroy()));
connect(this->button_save, SIGNAL(clicked()), this, SIGNAL(save()));
this->setMouseTracking(true);
}
dtkVisualizationWidgetsDataManagerItem::~dtkVisualizationWidgetsDataManagerItem(void)
{
}
void dtkVisualizationWidgetsDataManagerItem::enterEvent(QEvent *)
{
this->button_destroy->setVisible(true);
this->button_save->setVisible(true);
this->setPixmap(this->transparent_thumbnail);
}
void dtkVisualizationWidgetsDataManagerItem::leaveEvent(QEvent *)
{
this->button_destroy->setVisible(false);
this->button_save->setVisible(false);
this->setPixmap(this->thumbnail);
}
void dtkVisualizationWidgetsDataManagerItem::mousePressEvent(QMouseEvent *)
{
if(parent->state == dtkVisualizationWidgetsDataManagerPrivate::Collapsed) {
QMimeData *mimeData = new QMimeData;
mimeData->setText(QString(":%1").arg(this->id));
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(*(this->pixmap()));
drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height()/2));
Qt::DropAction dropAction = drag->exec();
} else {
emit clicked();
}
}
//
// dtkVisualizationWidgetsDataManagerItem.cpp ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <QtCore>
#include <QtWidgets>
class dtkVisualizationWidgetsDataManagerPrivate;
class dtkVisualizationWidgetsDataManagerItemButton;
class dtkVisualizationWidgetsDataManagerItem : public QLabel
{
Q_OBJECT
public:
dtkVisualizationWidgetsDataManagerItem(const QColor&, const QPixmap& thumbnail, dtkVisualizationWidgetsDataManagerPrivate *parent, bool multi_images);
~dtkVisualizationWidgetsDataManagerItem(void);
signals:
void clicked(void);
void destroy(void);
void save(void);
protected:
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void mousePressEvent(QMouseEvent *);
public:
int id;
public:
dtkVisualizationWidgetsDataManagerPrivate *parent;
public:
dtkVisualizationWidgetsDataManagerItemButton *button_destroy;
dtkVisualizationWidgetsDataManagerItemButton *button_save;
public:
QPixmap thumbnail;
QPixmap transparent_thumbnail;
};
//
// dtkVisualizationWidgetsDataManagerItem.h ends here
#include "dtkVisualizationWidgetsDataManagerItemButton.h"
#include <dtkFonts>
dtkVisualizationWidgetsDataManagerItemButton::dtkVisualizationWidgetsDataManagerItemButton(const QColor& color, int icon, QWidget *parent) : QLabel(parent)
{
// this->font = new gnomonFontAwesome(this);
// this->font->initFontAwesome();
// this->font->setDefaultOption("color", color);
//
// this->setPixmap(this->font->icon(icon).pixmap(16, 16));
this->setText("TODO TODO");
this->setStyleSheet("background: none; border: none;");
}
dtkVisualizationWidgetsDataManagerItemButton::~dtkVisualizationWidgetsDataManagerItemButton(void)
{
}
void dtkVisualizationWidgetsDataManagerItemButton::mousePressEvent(QMouseEvent *)
{
emit clicked();
}
#include <dtkVisualizationExport>
#include <QtCore>
#include <QLabel>
class gnomonFontAwesome;
// ///////////////////////////////////////////////////////////////////
// gnomonItemButton
// ///////////////////////////////////////////////////////////////////
class DTKVISUALIZATION_EXPORT dtkVisualizationWidgetsDataManagerItemButton : public QLabel
{
Q_OBJECT
public:
dtkVisualizationWidgetsDataManagerItemButton(const QColor& color, int icon, QWidget *parent = nullptr);
~dtkVisualizationWidgetsDataManagerItemButton(void);
signals:
void clicked(void);
protected:
void mousePressEvent(QMouseEvent *);