From 15d9c7c455b3e20bdab95dd37c2d018b0cfb68d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Fri, 10 Mar 2017 10:21:30 -0500 Subject: [PATCH] ... --- applis/PipelineEditor/PipelineEditor.ui | 24 ++++++++- libs/cpPipelineEditor/Block.cxx | 43 +++++++++++++++ libs/cpPipelineEditor/Block.h | 39 ++++++++++++++ libs/cpPipelineEditor/Canvas.cxx | 4 ++ libs/cpPipelineEditor/Canvas.h | 7 ++- libs/cpPipelineEditor/Editor.cxx | 24 +++++++++ libs/cpPipelineEditor/Editor.h | 38 ++++++++++++++ libs/cpPipelineEditor/Editor.ui | 50 ++++++++++++++++++ libs/cpPipelineEditor/Panel.cxx | 69 +++++++++++++++++++++++++ libs/cpPipelineEditor/Panel.h | 37 +++++++++++++ 10 files changed, 332 insertions(+), 3 deletions(-) create mode 100644 libs/cpPipelineEditor/Block.cxx create mode 100644 libs/cpPipelineEditor/Block.h create mode 100644 libs/cpPipelineEditor/Editor.cxx create mode 100644 libs/cpPipelineEditor/Editor.h create mode 100644 libs/cpPipelineEditor/Editor.ui create mode 100644 libs/cpPipelineEditor/Panel.cxx create mode 100644 libs/cpPipelineEditor/Panel.h diff --git a/applis/PipelineEditor/PipelineEditor.ui b/applis/PipelineEditor/PipelineEditor.ui index 3709dba..ed03661 100644 --- a/applis/PipelineEditor/PipelineEditor.ui +++ b/applis/PipelineEditor/PipelineEditor.ui @@ -13,14 +13,26 @@ MainWindow - + + + + 0 + + + 0 + + + + + + 0 0 800 - 25 + 20 @@ -38,6 +50,14 @@ + + + cpPipelineEditor::Editor + QWidget +
cpPipelineEditor/Editor.h
+ 1 +
+
diff --git a/libs/cpPipelineEditor/Block.cxx b/libs/cpPipelineEditor/Block.cxx new file mode 100644 index 0000000..d750c9c --- /dev/null +++ b/libs/cpPipelineEditor/Block.cxx @@ -0,0 +1,43 @@ +#include +#include + +// ------------------------------------------------------------------------- +cpPipelineEditor::Block:: +Block( QGraphicsItem* parent, QGraphicsScene* scene ) + : Superclass( parent, scene ) +{ + this->m_SelectedColor = Qt::darkYellow; + this->m_NotSelectedColor = Qt::darkGreen; +} + +// ------------------------------------------------------------------------- +cpPipelineEditor::Block:: +~Block( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Block:: +paint( + QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget + ) +{ + Q_UNUSED( option ); + Q_UNUSED( widget ); + + if( this->isSelected( ) ) + { + painter->setPen( QPen( this->m_SelectedColor ) ); + painter->setBrush( this->m_SelectedColor ); + } + else + { + painter->setPen( QPen( this->m_NotSelectedColor ) ); + painter->setBrush( this->m_NotSelectedColor ); + + } // fi + painter->drawPath( this->path( ) ); + +} + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Block.h b/libs/cpPipelineEditor/Block.h new file mode 100644 index 0000000..a5fb8d0 --- /dev/null +++ b/libs/cpPipelineEditor/Block.h @@ -0,0 +1,39 @@ +#ifndef __cpPipelineEditor__Block__h__ +#define __cpPipelineEditor__Block__h__ + +#include +#include + +namespace cpPipelineEditor +{ + /** + */ + class cpPipelineEditor_EXPORT Block + : public QGraphicsPathItem + { + public: + typedef Block Self; + typedef QGraphicsPathItem Superclass; + + public: + Block( + QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL + ); + virtual ~Block( ); + + virtual void paint( + QPainter* painter, + const QStyleOptionGraphicsItem* option, + QWidget* widget + ) override; + + private: + QColor m_SelectedColor; + QColor m_NotSelectedColor; + }; + +} // ecapseman + +#endif // __cpPipelineEditor__Block__h__ + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Canvas.cxx b/libs/cpPipelineEditor/Canvas.cxx index 7ee861f..2a8023a 100644 --- a/libs/cpPipelineEditor/Canvas.cxx +++ b/libs/cpPipelineEditor/Canvas.cxx @@ -9,6 +9,10 @@ cpPipelineEditor::Canvas:: Canvas( QWidget* parent ) : Superclass( parent ) { + this->m_Scene = new QGraphicsScene( this ); + this->setScene( this->m_Scene ); + this->setRenderHint( QPainter::Antialiasing ); + this->setAcceptDrops( true ); } // ------------------------------------------------------------------------- diff --git a/libs/cpPipelineEditor/Canvas.h b/libs/cpPipelineEditor/Canvas.h index ec6c5f7..2cd7201 100644 --- a/libs/cpPipelineEditor/Canvas.h +++ b/libs/cpPipelineEditor/Canvas.h @@ -8,12 +8,14 @@ #include #include +class QGraphicsScene; + namespace cpPipelineEditor { /** */ class Canvas - : QGraphicsView + : public QGraphicsView { Q_OBJECT; @@ -24,6 +26,9 @@ namespace cpPipelineEditor public: Canvas( QWidget* parent = NULL ); virtual ~Canvas( ); + + protected: + QGraphicsScene* m_Scene; }; } // ecapseman diff --git a/libs/cpPipelineEditor/Editor.cxx b/libs/cpPipelineEditor/Editor.cxx new file mode 100644 index 0000000..e613246 --- /dev/null +++ b/libs/cpPipelineEditor/Editor.cxx @@ -0,0 +1,24 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#include +#include + +// ------------------------------------------------------------------------- +cpPipelineEditor::Editor:: +Editor( QWidget* parent ) + : Superclass( parent ), + m_UI( new Ui::Editor ) +{ + this->m_UI->setupUi( this ); +} + +// ------------------------------------------------------------------------- +cpPipelineEditor::Editor:: +~Editor( ) +{ + delete this->m_UI; +} + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Editor.h b/libs/cpPipelineEditor/Editor.h new file mode 100644 index 0000000..c2fd718 --- /dev/null +++ b/libs/cpPipelineEditor/Editor.h @@ -0,0 +1,38 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __cpPipelineEditor__Editor__h__ +#define __cpPipelineEditor__Editor__h__ + +#include +#include + +namespace Ui { class Editor; } + +namespace cpPipelineEditor +{ + /** + */ + class Editor + : public QWidget + { + Q_OBJECT; + + public: + typedef Editor Self; + typedef QWidget Superclass; + + public: + Editor( QWidget* parent = NULL ); + virtual ~Editor( ); + + private: + Ui::Editor* m_UI; + }; + +} // ecapseman + +#endif // __cpPipelineEditor__Editor__h__ + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Editor.ui b/libs/cpPipelineEditor/Editor.ui new file mode 100644 index 0000000..c4ae96b --- /dev/null +++ b/libs/cpPipelineEditor/Editor.ui @@ -0,0 +1,50 @@ + + + Editor + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + + + + + + + cpPipelineEditor::Canvas + QWidget +
cpPipelineEditor/Canvas.h
+ 1 +
+ + cpPipelineEditor::Panel + QWidget +
cpPipelineEditor/Panel.h
+ 1 +
+
+ + +
diff --git a/libs/cpPipelineEditor/Panel.cxx b/libs/cpPipelineEditor/Panel.cxx new file mode 100644 index 0000000..e86f061 --- /dev/null +++ b/libs/cpPipelineEditor/Panel.cxx @@ -0,0 +1,69 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#include + +// ------------------------------------------------------------------------- +cpPipelineEditor::Panel:: +Panel( QWidget* parent ) + : Superclass( parent ) +{ + this->setDragEnabled( true ); + this->setDragDropMode( QAbstractItemView::DragOnly ); + this->setAlternatingRowColors( true ); + + this->_update( ); +} + +// ------------------------------------------------------------------------- +cpPipelineEditor::Panel:: +~Panel( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Panel:: +_clear( ) +{ + this->clear( ); + this->setColumnCount( 1 ); + QString header_txt = "Loaded plugins"; + if( QTreeWidgetItem* header = this->headerItem( ) ) + header->setText( 0, header_txt ); + else + this->setHeaderLabel( header_txt ); +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Panel:: +_update( ) +{ + this->_clear( ); + + QTreeWidgetItem* n = NULL; + QTreeWidgetItem* filters = new QTreeWidgetItem( n, QStringList( "Filters" ) ); + QTreeWidgetItem* functors = new QTreeWidgetItem( n, QStringList( "Functors" ) ); + QTreeWidgetItem* widgets = new QTreeWidgetItem( n, QStringList( "Widgets" ) ); + + this->addTopLevelItem( filters ); + this->addTopLevelItem( functors ); + this->addTopLevelItem( widgets ); + + // Add filters + QTreeWidgetItem* test_filter = + new QTreeWidgetItem( filters, QStringList( "myFilter" ) ); + + // Add functors + QTreeWidgetItem* test_functor = + new QTreeWidgetItem( functors, QStringList( "myFunctor" ) ); + + // Add widgets + QTreeWidgetItem* test_widget = + new QTreeWidgetItem( widgets, QStringList( "myWidget" ) ); + + // Finish + this->expandAll( ); +} + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Panel.h b/libs/cpPipelineEditor/Panel.h new file mode 100644 index 0000000..f69187c --- /dev/null +++ b/libs/cpPipelineEditor/Panel.h @@ -0,0 +1,37 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __cpPipelineEditor__Panel__h__ +#define __cpPipelineEditor__Panel__h__ + +#include +#include + +namespace cpPipelineEditor +{ + /** + */ + class Panel + : public QTreeWidget + { + Q_OBJECT; + + public: + typedef Panel Self; + typedef QTreeWidget Superclass; + + public: + Panel( QWidget* parent = NULL ); + virtual ~Panel( ); + + protected: + void _clear( ); + void _update( ); + }; + +} // ecapseman + +#endif // __cpPipelineEditor__Panel__h__ + +// eof - $RCSfile$ -- 2.45.1