From ce8c3f6cf22d89f696c0cb0030abf7d9c9e56375 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 6 Apr 2017 21:11:07 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 9 +---- cmake/BaseConfig.cmake | 5 ++- cmake/KitwareTools.cmake | 4 +- cmake/Options.cmake | 5 --- cmake/QtTools.cmake | 26 +++++-------- libs/cpPipelineEditor/Block.cxx | 10 ++++- libs/cpPipelineEditor/Block.h | 2 +- libs/cpPipelineEditor/Canvas.cxx | 54 +++++++++++++++++++------- libs/cpPipelineEditor/Canvas.h | 4 ++ libs/cpPipelineEditor/FilterBlock.cxx | 19 +++++++++ libs/cpPipelineEditor/FilterBlock.h | 28 +++++++++++++ libs/cpPipelineEditor/FunctorBlock.cxx | 19 +++++++++ libs/cpPipelineEditor/FunctorBlock.h | 28 +++++++++++++ libs/cpPipelineEditor/WidgetBlock.cxx | 19 +++++++++ libs/cpPipelineEditor/WidgetBlock.h | 28 +++++++++++++ 15 files changed, 213 insertions(+), 47 deletions(-) delete mode 100644 cmake/Options.cmake create mode 100644 libs/cpPipelineEditor/FilterBlock.cxx create mode 100644 libs/cpPipelineEditor/FilterBlock.h create mode 100644 libs/cpPipelineEditor/FunctorBlock.cxx create mode 100644 libs/cpPipelineEditor/FunctorBlock.h create mode 100644 libs/cpPipelineEditor/WidgetBlock.cxx create mode 100644 libs/cpPipelineEditor/WidgetBlock.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f91016..c0d3111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,8 @@ SET(prj_NAME cpPlugins) SET(prj_MAJ_VERSION 1) SET(prj_MIN_VERSION 0) SET(prj_REL_VERSION 0) +SET(_subdirs applis libs) SET(_policies CMP0015 CMP0020 CMP0042) -SET( - _subdirs - applis - libs - ) ## ========================== ## == Some useful policies == @@ -38,9 +34,8 @@ SET(prj_SHORT_VERSION "${prj_MAJ_VERSION}") ## ===================================== INCLUDE(cmake/BaseConfig.cmake) -INCLUDE(cmake/Options.cmake) +INCLUDE(cmake/KitwareTools.cmake) INCLUDE(cmake/QtTools.cmake) -#INCLUDE(cmake/KitwareTools.cmake) INCLUDE(cmake/Functions.cmake) ## =========================== diff --git a/cmake/BaseConfig.cmake b/cmake/BaseConfig.cmake index d177604..515820d 100644 --- a/cmake/BaseConfig.cmake +++ b/cmake/BaseConfig.cmake @@ -33,7 +33,10 @@ INCLUDE(GenerateExportHeader) ## ================================================== IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR}) - MESSAGE(FATAL_ERROR "Building in the source tree is not allowed.") + MESSAGE( + FATAL_ERROR + "Building in the source tree is not allowed." + ) ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR}) ## ================================================= diff --git a/cmake/KitwareTools.cmake b/cmake/KitwareTools.cmake index b4493d2..a120bb2 100644 --- a/cmake/KitwareTools.cmake +++ b/cmake/KitwareTools.cmake @@ -3,9 +3,9 @@ # ====================== FIND_PACKAGE(ITK REQUIRED) -FIND_PACKAGE(VTK REQUIRED) - INCLUDE(${ITK_USE_FILE}) + +FIND_PACKAGE(VTK REQUIRED) INCLUDE(${VTK_USE_FILE}) # =================================================== diff --git a/cmake/Options.cmake b/cmake/Options.cmake deleted file mode 100644 index f2cc242..0000000 --- a/cmake/Options.cmake +++ /dev/null @@ -1,5 +0,0 @@ -## =============================== -## == Some configurable options == -## =============================== - -## eof - $RCSfile$ diff --git a/cmake/QtTools.cmake b/cmake/QtTools.cmake index 47a3dd4..3542144 100644 --- a/cmake/QtTools.cmake +++ b/cmake/QtTools.cmake @@ -6,22 +6,16 @@ OPTION(BUILD_QT4_COMPONENTS "Build Qt4-based code" OFF) IF(BUILD_QT4_COMPONENTS) FIND_PACKAGE(Qt4 REQUIRED) INCLUDE(${QT_USE_FILE}) - # SET( - # _modules - # vtkGUISupportQt - # ) - # FOREACH(_m ${_modules}) - # IF(NOT ${_m}_LOADED) - # MESSAGE(FATAL_ERROR "${_m} module is required but not available.") - # BREAK() - # ENDIF(NOT ${_m}_LOADED) - # ENDFOREACH(_m) - # SET( - # cpPlugins_Qt4_VTKWidget - # QVTKWidget - # CACHE STRING "Base Qt4-based vtkRenderWindow" - # ) - # MARK_AS_ADVANCED(CLEAR cpPlugins_Qt4_VTKWidget) + SET( + _modules + vtkGUISupportQt + ) + FOREACH(_m ${_modules}) + IF(NOT ${_m}_LOADED) + MESSAGE(FATAL_ERROR "${_m} module is required but not available.") + BREAK() + ENDIF(NOT ${_m}_LOADED) + ENDFOREACH(_m) ENDIF(BUILD_QT4_COMPONENTS) ## eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Block.cxx b/libs/cpPipelineEditor/Block.cxx index d750c9c..315b197 100644 --- a/libs/cpPipelineEditor/Block.cxx +++ b/libs/cpPipelineEditor/Block.cxx @@ -8,6 +8,15 @@ Block( QGraphicsItem* parent, QGraphicsScene* scene ) { this->m_SelectedColor = Qt::darkYellow; this->m_NotSelectedColor = Qt::darkGreen; + + QPainterPath p; + p.addRoundedRect( -50, -50, 50, 50, 5, 5 ); + + this->setPath( p ); + this->setPen( QPen( this->m_NotSelectedColor ) ); + this->setBrush( this->m_NotSelectedColor ); + this->setFlag( QGraphicsItem::ItemIsMovable ); + this->setFlag( QGraphicsItem::ItemIsSelectable ); } // ------------------------------------------------------------------------- @@ -37,7 +46,6 @@ paint( } // fi painter->drawPath( this->path( ) ); - } // eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/Block.h b/libs/cpPipelineEditor/Block.h index a5fb8d0..7e6fa25 100644 --- a/libs/cpPipelineEditor/Block.h +++ b/libs/cpPipelineEditor/Block.h @@ -27,7 +27,7 @@ namespace cpPipelineEditor QWidget* widget ) override; - private: + protected: QColor m_SelectedColor; QColor m_NotSelectedColor; }; diff --git a/libs/cpPipelineEditor/Canvas.cxx b/libs/cpPipelineEditor/Canvas.cxx index 2731246..0015421 100644 --- a/libs/cpPipelineEditor/Canvas.cxx +++ b/libs/cpPipelineEditor/Canvas.cxx @@ -2,7 +2,17 @@ // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) // ------------------------------------------------------------------------- + +#include + + + + + #include +#include +#include +#include #include #include @@ -24,6 +34,23 @@ cpPipelineEditor::Canvas:: { } +// ------------------------------------------------------------------------- +cpPipelineEditor::Block* cpPipelineEditor::Canvas:: +createBlock( const std::string& name ) +{ + QString str = name.c_str( ); + QStringList tokens = str.split( "@" ); + std::string block_type = tokens.back( ).toStdString( ); + Block* new_block = NULL; + if( block_type == "Filters" ) + new_block = new FilterBlock( NULL, this->m_Scene ); + else if( block_type == "Functors" ) + new_block = new FunctorBlock( NULL, this->m_Scene ); + else if( block_type == "Widgets" ) + new_block = new WidgetBlock( NULL, this->m_Scene ); + return( new_block ); +} + // ------------------------------------------------------------------------- void cpPipelineEditor::Canvas:: dragEnterEvent( QDragEnterEvent* event ) @@ -60,21 +87,20 @@ dropEvent( QDropEvent* event ) // Process dropped data QList< QTreeWidgetItem* > items = tree->selectedItems( ); - for( - QList< QTreeWidgetItem* >::const_iterator iIt = items.begin( ); - iIt != items.end( ); - ++iIt - ) + for( QTreeWidgetItem* item : items ) { - /* TODO - auto parent = ( *iIt )->parent( ); - if( parent != NULL ) - this->addFilter( - parent->text( 0 ).toStdString( ), - ( *iIt )->text( 0 ).toStdString( ), - p - ); - */ + std::string name = ""; + QTreeWidgetItem* p = item; + while( p != NULL ) + { + name += p->text( 0 ).toStdString( ) + "@"; + p = p->parent( ); + + } // elihw + name.resize( name.size( ) - 1 ); + + // Create block + Block* b = this->createBlock( name ); } // rof } diff --git a/libs/cpPipelineEditor/Canvas.h b/libs/cpPipelineEditor/Canvas.h index 373dcd8..512dc2f 100644 --- a/libs/cpPipelineEditor/Canvas.h +++ b/libs/cpPipelineEditor/Canvas.h @@ -12,6 +12,8 @@ class QGraphicsScene; namespace cpPipelineEditor { + class Block; + /** */ class Canvas @@ -27,6 +29,8 @@ namespace cpPipelineEditor Canvas( QWidget* parent = NULL ); virtual ~Canvas( ); + Block* createBlock( const std::string& name ); + protected: virtual void dragEnterEvent( QDragEnterEvent* event ) override; virtual void dragLeaveEvent( QDragLeaveEvent* event ) override; diff --git a/libs/cpPipelineEditor/FilterBlock.cxx b/libs/cpPipelineEditor/FilterBlock.cxx new file mode 100644 index 0000000..6ce8a87 --- /dev/null +++ b/libs/cpPipelineEditor/FilterBlock.cxx @@ -0,0 +1,19 @@ +#include +#include + +// ------------------------------------------------------------------------- +cpPipelineEditor::FilterBlock:: +FilterBlock( QGraphicsItem* parent, QGraphicsScene* scene ) + : Superclass( parent, scene ) +{ + this->m_SelectedColor = Qt::darkYellow; + this->m_NotSelectedColor = Qt::darkGreen; +} + +// ------------------------------------------------------------------------- +cpPipelineEditor::FilterBlock:: +~FilterBlock( ) +{ +} + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/FilterBlock.h b/libs/cpPipelineEditor/FilterBlock.h new file mode 100644 index 0000000..82e089a --- /dev/null +++ b/libs/cpPipelineEditor/FilterBlock.h @@ -0,0 +1,28 @@ +#ifndef __cpPipelineEditor__FilterBlock__h__ +#define __cpPipelineEditor__FilterBlock__h__ + +#include + +namespace cpPipelineEditor +{ + /** + */ + class cpPipelineEditor_EXPORT FilterBlock + : public Block + { + public: + typedef FilterBlock Self; + typedef Block Superclass; + + public: + FilterBlock( + QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL + ); + virtual ~FilterBlock( ); + }; + +} // ecapseman + +#endif // __cpPipelineEditor__FilterBlock__h__ + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/FunctorBlock.cxx b/libs/cpPipelineEditor/FunctorBlock.cxx new file mode 100644 index 0000000..407496d --- /dev/null +++ b/libs/cpPipelineEditor/FunctorBlock.cxx @@ -0,0 +1,19 @@ +#include +#include + +// ------------------------------------------------------------------------- +cpPipelineEditor::FunctorBlock:: +FunctorBlock( QGraphicsItem* parent, QGraphicsScene* scene ) + : Superclass( parent, scene ) +{ + this->m_SelectedColor = Qt::darkYellow; + this->m_NotSelectedColor = Qt::darkMagenta; +} + +// ------------------------------------------------------------------------- +cpPipelineEditor::FunctorBlock:: +~FunctorBlock( ) +{ +} + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/FunctorBlock.h b/libs/cpPipelineEditor/FunctorBlock.h new file mode 100644 index 0000000..aec5dfd --- /dev/null +++ b/libs/cpPipelineEditor/FunctorBlock.h @@ -0,0 +1,28 @@ +#ifndef __cpPipelineEditor__FunctorBlock__h__ +#define __cpPipelineEditor__FunctorBlock__h__ + +#include + +namespace cpPipelineEditor +{ + /** + */ + class cpPipelineEditor_EXPORT FunctorBlock + : public Block + { + public: + typedef FunctorBlock Self; + typedef Block Superclass; + + public: + FunctorBlock( + QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL + ); + virtual ~FunctorBlock( ); + }; + +} // ecapseman + +#endif // __cpPipelineEditor__FunctorBlock__h__ + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/WidgetBlock.cxx b/libs/cpPipelineEditor/WidgetBlock.cxx new file mode 100644 index 0000000..da976d3 --- /dev/null +++ b/libs/cpPipelineEditor/WidgetBlock.cxx @@ -0,0 +1,19 @@ +#include +#include + +// ------------------------------------------------------------------------- +cpPipelineEditor::WidgetBlock:: +WidgetBlock( QGraphicsItem* parent, QGraphicsScene* scene ) + : Superclass( parent, scene ) +{ + this->m_SelectedColor = Qt::darkYellow; + this->m_NotSelectedColor = Qt::darkBlue; +} + +// ------------------------------------------------------------------------- +cpPipelineEditor::WidgetBlock:: +~WidgetBlock( ) +{ +} + +// eof - $RCSfile$ diff --git a/libs/cpPipelineEditor/WidgetBlock.h b/libs/cpPipelineEditor/WidgetBlock.h new file mode 100644 index 0000000..6ccb6ca --- /dev/null +++ b/libs/cpPipelineEditor/WidgetBlock.h @@ -0,0 +1,28 @@ +#ifndef __cpPipelineEditor__WidgetBlock__h__ +#define __cpPipelineEditor__WidgetBlock__h__ + +#include + +namespace cpPipelineEditor +{ + /** + */ + class cpPipelineEditor_EXPORT WidgetBlock + : public Block + { + public: + typedef WidgetBlock Self; + typedef Block Superclass; + + public: + WidgetBlock( + QGraphicsItem* parent = NULL, QGraphicsScene* scene = NULL + ); + virtual ~WidgetBlock( ); + }; + +} // ecapseman + +#endif // __cpPipelineEditor__WidgetBlock__h__ + +// eof - $RCSfile$ -- 2.47.1