Commit 6b800797 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud

Retrieve dtkComposer layer.

parent a0123f23
### CMakeLists.txt ---
##
## Author: Julien Wintz
## Created: Wed Mar 20 12:26:15 2013 (+0100)
## Version:
## Last-Updated: Mon Apr 15 16:01:56 2013 (+0200)
## By: Julien Wintz
## Update #: 260
######################################################################
##
### Change Log:
##
######################################################################
project(dtkComposer)
## #################################################################
## Input
## #################################################################
set(${PROJECT_NAME}_HEADERS
dtkComposer.h
dtkComposerCompass.h
dtkComposerControls.h
dtkComposerControlsDelegate.h
dtkComposerEvaluator.h
dtkComposerEvaluator_p.h
dtkComposerGraph.h
dtkComposerGraphEdge.h
dtkComposerGraphLayouter.h
dtkComposerGraphNode.h
dtkComposerGraphNodeBegin.h
dtkComposerGraphNodeEnd.h
dtkComposerGraphNode.h
dtkComposerGraphNodeLeaf.h
dtkComposerGraphNodeSelectBranch.h
dtkComposerGraphNodeSetInputs.h
dtkComposerGraphNodeSetOutputs.h
dtkComposerGraphNodeSetVariables.h
dtkComposerGraphView.h
dtkComposerNode.h
dtkComposerNodeFactory.h
dtkComposerNodeFactoryView.h
dtkComposerNodeBoolean.h
dtkComposerNodeBooleanOperator.h
dtkComposerNodeComposite.h
dtkComposerNodeConstants.h
dtkComposerNodeControl.h
dtkComposerNodeControlCase.h
dtkComposerNodeControlDoWhile.h
dtkComposerNodeControlIf.h
dtkComposerNodeControlFor.h
dtkComposerNodeControlForEach.h
dtkComposerNodeControlMap.h
dtkComposerNodeControlWhile.h
dtkComposerNodeFile.h
dtkComposerNodeFile_p.h
dtkComposerNodeInteger.h
dtkComposerNodeLeaf.h
# dtkComposerNodeLeafData.h
# dtkComposerNodeLeafProcess.h
# dtkComposerNodeLeafView.h
dtkComposerNodeLogger.h
dtkComposerNodeNumberOperator.h
dtkComposerNodeProxy.h
dtkComposerNodeReal.h
dtkComposerNodeString.h
dtkComposerNodeStringOperator.h
dtkComposerPath.h
dtkComposerScene.h
dtkComposerScene_p.h
dtkComposerSceneEdge.h
dtkComposerSceneModel.h
dtkComposerSceneNode.h
dtkComposerSceneNode_p.h
dtkComposerSceneNodeComposite.h
dtkComposerSceneNodeControl.h
dtkComposerSceneNodeHandle.h
dtkComposerSceneNodeEditor.h
dtkComposerSceneNodeEditor_p.h
dtkComposerSceneNodeLeaf.h
dtkComposerSceneNote.h
dtkComposerScenePort.h
dtkComposerSceneView.h
dtkComposerSearchDialog.h
dtkComposerStack.h
dtkComposerStackCommand.h
dtkComposerStackUtils.h
dtkComposerStackView.h
dtkComposerTransmitter.h
dtkComposerTransmitter_p.h
dtkComposerTransmitterEmitter.h
dtkComposerTransmitterEmitter.tpp
dtkComposerTransmitterHandler.h
dtkComposerTransmitterHandler.tpp
dtkComposerTransmitterProxy.h
dtkComposerTransmitterProxyLoop.h
dtkComposerTransmitterProxyLoop.tpp
dtkComposerTransmitterReceiver.h
dtkComposerTransmitterReceiver.tpp
dtkComposerView.h
dtkComposerReader.h
dtkComposerWriter.h)
set(${PROJECT_NAME}_SOURCES
dtkComposer.cpp
dtkComposerCompass.cpp
dtkComposerControls.cpp
dtkComposerControlsDelegate.cpp
dtkComposerEvaluator.cpp
dtkComposerGraph.cpp
dtkComposerGraphEdge.cpp
dtkComposerGraphLayouter.cpp
dtkComposerGraphNodeBegin.cpp
dtkComposerGraphNode.cpp
dtkComposerGraphNodeEnd.cpp
dtkComposerGraphNodeLeaf.cpp
dtkComposerGraphNodeSelectBranch.cpp
dtkComposerGraphNodeSetInputs.cpp
dtkComposerGraphNodeSetOutputs.cpp
dtkComposerGraphNodeSetVariables.cpp
dtkComposerGraphView.cpp
dtkComposerNode.cpp
dtkComposerNodeFactory.cpp
dtkComposerNodeFactoryView.cpp
dtkComposerNodeBoolean.cpp
dtkComposerNodeBooleanOperator.cpp
dtkComposerNodeComposite.cpp
dtkComposerNodeConstants.cpp
dtkComposerNodeControl.cpp
dtkComposerNodeControlCase.cpp
dtkComposerNodeControlDoWhile.cpp
dtkComposerNodeControlIf.cpp
dtkComposerNodeControlFor.cpp
dtkComposerNodeControlForEach.cpp
dtkComposerNodeControlMap.cpp
dtkComposerNodeControlWhile.cpp
dtkComposerNodeFile.cpp
dtkComposerNodeInteger.cpp
dtkComposerNodeLeaf.cpp
# dtkComposerNodeLeafData.cpp
# dtkComposerNodeLeafProcess.cpp
# dtkComposerNodeLeafView.cpp
dtkComposerNodeLogger.cpp
dtkComposerNodeNumberOperator.cpp
dtkComposerNodeProxy.cpp
dtkComposerNodeReal.cpp
dtkComposerNodeString.cpp
dtkComposerNodeStringOperator.cpp
dtkComposerPath.cpp
dtkComposerScene.cpp
dtkComposerSceneEdge.cpp
dtkComposerSceneModel.cpp
dtkComposerSceneNode.cpp
dtkComposerSceneNodeComposite.cpp
dtkComposerSceneNodeControl.cpp
dtkComposerSceneNodeHandle.cpp
dtkComposerSceneNodeEditor.cpp
dtkComposerSceneNodeLeaf.cpp
dtkComposerSceneNote.cpp
dtkComposerScenePort.cpp
dtkComposerSceneView.cpp
dtkComposerSearchDialog.cpp
dtkComposerStack.cpp
dtkComposerStackCommand.cpp
dtkComposerStackUtils.cpp
dtkComposerStackView.cpp
dtkComposerTransmitter.cpp
dtkComposerTransmitterEmitter.cpp
dtkComposerTransmitterReceiver.cpp
dtkComposerTransmitterProxy.cpp
dtkComposerTransmitterProxyLoop.cpp
dtkComposerView.cpp
dtkComposerReader.cpp
dtkComposerWriter.cpp)
set(${PROJECT_NAME}_QRC dtkComposer.qrc)
## #################################################################
## Build rules
## #################################################################
qt5_add_resources(${PROJECT_NAME}_QRC ${PROJECT_NAME}_RCC)
add_library(${PROJECT_NAME} SHARED
${${PROJECT_NAME}_RCC}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})
## ###################################################################
## Link rules
## ###################################################################
qt5_use_modules(${PROJECT_NAME} Concurrent)
qt5_use_modules(${PROJECT_NAME} Core)
qt5_use_modules(${PROJECT_NAME} Gui)
qt5_use_modules(${PROJECT_NAME} Network)
qt5_use_modules(${PROJECT_NAME} Widgets)
qt5_use_modules(${PROJECT_NAME} Xml)
target_link_libraries(${PROJECT_NAME} dtkLog)
target_link_libraries(${PROJECT_NAME} dtkCore)
target_link_libraries(${PROJECT_NAME} dtkWidgets)
## ###################################################################
## Install rules - files
## ###################################################################
install(FILES ${${PROJECT_NAME}_HEADERS}
DESTINATION include/${PROJECT_NAME}
COMPONENT composer)
## ###################################################################
## Install rules - targets
## ###################################################################
install(TARGETS ${PROJECT_NAME}
DESTINATION lib
COMPONENT composer
EXPORT dtkDepends)
#include "dtkComposer.h"
#include "dtkComposerCompass.h"
#include "dtkComposerControls.h"
#include "dtkComposerControlsDelegate.h"
#include "dtkComposerEvaluator.h"
#include "dtkComposerGraph.h"
#include "dtkComposerGraphEdge.h"
#include "dtkComposerGraphLayouter.h"
#include "dtkComposerGraphNode.h"
#include "dtkComposerGraphNodeBegin.h"
#include "dtkComposerGraphNodeEnd.h"
#include "dtkComposerGraphNode.h"
#include "dtkComposerGraphNodeLeaf.h"
#include "dtkComposerGraphNodeSelectBranch.h"
#include "dtkComposerGraphNodeSetInputs.h"
#include "dtkComposerGraphNodeSetOutputs.h"
#include "dtkComposerGraphNodeSetVariables.h"
#include "dtkComposerGraphView.h"
#include "dtkComposerNode.h"
#include "dtkComposerNodeFactory.h"
#include "dtkComposerNodeFactoryView.h"
#include "dtkComposerNodeBoolean.h"
#include "dtkComposerNodeBooleanOperator.h"
#include "dtkComposerNodeComposite.h"
#include "dtkComposerNodeConstants.h"
#include "dtkComposerNodeControl.h"
#include "dtkComposerNodeControlCase.h"
#include "dtkComposerNodeControlDoWhile.h"
#include "dtkComposerNodeControlFor.h"
#include "dtkComposerNodeControlForEach.h"
#include "dtkComposerNodeControlIf.h"
#include "dtkComposerNodeControlMap.h"
#include "dtkComposerNodeControlWhile.h"
#include "dtkComposerNodeFile.h"
#include "dtkComposerNodeInteger.h"
#include "dtkComposerNodeLeaf.h"
#include "dtkComposerNodeLogger.h"
#include "dtkComposerNodeNumberOperator.h"
#include "dtkComposerNodeReal.h"
#include "dtkComposerNodeString.h"
#include "dtkComposerNodeStringOperator.h"
#include "dtkComposerPath.h"
#include "dtkComposerScene.h"
#include "dtkComposerSceneEdge.h"
#include "dtkComposerSceneModel.h"
#include "dtkComposerSceneNode.h"
#include "dtkComposerSceneNode_p.h"
#include "dtkComposerSceneNodeComposite.h"
#include "dtkComposerSceneNodeControl.h"
#include "dtkComposerSceneNodeHandle.h"
#include "dtkComposerSceneNodeEditor.h"
#include "dtkComposerSceneNodeLeaf.h"
#include "dtkComposerSceneNote.h"
#include "dtkComposerScenePort.h"
#include "dtkComposerSceneView.h"
#include "dtkComposerSearchDialog.h"
#include "dtkComposerStack.h"
#include "dtkComposerStackCommand.h"
#include "dtkComposerStackUtils.h"
#include "dtkComposerStackView.h"
#include "dtkComposerTransmitter.h"
#include "dtkComposerTransmitterEmitter.h"
#include "dtkComposerTransmitterProxy.h"
#include "dtkComposerTransmitterProxyLoop.h"
#include "dtkComposerTransmitterReceiver.h"
#include "dtkComposerView.h"
#include "dtkComposerReader.h"
#include "dtkComposerWriter.h"
/* dtkComposer.cpp ---
*
* Author: Thibaud Kloczko
* Created: Tue Apr 9 12:49:06 2013 (+0200)
* Version:
* Last-Updated: Wed Apr 10 15:09:19 2013 (+0200)
* By: Thibaud Kloczko
* Update #: 37
*/
/* Change Log:
*
*/
#include "dtkComposer.h"
#include "dtkComposerNodeFactory.h"
namespace dtkComposer
{
namespace node
{
namespace _private {
dtkComposerNodeFactory factory;
}
dtkComposerNodeFactory& factory(void) {
return _private::factory;
}
}
}
/* dtkComposer.h ---
*
* Author: Thibaud Kloczko
* Created: Tue Apr 9 12:43:49 2013 (+0200)
* Version:
* Last-Updated: Mon Apr 15 10:30:06 2013 (+0200)
* By: Julien Wintz
* Update #: 32
*/
/* Change Log:
*
*/
#pragma once
class dtkComposerNodeFactory;
namespace dtkComposer
{
namespace node {
dtkComposerNodeFactory& factory(void);
}
}
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="dtkComposer">
<file>dtkComposerNodeFlag-blue.png</file>
<file>dtkComposerNodeFlag-gray.png</file>
<file>dtkComposerNodeFlag-green.png</file>
<file>dtkComposerNodeFlag-orange.png</file>
<file>dtkComposerNodeFlag-pink.png</file>
<file>dtkComposerNodeFlag-red.png</file>
<file>dtkComposerNodeFlag-yellow.png</file>
</qresource>
</RCC>
#include "dtkComposerCompass.h"
\ No newline at end of file
/* dtkComposerCompass.cpp ---
*
* Author: Julien Wintz
* Copyright (C) 2008-2011 - Julien Wintz, Inria.
* Created: Wed Apr 18 09:37:07 2012 (+0200)
* Version: $Id$
* Last-Updated: Thu Apr 19 13:16:55 2012 (+0200)
* By: tkloczko
* Update #: 344
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#include "dtkComposerCompass.h"
#include "dtkComposerView.h"
// /////////////////////////////////////////////////////////////////
// Helper functions
// /////////////////////////////////////////////////////////////////
QRect toRect(QPolygon polygon)
{
if(polygon.size() != 4)
return QRect();
return QRect(polygon.first(), polygon.at(2));
}
QRect toRect(QPolygonF polygon)
{
return toRect(polygon.toPolygon());
}
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
class dtkComposerCompassPrivate
{
public:
dtkComposerView *view;
public:
QRect c_rect; // crop
QRect s_rect; // source
QRect t_rect; // target
public:
QPoint pos;
public:
bool moving;
};
// /////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////
dtkComposerCompass::dtkComposerCompass(QWidget *parent) : QGraphicsView(parent), d(new dtkComposerCompassPrivate)
{
d->view = NULL;
this->setAttribute(Qt::WA_MacShowFocusRect, false);
this->setBackgroundBrush(QColor(0xc5, 0xc5, 0xc5));
this->setFrameStyle(QFrame::NoFrame);
this->setInteractive(false);
this->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
d->moving = false;
}
dtkComposerCompass::~dtkComposerCompass(void)
{
delete d;
d = NULL;
}
void dtkComposerCompass::setView(dtkComposerView *view)
{
d->view = view;
connect(d->view, SIGNAL(scrolled()), this, SLOT(update()));
}
void dtkComposerCompass::update(void)
{
this->scene()->update();
QGraphicsView::update();
}
#define CROP_BORDER_LINE 10
#define CROP_GRID_SIZE 3
void dtkComposerCompass::paintEvent(QPaintEvent *event)
{
if(!d->view)
return;
if(event->rect().width() < 20 || event->rect().height() < 20)
return;
bool fit = false;
if (d->s_rect != d->view->sceneRect().toRect()) {
d->s_rect = d->view->sceneRect().toRect();
fit = true;
}
if (d->t_rect != event->rect()) {
d->t_rect = event->rect();
fit = true;
}
if(fit && (d->s_rect.width() > d->t_rect.width() || d->s_rect.height() > d->t_rect.height()))
this->fitInView(this->scene()->sceneRect(), Qt::KeepAspectRatio);
// --
QGraphicsView::paintEvent(event);
// -- Map source view to target view through scene
d->c_rect = toRect(d->view->mapToScene(d->view->rect()));
d->c_rect = toRect(this->mapFromScene(d->c_rect));
// --
if(d->c_rect.contains(d->t_rect))
return;
// --
QPainterPath cropPath;
cropPath.addRect(d->c_rect);
QPainterPath windowPath;
windowPath.addRect(d->t_rect);
windowPath -= cropPath;
QPainter painter(this->viewport());
painter.setRenderHints(QPainter::Antialiasing);
// Draw Alpha-Black Background.
painter.fillPath(windowPath, QColor(0x83, 0x83, 0x83, 0x77));
// Draw Crop Rect
painter.setPen(QPen(QColor(0xdd, 0xdd, 0xdd), 1));
painter.drawPath(cropPath);
// --
int topRightX = d->c_rect.x() + d->c_rect.width();