Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/GlMainView.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 
00020 #ifndef Tulip_GLMAINVIEW_H
00021 #define Tulip_GLMAINVIEW_H
00022 
00023 #include <tulip/ViewWidget.h>
00024 
00025 class QGraphicsProxyWidget;
00026 class QAction;
00027 class QRectF;
00028 
00029 namespace tlp {
00030 class GlOverviewGraphicsItem;
00031 class SceneConfigWidget;
00032 class SceneLayersConfigWidget;
00033 class GlMainWidget;
00034 class QuickAccessBar;
00035 
00036 /**
00037  * @ingroup Plugins
00038  *
00039  * @brief An abstract view that displays a GlMainWidget as its central widget.
00040  *
00041  * The GlMainView subclasses ViewWidget and always uses a GlMainWidget as the central widget of the panel. It also adds the following features:
00042  * @list
00043  * @li An overview of the scene that can be toggled on or off.
00044  * @li Some configuration widgets that modify the rendering parameters.
00045  * @li A quick access bar widget that allows the user to quickly modify some of the most used rendering parameters and graph properties (nodes color, edges display, etc)
00046  * @li The possibility to make snapshots of the current scene
00047  * @endlist
00048  *
00049  * Subclassing GlMainView means you will only want to display graphs in a single GlMainWidget. Switching the central widget can only be achieved from the ViewWidget class.
00050  *
00051  * @warning It is strongly unadvised to re-implement methods already implemented into tlp::View or tlp::ViewWidget. If you have to add custom behavior to those method, make sure to call the upper-class methods first:
00052  @code
00053  void MyView::setupWidget() { // Where MyView is a subclass of tlp::GlMainView
00054    GlMainView::setupWidget(); // call this first
00055    // insert custom behavior here
00056  }
00057  @endcode
00058 
00059  * @see tlp::ViewWidget
00060  */
00061 class TLP_QT_SCOPE GlMainView: public tlp::ViewWidget {
00062 
00063   Q_OBJECT
00064 
00065   tlp::GlMainWidget* _glMainWidget;
00066   tlp::GlOverviewGraphicsItem* _overviewItem;
00067   bool isOverviewVisible;
00068   QGraphicsProxyWidget* _quickAccessBarItem;
00069 
00070   QAction *_centerViewAction;
00071   QAction *_forceRedrawAction;
00072   QAction* _advAntiAliasingAction;
00073 
00074 protected :
00075 
00076   tlp::QuickAccessBar* _quickAccessBar;
00077   tlp::SceneConfigWidget* _sceneConfigurationWidget;
00078   tlp::SceneLayersConfigWidget* _sceneLayersConfigurationWidget;
00079 
00080 public:
00081 
00082   enum OverviewPosition {OVERVIEW_TOP_LEFT, OVERVIEW_TOP_RIGHT, OVERVIEW_BOTTOM_LEFT, OVERVIEW_BOTTOM_RIGHT};
00083 
00084   GlMainView();
00085   virtual ~GlMainView();
00086   tlp::GlMainWidget* getGlMainWidget() const;
00087   virtual QList<QWidget*> configurationWidgets() const;
00088   bool overviewVisible() const;
00089   QPixmap snapshot(const QSize &outputSize=QSize()) const;
00090 
00091   void setOverviewPosition(const OverviewPosition &position);
00092   OverviewPosition overviewPosition() const;
00093 
00094   void setUpdateOverview(bool updateOverview);
00095   bool updateOverview() const;
00096 
00097 public slots:
00098   /**
00099    * @brief Calls GlMainWidget::draw();
00100    */
00101   virtual void draw();
00102 
00103   /**
00104    * @brief Calls GlMainWidget::redraw();
00105    */
00106   void redraw();
00107 
00108   /**
00109    * @brief Calls GlMainWidget::redraw();
00110    */
00111   virtual void refresh();
00112 
00113   /**
00114    * @brief Force the overview to be redrawn. Since GlMainView already detects graph's modifications, this method should not be called manually to avoid extra rendering.
00115    */
00116   virtual void drawOverview(bool generatePixmap=true);
00117 
00118   /**
00119    * @brief Centers the scene's camera
00120    */
00121   virtual void centerView(bool graphChanged = false);
00122 
00123   /**
00124    * @brief Toggles the overview on or off
00125    */
00126   void setOverviewVisible(bool);
00127 
00128   /**
00129    * @brief Toggles the orthogonal projection on or off, then draws
00130    */
00131   void setViewOrtho(bool);
00132 
00133   /**
00134    * @brief Force the settings set in the configuration widgets to be re-applied.
00135    */
00136   void applySettings();
00137 
00138   /**
00139    * @brief Display a dialog that takes a snapshot of the current scene.
00140    */
00141   void openSnapshotDialog();
00142 
00143   void undoCallback();
00144 
00145   void setAntiAliasing(bool);
00146 
00147   void setAdvancedAntiAliasing(bool);
00148 
00149 
00150 protected slots:
00151   virtual void glMainViewDrawn(bool graphChanged);
00152   virtual void sceneRectChanged(const QRectF&);
00153   void setQuickAccessBarVisible(bool);
00154   void fillContextMenu(QMenu *menu,const QPointF &);
00155   void delayedCenterView();
00156 
00157 
00158 protected:
00159   virtual void setupWidget();
00160   bool quickAccessBarVisible() const;
00161   void assignNewGlMainWidget(GlMainWidget *glMainWidget,bool deleteOldGlMainWidget=true);
00162   bool eventFilter(QObject* obj, QEvent* event);
00163 
00164   tlp::GlOverviewGraphicsItem* overviewItem() const;
00165 
00166   OverviewPosition _overviewPosition;
00167 
00168   bool _updateOverview;
00169 
00170 };
00171 }
00172 
00173 #endif /* GLMAINVIEW_H_ */
 All Classes Files Functions Variables Enumerations Enumerator Properties