OMPropertyVisualizer.hh 6.53 KB
Newer Older
1 2 3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2014 by Computer Graphics Group, RWTH Aachen       *
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
*                           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/>.                                       *
*                                                                            *
\*===========================================================================*/

35 36 37 38 39 40 41 42
/*===========================================================================*\
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
\*===========================================================================*/

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#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.
66
    virtual void visualize(bool _setDrawMode = true);
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

    /**
     * @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;

94 95 96 97
    virtual void visualizeFaceProp(bool _setDrawMode = true);
    virtual void visualizeEdgeProp(bool _setDrawMode = true);
    virtual void visualizeHalfedgeProp(bool _setDrawMode = true);
    virtual void visualizeVertexProp(bool _setDrawMode = true);
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141

    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:
Jan Möbius's avatar
Jan Möbius committed
142 143
            CopyProperty(const PropHandleT& _p1, const PropHandleT& _p2, MeshT*& mesh) :
                p1(_p1), p2(_p2), mesh(mesh) {}
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

            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 */