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);
119 void PropertyVisPlugin::slotVisualizeProperty(
int _id,
const QString& _propname )
130 QModelIndexList list;
142 QScriptValue PropertyVisPlugin::getPropertyVisualizer(
int _id,
const QString &_propname)
146 if (model ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
150 if (!idx.isValid()) {
return QScriptValue::SpecialValue::NullValue; }
152 QScriptEngine *engine;
153 emit getScriptingEngine (engine);
154 if (engine ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
156 QScriptContext *ctx = engine->currentContext();
157 if (ctx ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
160 if (!sopm) {
return QScriptValue::SpecialValue::NullValue; }
167 void PropertyVisPlugin::slotPickModeChanged(
const std::string& _mode)
169 if (propertyModel_ != 0)
170 propertyModel_->pickModeChanged(_mode);
175 void PropertyVisPlugin::slotAllCleared()
179 if (propertyModel_ != 0)
181 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
182 propertyModel_->clear(selectedIndices);
183 propertyModel_->objectUpdated();
190 void PropertyVisPlugin::objectDeleted(
int _id)
192 if( OpenFlipper::Options::gui() )
193 objectListItemModel_.removeObject(_id);
199 void PropertyVisPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type )
201 if( OpenFlipper::Options::gui() )
203 if ( tool_->isVisible() )
216 void PropertyVisPlugin::slotObjectPropertiesChanged(
int _identifier)
219 if( OpenFlipper::Options::gui() && tool_->isVisible() )
225 void PropertyVisPlugin::updateGUI()
228 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT 231 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT 234 #ifdef ENABLE_TETRAHEDRALMESH_SUPPORT 237 objectListItemModel_.refresh(datatype);
244 if (propertyModel_ != 0)
246 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
247 propertyModel_->updateWidget(selectedIndices);
266 propertyModel_->hideWidget();
267 disconnect(propertyModel_, SIGNAL(log(
Logtype,QString)),
this, SLOT(slotLog(
Logtype,QString)));
268 disconnect(propertyModel_, SIGNAL(log(QString)),
this, SLOT(slotLog(QString)));
271 if (propertyModel_ != 0)
274 tool_->propertyName_lv->setModel(propertyModel_);
275 connect(propertyModel_, SIGNAL( modelReset() ),
this, SLOT( propertySelectionChanged() ));
276 connect(tool_->propertyName_lv->selectionModel(),
277 SIGNAL( selectionChanged(
const QItemSelection &,
const QItemSelection &) ),
279 SLOT( propertySelectionChanged() ));
280 QWidget* widget = propertyModel_->getWidget();
281 tool_->propertyWidgets->addWidget(widget);
283 propertyModel_->gatherProperties();
284 connect(propertyModel_, SIGNAL(log(
Logtype,QString)),
this, SLOT(slotLog(
Logtype,QString)));
285 connect(propertyModel_, SIGNAL(log(QString)),
this, SLOT(slotLog(QString)));
289 tool_->propertyName_lv->setModel(0);
295 void PropertyVisPlugin::slotMeshChanged(
int )
297 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
298 setNewPropertyModel(
id);
303 void PropertyVisPlugin::slotVisualize()
308 if (propertyModel_ == 0)
return;
310 int selectedId = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
311 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
314 propertyModel_->visualize(selectedIndices);
336 void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) {
337 if (propertyModel_ != 0)
338 propertyModel_->mouseEvent(_event);
347 if (propertyModel_ != 0)
349 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
350 propertyModel_->duplicateProperty(selectedIndices);
353 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
376 if (propertyModel_ != 0)
378 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
379 propertyModel_->removeProperty(selectedIndices);
382 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
void setNewPropertyModel(int id)
Exchanges the PropertyModel after the user selected a different object.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
Logtype
Log types for Message Window.
void slotDuplicateProperty()
Duplicates the selected properties.
void slotRemoveProperty()
Removes the selected properties.
This class manages the visualizers for a single object.
const QStringList ALL_OBJECTS
Iterable object range.
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList())=0
Visualizes the selected properties.
#define DATA_TETRAHEDRAL_MESH
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
void propertySelectionChanged()
Called when user selects a property.
QModelIndex indexFromPlainPropName(const QString &propName) const
Returns the index of the property with the given name.
#define DATA_HEXAHEDRAL_MESH
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
#define DATA_POLYHEDRAL_MESH
virtual QScriptValue getScriptObject(const QModelIndex index, QScriptContext *ctx)
Returns a qscript object that can be used to access visualisation parameters.
virtual void objectUpdated()=0
Revisualizes visualized properties.
#define DATA_TRIANGLE_MESH
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
virtual void gatherProperties()=0
Searches for properties and creates PropertyVisualizers.