PropertyVisPlugin.hh 7.17 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
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.              *
Jan Möbius's avatar
Jan Möbius committed
39 40 41
*                                                                            *
\*===========================================================================*/

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

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

Jan Möbius's avatar
 
Jan Möbius committed
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>
Jan Möbius's avatar
 
Jan Möbius committed
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"
Jan Möbius's avatar
 
Jan Möbius committed
76

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

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

81
class PropertyVisPlugin : public QObject, BaseInterface, LoadSaveInterface, ToolboxInterface, KeyInterface, ScriptInterface, MouseInterface, PickingInterface, LoggingInterface
Jan Möbius's avatar
 
Jan Möbius committed
82 83 84
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
85
  Q_INTERFACES(LoadSaveInterface)
Jan Möbius's avatar
 
Jan Möbius committed
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)

Matthias Möller's avatar
Matthias Möller committed
93 94
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PropertyVis")

Jan Möbius's avatar
 
Jan Möbius committed
95
signals:
96 97
  void updateView() override;
  void updatedObject(int, const UpdateType&) override;
Jan Möbius's avatar
 
Jan Möbius committed
98

99 100
  void log(Logtype, QString) override;
  void log(QString) override;
Jan Möbius's avatar
 
Jan Möbius committed
101 102
  
  // ToolboxInterface
103
  void addToolbox( QString  _name  , QWidget* _widget ,QIcon* _icon) override;
Jan Möbius's avatar
 
Jan Möbius committed
104 105

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

  // Script Interface
  void getScriptingEngine( QScriptEngine*& _engine  ) override;
Jan Möbius's avatar
 
Jan Möbius committed
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;
Jan Möbius's avatar
 
Jan Möbius committed
117
  
118
  // LoadSaveInterface
119
  void objectDeleted( int _id ) override;
120

Jan Möbius's avatar
 
Jan Möbius committed
121
  // initialization functions
122 123
  void initializePlugin() override;
  void pluginsInitialized() override;
Jan Möbius's avatar
 
Jan Möbius committed
124 125 126 127 128 129

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

137
  /// Called when user selects a property.
Jan Möbius's avatar
 
Jan Möbius committed
138 139
  void propertySelectionChanged();

140
  /// Duplicates the selected properties.
Jan Möbius's avatar
 
Jan Möbius committed
141 142
  void slotDuplicateProperty();

143
  /// Removes the selected properties.
Jan Möbius's avatar
 
Jan Möbius committed
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); }

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

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


public :
Jan Möbius's avatar
 
Jan Möbius committed
157
  PropertyVisPlugin();
158
  ~PropertyVisPlugin() {}
Jan Möbius's avatar
 
Jan Möbius committed
159 160


161 162
  QString name() override { return (QString("Property Visualization")); }
  QString description( ) override { return (QString("Computes the PropertyVis of the the active Mesh")); }
Jan Möbius's avatar
 
Jan Möbius committed
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

Jan Möbius's avatar
 
Jan Möbius committed
174 175

private:
Jan Möbius's avatar
Jan Möbius committed
176
  ObjectListItemModel objectListItemModel_;
177 178

  PropertyModel* propertyModel_;
Jan Möbius's avatar
 
Jan Möbius committed
179 180 181 182 183 184 185 186 187 188
};

#if defined(INCLUDE_TEMPLATES) && !defined(PROPERTYVISPLUGIN_CC)
#define PROPERTYVISPLUGIN_TEMPLATES
#include "PropertyVisPluginT.cc"
#endif
//=============================================================================
#endif // PROPERTYVISPLUGIN_HH defined
//=============================================================================