Developer Documentation

ComponentsPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 #ifndef COMPONENTSPLUGIN_HH
43 #define COMPONENTSPLUGIN_HH
44
45 #include <QObject>
46
47 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
48 #include <OpenFlipper/BasePlugin/MouseInterface.hh>
49 #include <OpenFlipper/BasePlugin/PickingInterface.hh>
50 #include <OpenFlipper/BasePlugin/BackupInterface.hh>
51 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
52 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
53 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
54 #include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
55 #include <OpenFlipper/common/Types.hh>
56 #include <ObjectTypes/PolyMesh/PolyMesh.hh>
57 #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
58
59 class ComponentsPlugin : public QObject, BaseInterface, MouseInterface, PickingInterface, LoggingInterface, BackupInterface, LoadSaveInterface, ToolbarInterface,ScriptInterface
60 {
61 Q_OBJECT
62 Q_INTERFACES( BaseInterface )
63 Q_INTERFACES( MouseInterface )
64 Q_INTERFACES( PickingInterface )
65 Q_INTERFACES( LoggingInterface )
66 Q_INTERFACES( BackupInterface )
67 Q_INTERFACES( LoadSaveInterface )
68 Q_INTERFACES( ToolbarInterface )
69 Q_INTERFACES( ScriptInterface )
70
71
72 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Components")
73
74 signals:
75 // BaseInterface
76 void updateView();
77 void updatedObject(int _identifier, const UpdateType& _type);
78 void setSlotDescription(QString _slotName, QString _slotDescription,
79 QStringList _parameters, QStringList _descriptions);
80
81 // LoadSaveInterface
82 void addEmptyObject( DataType _type, int& _id);
83 void copyObject( int _oldId, int& _newId);
84
85 // ToolBarInterface
86 void addToolbar(QToolBar* _toolbar);
87 void getToolBar( QString _name, QToolBar*& _toolbar);
88
89 // PickingInterface
90 void addPickMode( const std::string& _mode);
91
92 //ScriptInterface
93 void scriptInfo( QString _functionName );
94
95 // LoggingInterface
96 void log( Logtype _type, QString _message );
97 void log( QString _message );
98
99 // BackupInterface
100 void createBackup( int _objectid, QString _name, UpdateType _type);
101
102 // LoadSaveInterface
103 void deleteObject( int _id );
104
105 private slots:
106
107 // BaseInterface
108 void initializePlugin();
109 void noguiSupported(){};
110 void pluginsInitialized();
111
112 // PickingInterface
113 void slotPickModeChanged( const std::string& _mode);
114
115 // MouseInterface:
116 void slotMouseEvent( QMouseEvent* _event );
117
118 public:
119 ComponentsPlugin();
120 ~ComponentsPlugin() { }
121
122 void exit() {}
123
124 QString name() { return (QString("Components")); };
125 QString description( ) { return (QString("Handle mesh components")); };
126
127
128 //===========================================================================
131 //===========================================================================
132
133 private slots:
134
136 void slotSplitComponentsButton();
137
138 void slotBiggestComponentButton();
139
141 void splitComponents(QMouseEvent* _event);
142
143 void biggestComponent(QMouseEvent* _event);
144
145 private :
146 //toolbar
147 QAction* splitAction_;
148 QAction* biggestAction_;
149
152 //===========================================================================
155 //===========================================================================
156
166 template< class MeshT >
167 void splitComponent( MeshT* _mesh, MeshT* _copy);
168
175 template< class MeshT >
176 void selectBiggestComponent( MeshT* _mesh);
177
185 template< class MeshT >
186 void deleteUnselectedFaces( MeshT* _mesh);
187
190 //===========================================================================
193 //===========================================================================
194
195 public slots:
196
197
204 IdList splitComponents( int _objectId );
205
206
213 void biggestComponent(int _objId);
214
217 public slots:
218 QString version() { return QString("1.0"); };
219
220 private:
222 void setDescriptions();
223 };
224
225 #if defined(INCLUDE_TEMPLATES) && !defined(COMPONENTSPLUGIN_CC)
226 #define COMPONENTSPLUGIN_TEMPLATES
227 #include "ComponentsPluginT_impl.hh"
228 #endif
229 //=============================================================================
230 #endif //CUTPLUGIN_HH
231 //=============================================================================
ComponentsPlugin
Definition: ComponentsPlugin.hh:59
ScriptInterface.hh
ComponentsPlugin::splitComponent
void splitComponent(MeshT *_mesh, MeshT *_copy)
Split mesh into components.
Definition: ComponentsPluginT_impl.hh:55
ComponentsPlugin::ComponentsPlugin
ComponentsPlugin()
Constructor.
Definition: ComponentsPlugin.cc:53
ComponentsPlugin::selectBiggestComponent
void selectBiggestComponent(MeshT *_mesh)
Select the biggest component of the mesh.
Definition: ComponentsPluginT_impl.hh:117
ComponentsPlugin::initializePlugin
void initializePlugin()
Initialize the plugin.
Definition: ComponentsPlugin.cc:64
ComponentsPlugin::exit
void exit()
Definition: ComponentsPlugin.hh:122
LoadSaveInterface.hh
ToolbarInterface
Add a toolbox to OpenFlipper.
Definition: ToolbarInterface.hh:62
MouseInterface
Interface class for receiving mouse events.
Definition: MouseInterface.hh:61
ComponentsPlugin::biggestComponent
void biggestComponent(QMouseEvent *_event)
Split into Components Button was hit.
Definition: ComponentsPlugin.cc:180
ComponentsPlugin::splitComponents
void splitComponents(QMouseEvent *_event)
Split Components of picked object.
Definition: ComponentsPlugin.cc:153
ComponentsPlugin::deleteUnselectedFaces
void deleteUnselectedFaces(MeshT *_mesh)
Deletes all faces of a mesh that are not selected.
Definition: ComponentsPluginT_impl.hh:167
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
MouseInterface.hh
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
PickingInterface.hh
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
ComponentsPlugin::setDescriptions
void setDescriptions()
set scripting slot descriptions
Definition: ComponentsScripting.cc:51
ComponentsPlugin::biggestAction_
QAction * biggestAction_
Split into Components Button was hit.
Definition: ComponentsPlugin.hh:148
LoggingInterface.hh
IdList
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
ToolbarInterface.hh
TriangleMesh.hh
ComponentsPlugin::splitAction_
QAction * splitAction_
Split into Components Button was hit.
Definition: ComponentsPlugin.hh:147
ComponentsPlugin::slotMouseEvent
void slotMouseEvent(QMouseEvent *_event)
a mouse event occured
Definition: ComponentsPlugin.cc:125
ComponentsPlugin::slotPickModeChanged
void slotPickModeChanged(const std::string &_mode)
the pickMode changed
Definition: ComponentsPlugin.cc:112
ComponentsPlugin::name
QString name()
Return a name for the plugin.
Definition: ComponentsPlugin.hh:124
ComponentsPlugin::slotSplitComponentsButton
void slotSplitComponentsButton()
Split into Components Button was hit.
Definition: ComponentsPlugin.cc:140
UpdateType
Update type class.
Definition: UpdateType.hh:60
PolyMesh.hh
ComponentsPlugin::pluginsInitialized
void pluginsInitialized()
Second initialization phase.
Definition: ComponentsPlugin.cc:73
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
Types.hh
ComponentsPlugin::slotBiggestComponentButton
void slotBiggestComponentButton()
Split into Components Button was hit.
Definition: ComponentsPlugin.cc:174
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
BaseInterface.hh
ComponentsPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: ComponentsPlugin.hh:125
PickingInterface
Allow access to picking functions.
Definition: PickingInterface.hh:62
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:59
BackupInterface.hh
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:59