Utilities.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GUI_UTILITIES_H
00024 #define GUI_UTILITIES_H
00025
00026 #include <Base/ViewProj.h>
00027 #include <App/Material.h>
00028 #include <vector>
00029 #include <Inventor/SbColor.h>
00030 #include <Inventor/SbVec2f.h>
00031 #include <Inventor/SbViewVolume.h>
00032
00033 class SbViewVolume;
00034 class QAbstractItemView;
00035
00036 namespace Base {
00037
00038 template <>
00039 struct vec_traits<SbVec3f> {
00040 typedef SbVec3f vec_type;
00041 typedef float float_type;
00042 vec_traits(const vec_type& v) : v(v){}
00043 inline float_type x() { return v[0]; }
00044 inline float_type y() { return v[1]; }
00045 inline float_type z() { return v[2]; }
00046 private:
00047 const vec_type& v;
00048 };
00049
00050
00051 template <>
00052 struct vec_traits<SbVec3d> {
00053 typedef SbVec3d vec_type;
00054 typedef double float_type;
00055 vec_traits(const vec_type& v) : v(v){}
00056 inline float_type x() { return v[0]; }
00057 inline float_type y() { return v[1]; }
00058 inline float_type z() { return v[2]; }
00059 private:
00060 const vec_type& v;
00061 };
00062
00063
00064 template <>
00065 struct vec_traits<SbColor> {
00066 typedef SbColor vec_type;
00067 typedef float float_type;
00068 vec_traits(const vec_type& v) : v(v){}
00069 inline float_type x() { return v[0]; }
00070 inline float_type y() { return v[1]; }
00071 inline float_type z() { return v[2]; }
00072 private:
00073 const vec_type& v;
00074 };
00075
00076
00077 template <>
00078 struct vec_traits<App::Color> {
00079 typedef App::Color vec_type;
00080 typedef float float_type;
00081 vec_traits(const vec_type& v) : v(v){}
00082 inline float_type x() { return v.r; }
00083 inline float_type y() { return v.g; }
00084 inline float_type z() { return v.b; }
00085 private:
00086 const vec_type& v;
00087 };
00088 }
00089
00090 namespace App{ class DocumentObject; }
00091 namespace Gui {
00092
00095 class GuiExport ViewVolumeProjection : public Base::ViewProjMethod
00096 {
00097 public:
00098 ViewVolumeProjection (const SbViewVolume &vv);
00099 virtual ~ViewVolumeProjection(){};
00100
00101 Base::Vector3f operator()(const Base::Vector3f &rclPt) const;
00102 Base::Vector3d operator()(const Base::Vector3d &rclPt) const;
00103 Base::Vector3f inverse (const Base::Vector3f &rclPt) const;
00104 Base::Vector3d inverse (const Base::Vector3d &rclPt) const;
00105
00106 Base::Matrix4D getProjectionMatrix () const;
00107
00108 protected:
00109 SbViewVolume viewVolume;
00110 };
00111
00112 class GuiExport Tessellator
00113 {
00114 public:
00115 Tessellator(const std::vector<SbVec2f>&);
00116 std::vector<int> tessellate() const;
00117
00118 private:
00119 static void tessCB(void * v0, void * v1, void * v2, void * cbdata);
00120
00121 private:
00122 std::vector<SbVec2f> polygon;
00123 };
00124
00125 class GuiExport ItemViewSelection
00126 {
00127 public:
00128 ItemViewSelection(QAbstractItemView* view);
00129 void applyFrom(const std::vector<App::DocumentObject*> objs);
00130
00131 private:
00132 QAbstractItemView* view;
00133 class MatchName;
00134 };
00135
00136 }
00137
00138 #endif // GUI_UTILITIES_H