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#include <QStringListModel>
73PropertyVisPlugin::PropertyVisPlugin() :
76propertyModel_(nullptr)
80PropertyVisPlugin::~PropertyVisPlugin()
85void PropertyVisPlugin::initializePlugin()
87 if ( OpenFlipper::Options::gui() ) {
93 tool_->meshNames->setModel(&objectListItemModel_);
95 emit addHiddenPickMode( PROP_VIS );
97 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"PropertyVisIcon.png");
99 emit addToolbox( tr(
"Property Visualization") , tool_, toolIcon_ );
105void PropertyVisPlugin::pluginsInitialized()
107 if ( OpenFlipper::Options::gui() ) {
110 connect(tool_->meshNames, SIGNAL( currentIndexChanged(
int) ),
this, SLOT( slotMeshChanged(
int) ) );
112 connect(tool_->visualizeButton, SIGNAL( clicked() ),
this, SLOT( slotVisualize() ) );
113 connect(tool_->clearButton, SIGNAL( clicked() ),
this, SLOT( slotAllCleared() ) );
115 connect(tool_->refresh_property_names_tb, SIGNAL( clicked() ),
this, SLOT( slotMeshChanged() ) );
117 connect(tool_->remove_property_tb, SIGNAL( clicked() ),
this, SLOT(
slotRemoveProperty() ) );
119 connect(tool_, SIGNAL( widgetShown() ),
this, SLOT( updateGUI() ) );
138 QModelIndexList list;
161 QModelIndexList list;
172#if QT_VERSION_MAJOR < 6
173QScriptValue PropertyVisPlugin::getPropertyVisualizer(
int _id,
const QString &_propname)
177 if (model ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
181 if (!idx.isValid()) {
return QScriptValue::SpecialValue::NullValue; }
183 QScriptEngine *engine;
184 emit getScriptingEngine (engine);
185 if (engine ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
187 QScriptContext *ctx = engine->currentContext();
188 if (ctx ==
nullptr) {
return QScriptValue::SpecialValue::NullValue; }
191 if (!sopm) {
return QScriptValue::SpecialValue::NullValue; }
199void PropertyVisPlugin::slotPickModeChanged(
const std::string& _mode)
202 propertyModel_->pickModeChanged(_mode);
207void PropertyVisPlugin::slotAllCleared()
213 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
214 propertyModel_->
clear(selectedIndices);
222void PropertyVisPlugin::objectDeleted(
int _id)
224 if( OpenFlipper::Options::gui() )
225 objectListItemModel_.removeObject(_id);
231void PropertyVisPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type )
233 if( OpenFlipper::Options::gui() )
235 if ( tool_->isVisible() )
248void PropertyVisPlugin::slotObjectPropertiesChanged(
int _identifier)
251 if( OpenFlipper::Options::gui() && tool_->isVisible() )
257void PropertyVisPlugin::updateGUI()
260#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
263#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
266#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
269 objectListItemModel_.refresh(datatype);
278 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
300 disconnect(propertyModel_, SIGNAL(log(QString)),
this, SLOT(
slotLog(QString)));
306 tool_->propertyName_lv->setModel(propertyModel_);
308 connect(tool_->propertyName_lv->selectionModel(),
309 SIGNAL( selectionChanged(
const QItemSelection &,
const QItemSelection &) ),
312 QWidget* widget = propertyModel_->
getWidget();
313 tool_->propertyWidgets->addWidget(widget);
317 connect(propertyModel_, SIGNAL(log(QString)),
this, SLOT(
slotLog(QString)));
321 tool_->propertyName_lv->setModel(0);
327void PropertyVisPlugin::slotMeshChanged(
int )
329 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
335void PropertyVisPlugin::slotVisualize()
340 if (propertyModel_ ==
nullptr)
return;
342 int selectedId = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
343 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
346 propertyModel_->
visualize(selectedIndices);
368void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) {
370 propertyModel_->mouseEvent(_event);
381 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
385 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
395 while (o_it != objectsEnd())
410 QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
414 int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
423 while (o_it != objectsEnd())
Logtype
Log types for Message Window.
#define DATA_HEXAHEDRAL_MESH
#define DATA_POLYHEDRAL_MESH
#define DATA_TETRAHEDRAL_MESH
#define DATA_TRIANGLE_MESH
virtual void updateWidget(const QModelIndexList &selectedIndices)=0
Updates the widget.
QModelIndex indexFromPlainPropName(const QString &propName) const
Returns the index of the property with the given name.
virtual void objectUpdated()=0
Revisualizes visualized properties.
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList())=0
Visualizes the selected properties.
virtual QWidget * getWidget()=0
Returns the widget.
virtual void removeProperty(QModelIndexList selectedIndices)=0
Removes the selected properties.
virtual void hideWidget()=0
Hides the widget.
virtual void gatherProperties()=0
Searches for properties and creates PropertyVisualizers.
virtual void clear(QModelIndexList selectedIndices)=0
Clears the selected property visualization.
virtual void duplicateProperty(QModelIndexList selectedIndices)=0
Duplicates the selected properties.
void propertySelectionChanged()
Called when user selects a property.
void slotClear(int _id, const QString &_propname)
void setNewPropertyModel(int id)
Exchanges the PropertyModel after the user selected a different object.
void slotDuplicateProperty()
Duplicates the selected properties.
void slotRemoveProperty()
Removes the selected properties.
void slotLog(Logtype _type, QString _message)
Receives log messages from PropertyModels and emits them.
void slotVisualizeProperty(int _id, const QString &_propname)
This class manages the visualizers for a single object.
virtual QScriptValue getScriptObject(const QModelIndex index, QScriptContext *ctx)
Returns a qscript object that can be used to access visualisation parameters.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(4))
Geometry updated.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1024))
Colors have changed.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.