Commit 15071227 authored by Mike Kremer's avatar Mike Kremer

Refactored PropertyVisualization plugin.

The code was written by Max Lyon.
New features are:

- Changed plugin's architecture so that it can now be extended
  to support generic object types (implementation for OpenVolumeMesh
  has been added).
- Read/write properties from/into files. Also reading props into existing
  properties is now supported.
- Multiple properties can be selected (multiple toolboxes appear)
  and combined.
- Documentation has been added.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15818 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 89ef218a
......@@ -4,4 +4,8 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/BSplineCurve)
add_definitions (-DENABLE_SKELETON_SUPPORT)
endif()
openflipper_plugin (INSTALLDATA Icons)
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/PolyhedralMesh)
add_definitions (-DENABLE_OPENVOLUMEMESH_SUPPORT)
endif()
openflipper_plugin (INSTALLDATA Icons DIRS OpenMesh OpenVolumeMesh Widgets)
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
#ifndef OM_PROPERTY_MODEL_H
#define OM_PROPERTY_MODEL_H
#include "../PropertyModel.hh"
#include "OMPropertyVisualizer.hh"
#include "Widgets/LoadSaveWidget.hh"
#include "Widgets/PickWidget.hh"
#include <OpenFlipper/common/ViewerProperties.hh>
class PropertyVisPlugin;
/*! \class OMPropertyModelSubclass
* \brief Added for signal/slot support.
*
* This class adds signal/slot support for OMPropertyModelSubclass. OMPropertyModel is
* then derived from this class to make use of those signals and slots. This needs
* to be done because "Sorry, Qt does not support templates that contain signals,
* slots or Q_OBJECT"
* http://doc.trolltech.com/qq/qq15-academic.html
*/
class OMPropertyModelSubclass: public PropertyModel
{
Q_OBJECT
public:
OMPropertyModelSubclass(QObject *parent = 0)
: PropertyModel(parent)
{
}
public slots:
virtual void slotCombine(){ combine(); }
virtual void slotSaveProperty(){ saveProperty(); }
virtual void slotLoadProperty(){ loadProperty(); }
virtual void slotPickProperty(){ pickProperty(); }
private:
virtual void combine(){}
virtual void saveProperty(){}
virtual void pickProperty(){}
};
template<typename MeshT>
class OMPropertyModel: public OMPropertyModelSubclass {
public:
OMPropertyModel(MeshT* mesh, int objectID, QObject *parent = 0);
virtual ~OMPropertyModel(){}
virtual void updateWidget(const QModelIndexList& selectedIndices);
protected:
virtual QString getLoadFilenameFilter();
virtual QString getSaveFilenameFilter(unsigned int propId);
private:
/// Combines two properties.
virtual void combine();
/// Checks if two properties are combinable.
bool combinable(PropertyVisualizer* propertyVisualizer1, PropertyVisualizer* propertyVisualizer2);
/// Saves the currently slected properties.
virtual void saveProperty();
virtual bool parseHeader(QString header, PropertyVisualizer*& propVis, unsigned int& n);
virtual void setPropertyFromFile(QTextStream*& file_stream_, unsigned int n, PropertyVisualizer *propVis);
/// Disables picking.
void resetPicking();
/// Toggle picking on and off.
virtual void pickProperty();
/// Handles changing of pick mode.
virtual void pickModeChanged(const std::string& _mode);
/// Handles mouse events for picking.
virtual void mouseEvent(QMouseEvent* _event);
bool isVectorType(const TypeInfoWrapper& typeInfo) const;
/// Searches for properties with a specific entity type and creates visualizers.
void gatherProperties( MeshT* mesh,
typename MeshT::prop_iterator props_first,
typename MeshT::prop_iterator props_last,
PropertyInfo::ENTITY_FILTER filter);
/// Searches for all properties and creates the visualizers.
void gatherProperties();
/// Checks if visualizing this property is supported.
bool isSupported(OpenMesh::BaseProperty* const baseProp) const;
/// Checks if visualizing this type of property is supported.
bool isSupported(QString friendlyName) const;
/// Checks if we already created a PropertyVisualizer for this property.
bool isNew(OpenMesh::BaseProperty* const baseProp, PropertyInfo::ENTITY_FILTER filter);
/// Returns the TypeInfoWrapper for the property if it is supported.
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenMesh::BaseProperty* const baseProp);
/// Returns the TypeInfoWrapper for the type of property if it is supported.
TypeInfoWrapper getSupportedTypeInfoWrapper(QString friendlyName);
/// Adds a new PropertyVisualizer.
void addPropertyVisualizer(OpenMesh::BaseProperty* const baseProp, MeshT* mesh, PropertyInfo::ENTITY_FILTER filter);
/// Adds a new property to the mesh.
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter);
private:
MeshT* mesh_;
int objectID_;
static const TypeInfoWrapper proptype_bool;
static const TypeInfoWrapper proptype_int;
static const TypeInfoWrapper proptype_uint;
static const TypeInfoWrapper proptype_double;
static const TypeInfoWrapper proptype_Vec3d;
static const TypeInfoWrapper proptype_Vec3f;
#ifdef ENABLE_SKELETON_SUPPORT
static const TypeInfoWrapper proptype_SkinWeights;
#endif
typedef std::set<TypeInfoWrapper> TypeInfoWrapperSet;
static const TypeInfoWrapper propertyTypes[];
static const TypeInfoWrapperSet supportedPropertyTypes;
QPushButton bCombine;
const PropertyInfo* mCombineProperty1;
const PropertyInfo* mCombineProperty2;
LoadSaveWidget mLoadSaveWidget;
PickWidget mPickWidget;
bool pickModeActive;
std::string lastPickMode;
Viewer::ActionMode lastActionMode;
};
#if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_MODEL_CC)
#include "OMPropertyModelT.cc"
#endif
#endif /* OM_PROPERTY_MODEL_H */
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
#ifndef OM_PROPERTY_VISUALIZER_HH
#define OM_PROPERTY_VISUALIZER_HH
#include "../PropertyVisualizer.hh"
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <iostream>
template <typename MeshT>
class OMPropertyVisualizer: public PropertyVisualizer{
public:
OMPropertyVisualizer(MeshT* _mesh, PropertyInfo _propertyInfo)
: PropertyVisualizer(_propertyInfo),
mesh(_mesh)
{ }
virtual ~OMPropertyVisualizer(){clear();}
/// Visualizes the property.
virtual void visualize();
/**
* @brief Removes the property.
*
* This will remove the property from the mesh. After this method the PropertyVisualizer
* should be deleted.
*/
virtual void removeProperty(){ /*implemented by subclass*/}
/**
* @brief Duplicates the property.
*
* This will duplicate the property.
*/
virtual void duplicateProperty(){ /*implemented by subclass*/}
/// Clears the property.
virtual void clear();
/// Returns the ID of the closest primitive.
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint);
virtual QString getPropertyText(unsigned int index);
protected:
MeshT* mesh;
virtual void visualizeFaceProp();
virtual void visualizeEdgeProp();
virtual void visualizeHalfedgeProp();
virtual void visualizeVertexProp();
template <typename PropType>
void removeProperty_stage1();
template <typename PropType>
void removeProperty_stage2();
template<typename PropType>
void duplicateProperty_stage1();
template<typename PropHandle, typename Iterator>
void duplicateProperty_stage2(Iterator first, Iterator last);
virtual void clearFaceProp();
virtual void clearEdgeProp();
virtual void clearHalfedgeProp();
virtual void clearVertexProp();
virtual void setFacePropertyFromText(unsigned int index, QString text);
virtual void setEdgePropertyFromText(unsigned int index, QString text);
virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
virtual void setVertexPropertyFromText(unsigned int index, QString text);
OpenMesh::Vec4f convertColor(QColor color);
virtual void setPropertyFromText(unsigned int index, QString text);
virtual int getEntityCount();
virtual QString getHeader();
unsigned int getClosestFaceId(unsigned int _face, ACG::Vec3d& _hitPoint);
unsigned int getClosestEdgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
unsigned int getClosestHalfedgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
unsigned int getClosestVertexId(unsigned int _face, ACG::Vec3d& _hitPoint);
template <typename InnerType >
QString getPropertyText_(unsigned int index);
private:
template<typename PropHandleT>
class CopyProperty
{
public:
CopyProperty(const PropHandleT& p1, const PropHandleT& p2, MeshT*& mesh) :
p1(p1), p2(p2), mesh(mesh) {}
template<typename PrimitiveHandleT>
inline void operator() (const PrimitiveHandleT &pr) {
mesh->property(p1, pr) = mesh->property(p2, pr);
}
private:
const PropHandleT &p1, &p2;
MeshT*& mesh;
};
};
#if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_VISUALIZER_CC)
#include "OMPropertyVisualizerT.cc"
#endif
#endif /* OM_PROPERTY_VISUALIZER_HH */
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
#ifndef OM_PROPERTY_VISUALIZER_BOOLEAN_HH
#define OM_PROPERTY_VISUALIZER_BOOLEAN_HH
#include "OMPropertyVisualizer.hh"
#include "Widgets/BooleanWidget.hh"
#include <iostream>
template <typename MeshT>
class OMPropertyVisualizerBoolean: public OMPropertyVisualizer<MeshT>{
public:
OMPropertyVisualizerBoolean(MeshT* _mesh, PropertyInfo _propertyInfo);
virtual ~OMPropertyVisualizerBoolean(){}
protected:
virtual void visualizeFaceProp();
virtual void visualizeEdgeProp();
virtual void visualizeHalfedgeProp();
virtual void visualizeVertexProp();
virtual void removeProperty();
virtual void duplicateProperty();
virtual QString getPropertyText(unsigned int index);
virtual void setFacePropertyFromText(unsigned int index, QString text);
virtual void setEdgePropertyFromText(unsigned int index, QString text);
virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
virtual void setVertexPropertyFromText(unsigned int index, QString text);
};
#if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_VISUALIZER_BOOLEAN_CC)
#include "OMPropertyVisualizerBooleanT.cc"
#endif
#endif /* OM_PROPERTY_VISUALIZER_BOOLEAN_HH */
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
#ifndef OM_PROPERTY_VISUALIZER_DOUBLE_HH
#define OM_PROPERTY_VISUALIZER_DOUBLE_HH
#include "OMPropertyVisualizer.hh"
#include "Widgets/DoubleWidget.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <ACG/Utils/ColorCoder.hh>
#include <iostream>
template <typename MeshT>
class OMPropertyVisualizerDouble: public OMPropertyVisualizer<MeshT>{
public:
OMPropertyVisualizerDouble(MeshT* _mesh, PropertyInfo _propertyInfo);
virtual ~OMPropertyVisualizerDouble(){}
protected:
virtual void visualizeFaceProp();
virtual void visualizeEdgeProp();
virtual void visualizeHalfedgeProp();
virtual void visualizeVertexProp();
virtual void removeProperty();
virtual void duplicateProperty();
virtual QString getPropertyText(unsigned int index);
virtual void setFacePropertyFromText(unsigned int index, QString text);
virtual void setEdgePropertyFromText(unsigned int index, QString text);
virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
virtual void setVertexPropertyFromText(unsigned int index, QString text);
};
template <typename MeshT>
QString OMPropertyVisualizerDouble<MeshT>::getPropertyText(unsigned int index)
{
return OMPropertyVisualizer<MeshT>::template getPropertyText_<double>(index);
}
#if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_VISUALIZER_DOUBLE_CC)
#include "OMPropertyVisualizerDoubleT.cc"
#endif
#endif /* OM_PROPERTY_VISUALIZER_DOUBLE_HH */
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
#ifndef OM_PROPERTY_VISUALIZER_INTEGER_HH
#define OM_PROPERTY_VISUALIZER_INTEGER_HH
#include "OMPropertyVisualizer.hh"
#include "Widgets/IntegerWidget.hh"
#include <ACG/Utils/ColorGenerator.hh>
#include <iostream>
template <typename MeshT, typename T>
class OMPropertyVisualizerInteger: public OMPropertyVisualizer<MeshT>{
public:
OMPropertyVisualizerInteger(MeshT* _mesh, PropertyInfo _propertyInfo, bool isUnsigned);
virtual ~OMPropertyVisualizerInteger(){}
protected:
virtual void visualizeFaceProp();
virtual void visualizeEdgeProp();
virtual void visualizeHalfedgeProp();
virtual void visualizeVertexProp();
virtual void removeProperty();
virtual void duplicateProperty();
virtual T getValue(OpenMesh::FPropHandleT< T > prop, typename MeshT::FaceIter iter) { return OMPropertyVisualizer<MeshT>::mesh->property(prop, iter) ; }
virtual T getValue(OpenMesh::EPropHandleT< T > prop, typename MeshT::EdgeIter iter) { return OMPropertyVisualizer<MeshT>::mesh->property(prop, iter) ; }
virtual T getValue(OpenMesh::HPropHandleT< T > prop, typename MeshT::HalfedgeIter iter) { return OMPropertyVisualizer<MeshT>::mesh->property(prop, iter) ; }
virtual T getValue(OpenMesh::VPropHandleT< T > prop, typename MeshT::VertexIter iter) { return OMPropertyVisualizer<MeshT>::mesh->property(prop, iter) ; }
virtual QString getPropertyText(unsigned int index);
virtual void setFacePropertyFromText(unsigned int index, QString text);
virtual void setEdgePropertyFromText(unsigned int index, QString text);
virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
virtual void setVertexPropertyFromText(unsigned int index, QString text);
inline int strToT (QString str, int) { return this->strToInt(str); }
inline unsigned int strToT (QString str, unsigned int) { return this->strToUInt(str); }
inline QString TToStr (int i) { return this->intToStr(i); }
inline QString TToStr (unsigned int i) { return this->uintToStr(i); }
ACG::ColorGenerator mColorGenerator;
};
#if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_VISUALIZER_INTEGER_CC)
#include "OMPropertyVisualizerIntegerT.cc"
#endif
#endif /* OM_PROPERTY_VISUALIZER_INTEGER_HH */
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
#ifdef ENABLE_SKELETON_SUPPORT
#ifndef OM_PROPERTY_VISUALIZER_SKIN_WEIGHTS_HH
#define OM_PROPERTY_VISUALIZER_SKIN_WEIGHTS_HH
#include "OMPropertyVisualizer.hh"
#include "Widgets/SkinWeightsWidget.hh"
#include <ObjectTypes/Skeleton/BaseSkin.hh>
#include <iostream>
template <typename MeshT>
class OMPropertyVisualizerSkinWeights: public OMPropertyVisualizer<MeshT>{
public:
OMPropertyVisualizerSkinWeights(MeshT* _mesh, PropertyInfo _propertyInfo);
virtual ~OMPropertyVisualizerSkinWeights(){}
protected:
virtual void visualizeFaceProp();
virtual void visualizeEdgeProp();
virtual void visualizeHalfedgeProp();
virtual void visualizeVertexProp();
QString getPropertyText(unsigned int index);
virtual void setFacePropertyFromText(unsigned int index, QString text);
virtual void setEdgePropertyFromText(unsigned int index, QString text);
virtual void setHalfedgePropertyFromText(unsigned int index, QString text);