PropertyVisPlugin.hh 7.18 KB
Newer Older
1 2 3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
39 40 41
*                                                                            *
\*===========================================================================*/

Jan Möbius's avatar
Jan Möbius committed
42

43

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
//=============================================================================
//
//  CLASS PropertyVisPlugin
//
//=============================================================================


#ifndef PROPERTYVISPLUGIN_HH
#define PROPERTYVISPLUGIN_HH


//== INCLUDES =================================================================

#include <QObject>
#include <QMenuBar>
#include <QSpinBox>
#include <QFile>
#include <QTextStream>
#include <vector>

#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
66
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
67 68 69 70 71 72 73
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/MouseInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>

Jan Möbius's avatar
Jan Möbius committed
74
#include "Toolbars/PropertyVisToolbar.hh"
Jan Möbius's avatar
Jan Möbius committed
75
#include "Models/ObjectListItemModel.hh"
76

Jan Möbius's avatar
Jan Möbius committed
77
#include "Models/PropertyModel.hh"
78 79 80

//== CLASS DEFINITION =========================================================

81
class PropertyVisPlugin : public QObject, BaseInterface, LoadSaveInterface, ToolboxInterface, KeyInterface, ScriptInterface, MouseInterface, PickingInterface, LoggingInterface
82 83 84
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
85
  Q_INTERFACES(LoadSaveInterface)
86 87 88 89 90 91 92
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(KeyInterface)
  Q_INTERFACES(ScriptInterface)
  Q_INTERFACES(MouseInterface)
  Q_INTERFACES(PickingInterface)
  Q_INTERFACES(LoggingInterface)

93 94
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PropertyVis")

95
signals:
96 97
  void updateView() override;
  void updatedObject(int, const UpdateType&) override;
98

99 100
  void log(Logtype, QString) override;
  void log(QString) override;
101 102
  
  // ToolboxInterface
103
  void addToolbox( QString  _name  , QWidget* _widget ,QIcon* _icon) override;
104 105

  //PickingInterface
106
  void addHiddenPickMode( const std::string& _mode ) override;
107 108 109

  // Script Interface
  void getScriptingEngine( QScriptEngine*& _engine  ) override;
110 111 112 113

private slots:

  // BaseInterface
114
  void slotObjectUpdated( int _identifier, const UpdateType& _type ) override;
115
  void slotObjectPropertiesChanged( int _identifier) override;
116
  void slotAllCleared() override;
117
  
118
  // LoadSaveInterface
119
  void objectDeleted( int _id ) override;
120

121
  // initialization functions
122 123
  void initializePlugin() override;
  void pluginsInitialized() override;
124 125 126 127 128 129

  // toolbox slots
  void slotMeshChanged(int _index = -1);
  void slotVisualize();
  
  // MouseInterface
130
  void slotMouseEvent( QMouseEvent* _event ) override;
131 132
  
  //PickingInterface
133
  void slotPickModeChanged( const std::string& _mode) override;
134 135 136
  
  void updateGUI();

137
  /// Called when user selects a property.
138 139
  void propertySelectionChanged();

140
  /// Duplicates the selected properties.
141 142
  void slotDuplicateProperty();

143
  /// Removes the selected properties.
144 145
  void slotRemoveProperty();

146 147 148 149
  /// Receives log messages from PropertyModels and emits them
  void slotLog(Logtype _type, QString _message){ emit log(_type, _message); }
  void slotLog(QString _message){ emit log(_message); }

150

151 152 153 154 155 156
public slots:
  void slotVisualizeProperty( int _id, const QString& _propname );
  QScriptValue getPropertyVisualizer( int _id, const QString& _propname );


public :
157
  PropertyVisPlugin();
158
  ~PropertyVisPlugin() {}
159 160


161 162
  QString name() override { return (QString("Property Visualization")); }
  QString description( ) override { return (QString("Computes the PropertyVis of the the active Mesh")); }
163 164 165 166 167 168 169 170


private :
  // Widget for Toolbox
  PropertyVisToolbar* tool_;

private:

171 172
  /// Exchanges the PropertyModel after the user selected a different object.
  void setNewPropertyModel(int id);
173

174 175

private:
176
  ObjectListItemModel objectListItemModel_;
177 178

  PropertyModel* propertyModel_;
179 180 181 182
};

#if defined(INCLUDE_TEMPLATES) && !defined(PROPERTYVISPLUGIN_CC)
#define PROPERTYVISPLUGIN_TEMPLATES
183
#include "PropertyVisPluginT_impl.hh"
184 185 186 187 188
#endif
//=============================================================================
#endif // PROPERTYVISPLUGIN_HH defined
//=============================================================================