PropertyVisPlugin.hh 7.66 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
42
43
44
45
46
47
48
49
*                                                                            *
\*===========================================================================*/

/*===========================================================================*\
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
\*===========================================================================*/

Jan Möbius's avatar
 
Jan Möbius committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//=============================================================================
//
//  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>
72
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
Jan Möbius's avatar
 
Jan Möbius committed
73
74
75
76
77
78
79
80
81
82
#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>

#include "PropertyVisToolbar.hh"
#include "ObjectListItemModel.hh"

83
#include "PropertyModel.hh"
Jan Möbius's avatar
 
Jan Möbius committed
84
85
86

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

87
class PropertyVisPlugin : public QObject, BaseInterface, LoadSaveInterface, ToolboxInterface, KeyInterface, ScriptInterface, MouseInterface, PickingInterface, LoggingInterface
Jan Möbius's avatar
 
Jan Möbius committed
88
89
90
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
91
  Q_INTERFACES(LoadSaveInterface)
Jan Möbius's avatar
 
Jan Möbius committed
92
93
94
95
96
97
98
  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
99
100
101
102
#if QT_VERSION >= 0x050000
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PropertyVis")
#endif

Jan Möbius's avatar
 
Jan Möbius committed
103
signals:
104
105
  void updateView() override;
  void updatedObject(int, const UpdateType&) override;
Jan Möbius's avatar
 
Jan Möbius committed
106

107
108
  void log(Logtype, QString) override;
  void log(QString) override;
Jan Möbius's avatar
 
Jan Möbius committed
109
110
  
  // ToolboxInterface
111
  void addToolbox( QString  _name  , QWidget* _widget ,QIcon* _icon) override;
Jan Möbius's avatar
 
Jan Möbius committed
112
113

  //PickingInterface
114
  void addHiddenPickMode( const std::string& _mode ) override;
115
116
117

  // Script Interface
  void getScriptingEngine( QScriptEngine*& _engine  ) override;
Jan Möbius's avatar
 
Jan Möbius committed
118
119
120
121

private slots:

  // BaseInterface
122
  void slotObjectUpdated( int _identifier, const UpdateType& _type ) override;
123
  void slotObjectPropertiesChanged( int _identifier) override;
124
  void slotAllCleared() override;
Jan Möbius's avatar
 
Jan Möbius committed
125
  
126
  // LoadSaveInterface
127
  void objectDeleted( int _id ) override;
128

Jan Möbius's avatar
 
Jan Möbius committed
129
  // initialization functions
130
131
  void initializePlugin() override;
  void pluginsInitialized() override;
Jan Möbius's avatar
 
Jan Möbius committed
132
133
134
135
136
137

  // toolbox slots
  void slotMeshChanged(int _index = -1);
  void slotVisualize();
  
  // MouseInterface
138
  void slotMouseEvent( QMouseEvent* _event ) override;
Jan Möbius's avatar
 
Jan Möbius committed
139
140
  
  //PickingInterface
141
  void slotPickModeChanged( const std::string& _mode) override;
Jan Möbius's avatar
 
Jan Möbius committed
142
143
144
  
  void updateGUI();

145
  /// Called when user selects a property.
Jan Möbius's avatar
 
Jan Möbius committed
146
147
  void propertySelectionChanged();

148
  /// Duplicates the selected properties.
Jan Möbius's avatar
 
Jan Möbius committed
149
150
  void slotDuplicateProperty();

151
  /// Removes the selected properties.
Jan Möbius's avatar
 
Jan Möbius committed
152
153
  void slotRemoveProperty();

154
155
156
157
  /// 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
158

159
160
161
162
163
164
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
165
  PropertyVisPlugin();
166
  ~PropertyVisPlugin() {}
Jan Möbius's avatar
 
Jan Möbius committed
167
168


169
170
  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
171
172
173
174
175
176
177
178


private :
  // Widget for Toolbox
  PropertyVisToolbar* tool_;

private:

179
180
  /// Exchanges the PropertyModel after the user selected a different object.
  void setNewPropertyModel(int id);
181

Jan Möbius's avatar
 
Jan Möbius committed
182
183

private:
Jan Möbius's avatar
Jan Möbius committed
184
  ObjectListItemModel objectListItemModel_;
185
186

  PropertyModel* propertyModel_;
Jan Möbius's avatar
 
Jan Möbius committed
187
188
189
190
191
192
193
194
195
196
};

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