Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SingleObjectPropertyModel.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 /*===========================================================================*\
43 * *
44 * $Revision: 21016 $ *
45 * $LastChangedBy: schultz $ *
46 * $Date: 2015-07-16 16:48:42 +0200 (Thu, 16 Jul 2015) $ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef SINGLE_OBJECT_PROPERTY_MODEL_H
51 #define SINGLE_OBJECT_PROPERTY_MODEL_H
52
53 #include "PropertyModel.hh"
54 #include "PropertyVisualizer.hh"
55
56 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
57 #include <OpenFlipper/BasePlugin/PickingInterface.hh>
58 #include <OpenFlipper/BasePlugin/MouseInterface.hh>
59
60 #include <vector>
61 #include <iostream>
62 #include <set>
63 #include <typeinfo>
64
65 #include <QPushButton>
66
67 #include <Widgets/VectorWidget.hh>
68
69
80 class SingleObjectPropertyModel: public PropertyModel
81 {
82 Q_OBJECT
83
84 signals:
85 void log(Logtype _type, QString _message);
86 void log(QString _message);
87
88 private slots:
89 void slotLog(Logtype _type, QString _message){ emit log(_type, _message); }
90 void slotLog(QString _message){ emit log(_message);}
91
92 public:
93 virtual void pickModeChanged(const std::string& _mode) {}
94 virtual void mouseEvent(QMouseEvent* _event) {}
95
96 SingleObjectPropertyModel(QObject *parent = 0);
97 virtual ~SingleObjectPropertyModel();
98
99 virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
100 virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
101 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
102
104 virtual void objectUpdated();
105
107 virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets = QWidgetList());
108
110 virtual void removeProperty(QModelIndexList selectedIndices);
111
113 virtual void duplicateProperty(QModelIndexList selectedIndices);
114
116 virtual void gatherProperties(){ /* implemented by subclass */ }
117
119 virtual void clear(QModelIndexList selectedIndices);
120
122 inline void hideWidget() { widgets->hide(); }
123
125 inline QWidget* getWidget() { return widgets; }
126
128 virtual void updateWidget(const QModelIndexList& selectedIndices);
129
131 void connectLogs(PropertyVisualizer* propViz);
132
134 virtual PropertyInfo getPropertyInfo(const QModelIndex index) const;
135
136
137 protected:
138
140 PropertyVisualizer* getPropertyVisualizer(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo);
141
143 bool isPropertyFree(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo);
144
145
147 QString getLoadFilename();
148
150 virtual QString getLoadFilenameFilter();
151
153 QString getSaveFilename(unsigned int propId);
154
156 virtual QString getSaveFilenameFilter(unsigned int propId);
157
159 virtual QString getDefaultSaveFilename(unsigned int propId);
160
162 void openFile(QString _filename, QFile &file_, QTextStream *&file_stream_);
163
165 void closeFile(QFile& file_, QTextStream*& file_stream_);
166
168 QString readLine(QTextStream *file_stream_);
169
171 void writeLine(QString _s, QTextStream *&file_stream_);
172
173
175 void saveProperty(unsigned int propId);
176
178 void loadProperty();
179
181 virtual void setPropertyFromFile(QTextStream*& file_stream_, unsigned int n, PropertyVisualizer *propVis);
182
194 virtual bool parseHeader(QString header, PropertyVisualizer*& propVis, unsigned int& n){ return false; }
195
196 protected:
197 std::vector<PropertyVisualizer*> propertyVisualizers;
198 QWidget* widgets;
199 QModelIndexList currentlySelectedIndices;
200 std::vector<unsigned int> currentlyVisualizedIndices;
201 };
202
203 #endif /* SINGLE_OBJECT_PROPERTY_MODEL_H */
SingleObjectPropertyModel
This class manages the visualizers for a single object.
Definition: SingleObjectPropertyModel.hh:80
SingleObjectPropertyModel::getPropertyVisualizer
PropertyVisualizer * getPropertyVisualizer(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Returns a PropertyVisualizer.
Definition: SingleObjectPropertyModel.cc:362
SingleObjectPropertyModel::clear
virtual void clear(QModelIndexList selectedIndices)
Clears the selected property visualization.
Definition: SingleObjectPropertyModel.cc:137
SingleObjectPropertyModel::readLine
QString readLine(QTextStream *file_stream_)
Read line from a file.
Definition: SingleObjectPropertyModel.cc:278
PropertyVisualizer
This class vizualizes a property.
Definition: PropertyVisualizer.hh:80
PropertyModel
Definition: PropertyModel.hh:59
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:103
SingleObjectPropertyModel::getWidget
QWidget * getWidget()
Returns the widget.
Definition: SingleObjectPropertyModel.hh:125
SingleObjectPropertyModel::getSaveFilename
QString getSaveFilename(unsigned int propId)
Asks the user for a file to load.
Definition: SingleObjectPropertyModel.cc:218
SingleObjectPropertyModel::connectLogs
void connectLogs(PropertyVisualizer *propViz)
Connects the PropertyVisualizer log signals with the log slot.
Definition: SingleObjectPropertyModel.cc:166
SingleObjectPropertyModel::loadProperty
void loadProperty()
Loads property.
Definition: SingleObjectPropertyModel.cc:324
SingleObjectPropertyModel::getLoadFilename
QString getLoadFilename()
Asks the user for a file to load.
Definition: SingleObjectPropertyModel.cc:203
SingleObjectPropertyModel::getDefaultSaveFilename
virtual QString getDefaultSaveFilename(unsigned int propId)
Returns the default file name.
Definition: SingleObjectPropertyModel.cc:235
TypeInfoWrapper
Wraps the information of a type.
Definition: Utils.hh:79
SingleObjectPropertyModel::visualize
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList())
Visualizes the selected properties.
Definition: SingleObjectPropertyModel.cc:74
SingleObjectPropertyModel::saveProperty
void saveProperty(unsigned int propId)
Saves property.
Definition: SingleObjectPropertyModel.cc:298
SingleObjectPropertyModel::updateWidget
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
Definition: SingleObjectPropertyModel.cc:146
SingleObjectPropertyModel::getSaveFilenameFilter
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.
Definition: SingleObjectPropertyModel.cc:228
SingleObjectPropertyModel::isPropertyFree
bool isPropertyFree(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Checks if the property name is still available.
Definition: SingleObjectPropertyModel.cc:373
MouseInterface.hh
SingleObjectPropertyModel::setPropertyFromFile
virtual void setPropertyFromFile(QTextStream *&file_stream_, unsigned int n, PropertyVisualizer *propVis)
Sets the property values from a given file.
Definition: SingleObjectPropertyModel.cc:353
SingleObjectPropertyModel::objectUpdated
virtual void objectUpdated()
Revisualizes visualized properties.
Definition: SingleObjectPropertyModel.cc:195
SingleObjectPropertyModel::duplicateProperty
virtual void duplicateProperty(QModelIndexList selectedIndices)
Duplicates the selected properties.
Definition: SingleObjectPropertyModel.cc:131
SingleObjectPropertyModel::getLoadFilenameFilter
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
Definition: SingleObjectPropertyModel.cc:213
SingleObjectPropertyModel::hideWidget
void hideWidget()
Hides the widget.
Definition: SingleObjectPropertyModel.hh:122
SingleObjectPropertyModel::getPropertyInfo
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const
Returns the property info for the property with the given index.
Definition: SingleObjectPropertyModel.cc:378
SingleObjectPropertyModel::parseHeader
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
Definition: SingleObjectPropertyModel.hh:194
SingleObjectPropertyModel::closeFile
void closeFile(QFile &file_, QTextStream *&file_stream_)
Closes a file.
Definition: SingleObjectPropertyModel.cc:265
PickingInterface.hh
BaseInterface.hh
SingleObjectPropertyModel::removeProperty
virtual void removeProperty(QModelIndexList selectedIndices)
Removes the selected properties.
Definition: SingleObjectPropertyModel.cc:96
SingleObjectPropertyModel::openFile
void openFile(QString _filename, QFile &file_, QTextStream *&file_stream_)
Opens a file.
Definition: SingleObjectPropertyModel.cc:257
SingleObjectPropertyModel::gatherProperties
virtual void gatherProperties()
Searches for properties and creates PropertyVisualizers.
Definition: SingleObjectPropertyModel.hh:116
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:115
SingleObjectPropertyModel::writeLine
void writeLine(QString _s, QTextStream *&file_stream_)
Writes a line to a file.
Definition: SingleObjectPropertyModel.cc:289