Commit 868e1469 authored by Isaak Lim's avatar Isaak Lim

added multiple object property visualization support for OVM (thanks to Alexander Dielen)

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@21171 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d51a34d8
This diff is collapsed.
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define MULTI_OBJECT_PROPERTY_MODEL_H #define MULTI_OBJECT_PROPERTY_MODEL_H
#include "PropertyModel.hh" #include "PropertyModel.hh"
#include "OpenFlipper/common/DataTypes.hh"
class PropertyVisualizer; class PropertyVisualizer;
...@@ -10,11 +11,11 @@ class MultiObjectPropertyModel: public PropertyModel ...@@ -10,11 +11,11 @@ class MultiObjectPropertyModel: public PropertyModel
Q_OBJECT Q_OBJECT
public: public:
MultiObjectPropertyModel(const QStringList& res, QObject *parent = 0); MultiObjectPropertyModel(const QStringList& res, QObject *parent = 0);
virtual ~MultiObjectPropertyModel(); virtual ~MultiObjectPropertyModel();
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const; virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
/// Revisualizes visualized properties. /// Revisualizes visualized properties.
...@@ -47,19 +48,20 @@ public: ...@@ -47,19 +48,20 @@ public:
/// Connects the PropertyVisualizer log signals with the log slot. /// Connects the PropertyVisualizer log signals with the log slot.
virtual void connectLogs(PropertyVisualizer* propViz); virtual void connectLogs(PropertyVisualizer* propViz);
/// Returns the property info for the property with the given index. /// Returns the property info for the property with the given index.
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const; virtual PropertyInfo getPropertyInfo(const QModelIndex index) const;
private: private:
QWidget* createWidgetForType(const TypeInfoWrapper& info) const; QWidget* createWidgetForType(const TypeInfoWrapper& info) const;
void setRange(const PropertyInfo& info, QWidget* widget) const; void setRange(const PropertyInfo& info, QWidget* widget) const;
private: private:
const QStringList restriction; const QStringList restriction;
const DataType datatypes;
std::vector<QString> propNames; std::vector<QString> propNames;
std::vector<PropertyInfo> propInfos; std::vector<PropertyInfo> propInfos;
std::vector<QWidget*> propWidgets; std::vector<QWidget*> propWidgets;
QWidget* widget; QWidget* widget;
}; };
#endif /* MULTI_OBJECT_PROPERTY_MODEL_H */ #endif /* MULTI_OBJECT_PROPERTY_MODEL_H */
...@@ -76,10 +76,10 @@ ...@@ -76,10 +76,10 @@
#include <ObjectTypes/PolyMesh/PolyMesh.hh> #include <ObjectTypes/PolyMesh/PolyMesh.hh>
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
#include <ObjectTypes/PolyhedralMesh/PolyhedralMesh.hh> #include <ObjectTypes/PolyhedralMesh/PolyhedralMesh.hh>
#endif #endif
#ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
#include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh> #include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
#endif #endif
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
...@@ -94,50 +94,50 @@ propertyModel_(0) ...@@ -94,50 +94,50 @@ propertyModel_(0)
void PropertyVisPlugin::initializePlugin() void PropertyVisPlugin::initializePlugin()
{ {
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
tool_ = new PropertyVisToolbar(); tool_ = new PropertyVisToolbar();
QSize size(300,300); QSize size(300,300);
tool_->resize(size); tool_->resize(size);
tool_->meshNames->setModel(&objectListItemModel_); tool_->meshNames->setModel(&objectListItemModel_);
emit addHiddenPickMode( PROP_VIS ); emit addHiddenPickMode( PROP_VIS );
QIcon* toolIcon = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"PropertyVisIcon.png"); QIcon* toolIcon = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"PropertyVisIcon.png");
emit addToolbox( tr("Property Visualization") , tool_, toolIcon ); emit addToolbox( tr("Property Visualization") , tool_, toolIcon );
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PropertyVisPlugin::pluginsInitialized() void PropertyVisPlugin::pluginsInitialized()
{ {
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
// connect toolbox elements // connect toolbox elements
connect(tool_->meshNames, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotMeshChanged(int) ) ); connect(tool_->meshNames, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotMeshChanged(int) ) );
connect(tool_->visualizeButton, SIGNAL( clicked() ), this, SLOT( slotVisualize() ) ); connect(tool_->visualizeButton, SIGNAL( clicked() ), this, SLOT( slotVisualize() ) );
connect(tool_->clearButton, SIGNAL( clicked() ), this, SLOT( slotAllCleared() ) ); connect(tool_->clearButton, SIGNAL( clicked() ), this, SLOT( slotAllCleared() ) );
connect(tool_->refresh_property_names_tb, SIGNAL( clicked() ), this, SLOT( slotMeshChanged() ) ); connect(tool_->refresh_property_names_tb, SIGNAL( clicked() ), this, SLOT( slotMeshChanged() ) );
connect(tool_->duplicate_property_tb, SIGNAL( clicked() ), this, SLOT( slotDuplicateProperty() ) ); connect(tool_->duplicate_property_tb, SIGNAL( clicked() ), this, SLOT( slotDuplicateProperty() ) );
connect(tool_->remove_property_tb, SIGNAL( clicked() ), this, SLOT( slotRemoveProperty() ) ); connect(tool_->remove_property_tb, SIGNAL( clicked() ), this, SLOT( slotRemoveProperty() ) );
connect(tool_, SIGNAL( widgetShown() ), this, SLOT( updateGUI() ) ); connect(tool_, SIGNAL( widgetShown() ), this, SLOT( updateGUI() ) );
setNewPropertyModel(-1); setNewPropertyModel(-1);
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PropertyVisPlugin::slotPickModeChanged( const std::string& _mode) void PropertyVisPlugin::slotPickModeChanged( const std::string& _mode)
{ {
if (propertyModel_ != 0) if (propertyModel_ != 0)
propertyModel_->pickModeChanged(_mode); propertyModel_->pickModeChanged(_mode);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -146,64 +146,64 @@ void PropertyVisPlugin::slotAllCleared() ...@@ -146,64 +146,64 @@ void PropertyVisPlugin::slotAllCleared()
{ {
using namespace PluginFunctions; using namespace PluginFunctions;
if (propertyModel_ != 0) if (propertyModel_ != 0)
{ {
QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
propertyModel_->clear(selectedIndices); propertyModel_->clear(selectedIndices);
propertyModel_->objectUpdated(); propertyModel_->objectUpdated();
emit updateView(); emit updateView();
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PropertyVisPlugin::objectDeleted(int _id) void PropertyVisPlugin::objectDeleted(int _id)
{ {
if( OpenFlipper::Options::gui() ) if( OpenFlipper::Options::gui() )
objectListItemModel_.removeObject(_id); objectListItemModel_.removeObject(_id);
PropertyModelFactory::Instance().deleteModel(_id); PropertyModelFactory::Instance().deleteModel(_id);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PropertyVisPlugin::slotObjectUpdated( int _identifier, const UpdateType& _type ) void PropertyVisPlugin::slotObjectUpdated( int _identifier, const UpdateType& _type )
{ {
if( OpenFlipper::Options::gui() ) if( OpenFlipper::Options::gui() )
{ {
if ( tool_->isVisible() ) if ( tool_->isVisible() )
updateGUI(); updateGUI();
PropertyModel* propertyModel = PropertyModelFactory::Instance().getModel(_identifier); PropertyModel* propertyModel = PropertyModelFactory::Instance().getModel(_identifier);
if (propertyModel) if (propertyModel)
{ {
if (_type == UPDATE_ALL) if (_type == UPDATE_ALL)
propertyModel->gatherProperties(); propertyModel->gatherProperties();
if (_type == (UPDATE_ALL | UPDATE_GEOMETRY)) if (_type == (UPDATE_ALL | UPDATE_GEOMETRY))
propertyModel->objectUpdated(); propertyModel->objectUpdated();
} }
} }
} }
void PropertyVisPlugin::updateGUI() void PropertyVisPlugin::updateGUI()
{ {
DataType datatype = DataType(DATA_TRIANGLE_MESH | DATA_POLY_MESH); DataType datatype = DataType(DATA_TRIANGLE_MESH | DATA_POLY_MESH);
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
datatype |= DataType(DATA_POLYHEDRAL_MESH); datatype |= DataType(DATA_POLYHEDRAL_MESH);
#endif #endif
#ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
datatype |= DataType(DATA_HEXAHEDRAL_MESH); datatype |= DataType(DATA_HEXAHEDRAL_MESH);
#endif #endif
objectListItemModel_.refresh(datatype); objectListItemModel_.refresh(datatype);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PropertyVisPlugin::propertySelectionChanged() void PropertyVisPlugin::propertySelectionChanged()
{ {
if (propertyModel_ != 0) if (propertyModel_ != 0)
{ {
QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
propertyModel_->updateWidget(selectedIndices); propertyModel_->updateWidget(selectedIndices);
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -219,40 +219,40 @@ void PropertyVisPlugin::propertySelectionChanged() ...@@ -219,40 +219,40 @@ void PropertyVisPlugin::propertySelectionChanged()
*/ */
void PropertyVisPlugin::setNewPropertyModel(int id) void PropertyVisPlugin::setNewPropertyModel(int id)
{ {
if (propertyModel_) if (propertyModel_)
{ {
propertyModel_->hideWidget(); propertyModel_->hideWidget();
disconnect(propertyModel_, SIGNAL(log(Logtype,QString)), this, SLOT(slotLog(Logtype,QString))); disconnect(propertyModel_, SIGNAL(log(Logtype,QString)), this, SLOT(slotLog(Logtype,QString)));
disconnect(propertyModel_, SIGNAL(log(QString)), this, SLOT(slotLog(QString))); disconnect(propertyModel_, SIGNAL(log(QString)), this, SLOT(slotLog(QString)));
} }
propertyModel_ = PropertyModelFactory::Instance().getModel(id); propertyModel_ = PropertyModelFactory::Instance().getModel(id);
if (propertyModel_ != 0) if (propertyModel_ != 0)
{ {
tool_->propertyName_lv->setModel(propertyModel_); tool_->propertyName_lv->setModel(propertyModel_);
connect(propertyModel_, SIGNAL( modelReset() ), this, SLOT( propertySelectionChanged() )); connect(propertyModel_, SIGNAL( modelReset() ), this, SLOT( propertySelectionChanged() ));
connect(tool_->propertyName_lv->selectionModel(), connect(tool_->propertyName_lv->selectionModel(),
SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
this, this,
SLOT( propertySelectionChanged() )); SLOT( propertySelectionChanged() ));
QWidget* widget = propertyModel_->getWidget(); QWidget* widget = propertyModel_->getWidget();
tool_->propertyWidgets->addWidget(widget); tool_->propertyWidgets->addWidget(widget);
widget->show(); widget->show();
propertyModel_->gatherProperties(); propertyModel_->gatherProperties();
connect(propertyModel_, SIGNAL(log(Logtype,QString)), this, SLOT(slotLog(Logtype,QString))); connect(propertyModel_, SIGNAL(log(Logtype,QString)), this, SLOT(slotLog(Logtype,QString)));
connect(propertyModel_, SIGNAL(log(QString)), this, SLOT(slotLog(QString))); connect(propertyModel_, SIGNAL(log(QString)), this, SLOT(slotLog(QString)));
} }
else else
{ {
tool_->propertyName_lv->setModel(0); tool_->propertyName_lv->setModel(0);
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PropertyVisPlugin::slotMeshChanged(int /*_index*/) void PropertyVisPlugin::slotMeshChanged(int /*_index*/)
{ {
int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt(); int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
setNewPropertyModel(id); setNewPropertyModel(id);
} }
...@@ -261,26 +261,26 @@ void PropertyVisPlugin::slotMeshChanged(int /*_index*/) ...@@ -261,26 +261,26 @@ void PropertyVisPlugin::slotMeshChanged(int /*_index*/)
void PropertyVisPlugin::slotVisualize() void PropertyVisPlugin::slotVisualize()
{ {
using namespace PluginFunctions; using namespace PluginFunctions;
// return if nothing is selected // return if nothing is selected
if (propertyModel_ == 0) return; if (propertyModel_ == 0) return;
int selectedId = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt(); int selectedId = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
// visualize property // visualize property
propertyModel_->visualize(selectedIndices); propertyModel_->visualize(selectedIndices);
// emit updates // emit updates
emit updateView(); emit updateView();
if (selectedId >= 0) if (selectedId >= 0)
{ {
emit updatedObject( selectedId, UPDATE_COLOR ); emit updatedObject( selectedId, UPDATE_COLOR );
} }
else else
{ {
ObjectIterator o_it(ALL_OBJECTS, DATA_TRIANGLE_MESH | DATA_POLY_MESH); ObjectIterator o_it(ALL_OBJECTS, supportedDataTypes());
while (o_it != objectsEnd()) while (o_it != objectsEnd())
{ {
emit updatedObject( o_it->id(), UPDATE_COLOR ); emit updatedObject( o_it->id(), UPDATE_COLOR );
...@@ -292,8 +292,8 @@ void PropertyVisPlugin::slotVisualize() ...@@ -292,8 +292,8 @@ void PropertyVisPlugin::slotVisualize()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) { void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) {
if (propertyModel_ != 0) if (propertyModel_ != 0)
propertyModel_->mouseEvent(_event); propertyModel_->mouseEvent(_event);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -301,15 +301,15 @@ void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) { ...@@ -301,15 +301,15 @@ void PropertyVisPlugin::slotMouseEvent( QMouseEvent* _event ) {
void PropertyVisPlugin::slotDuplicateProperty() void PropertyVisPlugin::slotDuplicateProperty()
{ {
using namespace PluginFunctions; using namespace PluginFunctions;
if (propertyModel_ != 0)
{
QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
propertyModel_->duplicateProperty(selectedIndices);
emit updateView(); if (propertyModel_ != 0)
int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt(); {
slotMeshChanged(); QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
propertyModel_->duplicateProperty(selectedIndices);
emit updateView();
int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
slotMeshChanged();
if (id >= 0) if (id >= 0)
{ {
...@@ -317,42 +317,42 @@ void PropertyVisPlugin::slotDuplicateProperty() ...@@ -317,42 +317,42 @@ void PropertyVisPlugin::slotDuplicateProperty()
} }
else else
{ {
ObjectIterator o_it(ALL_OBJECTS, DATA_TRIANGLE_MESH | DATA_POLY_MESH); ObjectIterator o_it(ALL_OBJECTS, supportedDataTypes());
while (o_it != objectsEnd()) while (o_it != objectsEnd())
{ {
emit updatedObject( o_it->id(), UPDATE_ALL ); emit updatedObject( o_it->id(), UPDATE_ALL );
++o_it; ++o_it;
} }
} }
} }
} }
void PropertyVisPlugin::slotRemoveProperty() void PropertyVisPlugin::slotRemoveProperty()
{ {
using namespace PluginFunctions; using namespace PluginFunctions;
if (propertyModel_ != 0) if (propertyModel_ != 0)
{ {
QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes(); QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
propertyModel_->removeProperty(selectedIndices); propertyModel_->removeProperty(selectedIndices);
emit updateView(); emit updateView();
int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt(); int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
if (id >= 0) if (id >= 0)
{ {
emit updatedObject( id, UPDATE_ALL ); emit updatedObject( id, UPDATE_ALL );
} }
else else
{ {
ObjectIterator o_it(ALL_OBJECTS, DATA_TRIANGLE_MESH | DATA_POLY_MESH); ObjectIterator o_it(ALL_OBJECTS, supportedDataTypes());
while (o_it != objectsEnd()) while (o_it != objectsEnd())
{ {
emit updatedObject( o_it->id(), UPDATE_ALL ); emit updatedObject( o_it->id(), UPDATE_ALL );
++o_it; ++o_it;
} }
} }
} }
} }
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
......
...@@ -56,9 +56,12 @@ ...@@ -56,9 +56,12 @@
#include <typeinfo> #include <typeinfo>
#include <QObject> #include <QObject>
#include <QMessageBox> #include <QMessageBox>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
#include <ObjectTypes/PolyhedralMesh/PolyhedralMesh.hh>
/*! \class TypeInfoWrapper /*! \class TypeInfoWrapper
* \brief Wraps the information of a type. * \brief Wraps the information of a type.
...@@ -192,4 +195,19 @@ public: ...@@ -192,4 +195,19 @@ public:
}; };
static DataType supportedDataTypes()
{
DataType res = DATA_TRIANGLE_MESH | DATA_POLY_MESH;
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
res |= DATA_POLYHEDRAL_MESH;
#endif
#ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
res |= DATA_HEXAHEDRAL_MESH;
#endif
return res;
}
#endif /* UTILS_H */ #endif /* UTILS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment