]> Creatis software - cpPlugins.git/blobdiff - lib/cpBaseQtApplication/Pipeline/Canvas.h
yet another refactoring
[cpPlugins.git] / lib / cpBaseQtApplication / Pipeline / Canvas.h
diff --git a/lib/cpBaseQtApplication/Pipeline/Canvas.h b/lib/cpBaseQtApplication/Pipeline/Canvas.h
new file mode 100644 (file)
index 0000000..bdd487c
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef __cpBaseQtApplication__Pipeline__Canvas__h__
+#define __cpBaseQtApplication__Pipeline__Canvas__h__
+
+#include <cpBaseQtApplication_Export.h>
+#include <QtGui/QGraphicsView>
+#include <cpPlugins/Interface/Workspace.h>
+
+class QGraphicsScene;
+
+namespace cpBaseQtApplication
+{
+  namespace Pipeline
+  {
+    // Some other forward declarations
+    class EventFilter;
+    class Block;
+    class Connection;
+
+    /**
+     */
+    class cpBaseQtApplication_EXPORT Canvas
+      : public QGraphicsView
+    {
+      Q_OBJECT;
+
+    public:
+      typedef Canvas        Self;
+      typedef QGraphicsView Superclass;
+      typedef cpPlugins::Interface::Workspace TWorkspace;
+
+    public:
+      Canvas( QWidget* parent = 0 );
+      virtual ~Canvas( );
+
+      void clear( );
+
+      TWorkspace* workspace( );
+      const TWorkspace* workspace( ) const;
+      void setWorkspace( TWorkspace* ws );
+
+      std::string addFilter(
+        const std::string& cat, const std::string& fil,
+        const QPointF& pos = QPointF( 0, 0 )
+        );
+      bool connectOutputPortSlot( QObject* receiver, const char* slot );
+
+      void rename( QGraphicsItem* item );
+      void exposePort( QGraphicsItem* item );
+      void moveConnection( const QPointF& pnt );
+      void grab( const QPointF& pnt );
+      void release( const QPointF& pnt );
+
+    protected:
+      void keyPressEvent( QKeyEvent* event );
+      void wheelEvent( QWheelEvent* event );
+
+      void dragEnterEvent( QDragEnterEvent* event );
+      void dragLeaveEvent( QDragLeaveEvent* event );
+      void dragMoveEvent( QDragMoveEvent* event );
+      void dropEvent( QDropEvent* event );
+
+      void _scaleView( qreal scaleFactor );
+      void _redrawWorkspace( );
+
+    protected:
+      QGraphicsScene* m_Scene;
+      EventFilter* m_EventFilter;
+      TWorkspace*  m_Workspace;
+      std::map< std::string, Block* > m_Blocks;
+
+      Connection* m_ActualConnection;
+
+      QObject* m_OutputPortReceiver;
+      std::string m_OutputPortSlot;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __cpBaseQtApplication__Pipeline__Canvas__h__
+
+// eof - $RCSfile$