52 #include "PropertyVisPlugin.hh" 54 #include "Models/PropertyModelFactory.hh" 55 #include "Models/SingleObjectPropertyModel.hh" 57 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT 60 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT 63 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 69 #define PROP_VIS "PropertyVisualization" 71 PropertyVisPlugin::PropertyVisPlugin() :
77 void PropertyVisPlugin::initializePlugin()
79 if ( OpenFlipper::Options::gui() ) {
85 tool_->meshNames->setModel(&objectListItemModel_);
87 emit addHiddenPickMode( PROP_VIS );
89 QIcon* toolIcon =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"PropertyVisIcon.png");
91 emit addToolbox( tr(
"Property Visualization") , tool_, toolIcon );
97 void PropertyVisPlugin::pluginsInitialized()
99 if ( OpenFlipper::Options::gui() ) {
102 connect(tool_->meshNames, SIGNAL( currentIndexChanged(
int) ),
this, SLOT( slotMeshChanged(
int) ) );
104 connect(tool_->visualizeButton, SIGNAL( clicked() ),
this, SLOT( slotVisualize() ) );
105 connect(tool_->clearButton, SIGNAL( clicked() ),
this, SLOT( slotAllCleared() ) );
107 connect(tool_->refresh_property_names_tb, SIGNAL( clicked() ),
this, SLOT( slotMeshChanged() ) );
108 connect(tool_->duplicate_property_tb, SIGNAL( clicked() ),
this, SLOT( slotDuplicateProperty() ) );
109 connect(tool_->remove_property_tb, SIGNAL( clicked() ),
this, SLOT( slotRemoveProperty() ) );
111 connect(tool_, SIGNAL( widgetShown() ),
this, SLOT( updateGUI() ) );
113 setNewPropertyModel(-1);
130 QModelIndexList list;
153 QModelIndexList list;
164 QScriptValue PropertyVisPlugin::getPropertyVisualizer(
int _id,
const QString &_propname)
168 if (model ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
172 if (!idx.isValid()) {
return QScriptValue::SpecialValue::NullValue; }
174 QScriptEngine *engine;
175 emit getScriptingEngine (engine);
176 if (engine ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
178 QScriptContext *ctx = engine->currentContext();
179 if (ctx ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
182 if (!sopm) {
return QScriptValue::SpecialValue::NullValue; }
189 void PropertyVisPlugin::slotPickModeChanged(
const std::string& _mode)
191 if (propertyModel_ != 0)
192 propertyModel_->pickModeChanged(_mode);
197 void PropertyVisPlugin::slotAllCleared()
201 if (propertyModel_ != 0)
203 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
204 propertyModel_->clear(selectedIndices);
205 propertyModel_->objectUpdated();
212 void PropertyVisPlugin::objectDeleted(
int _id)
214 if( OpenFlipper::Options::gui() )
215 objectListItemModel_.removeObject(_id);
221 void PropertyVisPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type )
223 if( OpenFlipper::Options::gui() )
225 if ( tool_->isVisible() )
238 void PropertyVisPlugin::slotObjectPropertiesChanged(
int _identifier)
241 if( OpenFlipper::Options::gui() && tool_->isVisible() )
247 void PropertyVisPlugin::updateGUI()
250 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT 253 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT 256 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 259 objectListItemModel_.refresh(datatype);
266 if (propertyModel_ != 0)
268 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
269 propertyModel_->updateWidget(selectedIndices);
288 propertyModel_->hideWidget();
289 disconnect(propertyModel_, SIGNAL(log(
Logtype,QString)),
this, SLOT(slotLog(
Logtype,QString)));
290 disconnect(propertyModel_, SIGNAL(log(QString)),
this, SLOT(slotLog(QString)));
293 if (propertyModel_ != 0)
296 tool_->propertyName_lv->setModel(propertyModel_);
297 connect(propertyModel_, SIGNAL( modelReset() ),
this, SLOT( propertySelectionChanged() ));
298 connect(tool_->propertyName_lv->selectionModel(),
299 SIGNAL( selectionChanged(
const QItemSelection &,
const QItemSelection &) ),
301 SLOT( propertySelectionChanged() ));
302 QWidget* widget = propertyModel_->getWidget();
303 tool_->propertyWidgets->addWidget(widget);
305 propertyModel_->gatherProperties();
306 connect(propertyModel_, SIGNAL(log(
Logtype,QString)),
this, SLOT(slotLog(
Logtype,QString)));
307 connect(propertyModel_, SIGNAL(log(QString)),
this, SLOT(slotLog(QString)));
311 tool_->propertyName_lv->setModel(0);
317 void PropertyVisPlugin::slotMeshChanged(
int )
319 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
320 setNewPropertyModel(
id);
325 void PropertyVisPlugin::slotVisualize()
330 if (propertyModel_ == 0)
return;
332 int selectedId = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
333 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
336 propertyModel_->visualize(selectedIndices);
358 void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) {
359 if (propertyModel_ != 0)
360 propertyModel_->mouseEvent(_event);
369 if (propertyModel_ != 0)
371 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
372 propertyModel_->duplicateProperty(selectedIndices);
375 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
398 if (propertyModel_ != 0)
400 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
401 propertyModel_->removeProperty(selectedIndices);
404 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
void slotClear(int _id, const QString &_propname)
This class manages the visualizers for a single object.
#define DATA_POLYHEDRAL_MESH
#define DATA_TRIANGLE_MESH
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void propertySelectionChanged()
Called when user selects a property.
#define DATA_TETRAHEDRAL_MESH
#define DATA_HEXAHEDRAL_MESH
Logtype
Log types for Message Window.
const QStringList ALL_OBJECTS
Iterable object range.
void slotVisualizeProperty(int _id, const QString &_propname)
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(4))
Geometry updated.
virtual void clear(QModelIndexList selectedIndices)=0
Clears the selected property visualization.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList())=0
Visualizes the selected properties.
virtual void objectUpdated()=0
Revisualizes visualized properties.
QModelIndex indexFromPlainPropName(const QString &propName) const
Returns the index of the property with the given name.
void setNewPropertyModel(int id)
Exchanges the PropertyModel after the user selected a different object.
void slotRemoveProperty()
Removes the selected properties.
virtual QScriptValue getScriptObject(const QModelIndex index, QScriptContext *ctx)
Returns a qscript object that can be used to access visualisation parameters.
void slotDuplicateProperty()
Duplicates the selected properties.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1024))
Colors have changed.
virtual void gatherProperties()=0
Searches for properties and creates PropertyVisualizers.