iselection.h
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #if !defined(INCLUDED_ISELECTION_H)
00027 #define INCLUDED_ISELECTION_H
00028
00029 #include <cstddef>
00030 #include "generic/constant.h"
00031 #include "generic/callbackfwd.h"
00032 #include "signal/signalfwd.h"
00033
00034 class Renderer;
00035 class View;
00036
00041 class Selectable
00042 {
00043 public:
00044 STRING_CONSTANT(Name, "Selectable");
00045
00046 virtual ~Selectable ()
00047 {
00048 }
00049
00050
00051 virtual void setSelected (bool select) = 0;
00052
00053 virtual bool isSelected () const = 0;
00054
00055
00056
00057 };
00058
00059 namespace scene
00060 {
00061 class Instance;
00062 }
00063 ;
00064
00065 class InstanceSelectionObserver
00066 {
00067 public:
00068 virtual ~InstanceSelectionObserver ()
00069 {
00070 }
00071
00072 virtual void onSelectedChanged (scene::Instance& instance) = 0;
00073 };
00074
00075 template<typename Element> class BasicVector3;
00076 typedef BasicVector3<float> Vector3;
00077 template<typename Element> class BasicVector4;
00078 typedef BasicVector4<float> Vector4;
00079 class Matrix4;
00080 typedef Vector4 Quaternion;
00081
00082 typedef Callback1<const Selectable&> SelectionChangeCallback;
00083 typedef SignalHandler1<const Selectable&> SelectionChangeHandler;
00084
00085 class SelectionSystem
00086 {
00087 public:
00088 INTEGER_CONSTANT(Version, 1);
00089 STRING_CONSTANT(Name, "selection");
00090
00091 enum EMode
00092 {
00093 eEntity,
00094 ePrimitive,
00095 eComponent,
00097 };
00098
00099
00100 enum EComponentMode
00101 {
00102 eDefault, eVertex, eEdge, eFace,
00103 };
00104
00105
00106 enum EManipulatorMode
00107 {
00108 eTranslate, eRotate, eScale, eDrag, eClip,
00109 };
00110
00111 virtual ~SelectionSystem ()
00112 {
00113 }
00114
00115 virtual void SetMode (EMode mode) = 0;
00116 virtual EMode Mode () const = 0;
00117 virtual void SetComponentMode (EComponentMode mode) = 0;
00118 virtual EComponentMode ComponentMode () const = 0;
00119 virtual void SetManipulatorMode (EManipulatorMode mode) = 0;
00120 virtual EManipulatorMode ManipulatorMode () const = 0;
00121
00122 virtual SelectionChangeCallback getObserver (EMode mode) = 0;
00123
00124 virtual std::size_t countSelected () const = 0;
00125
00126 virtual std::size_t countSelectedComponents () const = 0;
00127
00128 virtual std::size_t countSelectedFaces () const = 0;
00129
00130 virtual bool areFacesSelected () const = 0;
00131 virtual void onSelectedChanged (scene::Instance& instance, const Selectable& selectable) = 0;
00132 virtual void onComponentSelection (scene::Instance& instance, const Selectable& selectable) = 0;
00133 virtual scene::Instance& ultimateSelected () const = 0;
00134 virtual scene::Instance& penultimateSelected () const = 0;
00142 virtual void setSelectedAll (bool selected) = 0;
00143 virtual void setSelectedAllComponents (bool selected) = 0;
00144
00152 class Visitor
00153 {
00154 public:
00155 virtual ~Visitor ()
00156 {
00157 }
00158
00162 virtual void visit (scene::Instance& instance) const = 0;
00163 };
00167 virtual void foreachSelected (const Visitor& visitor) const = 0;
00171 virtual void foreachSelectedComponent (const Visitor& visitor) const = 0;
00172
00173 virtual void addSelectionChangeCallback (const SelectionChangeHandler& handler) = 0;
00174
00175 virtual void NudgeManipulator (const Vector3& nudge, const Vector3& view) = 0;
00176
00177 virtual void translateSelected (const Vector3& translation) = 0;
00178 virtual void rotateSelected (const Quaternion& rotation) = 0;
00179 virtual void scaleSelected (const Vector3& scaling) = 0;
00180
00181 virtual void pivotChanged () const = 0;
00182 };
00183
00184 #include "modulesystem.h"
00185
00186 template<typename Type>
00187 class GlobalModule;
00188 typedef GlobalModule<SelectionSystem> GlobalSelectionModule;
00189
00190 template<typename Type>
00191 class GlobalModuleRef;
00192 typedef GlobalModuleRef<SelectionSystem> GlobalSelectionModuleRef;
00193
00194 inline SelectionSystem& GlobalSelectionSystem ()
00195 {
00196 return GlobalSelectionModule::getTable();
00197 }
00198
00199 #endif