00001 #ifndef TDPOINT_H
00002 #define TDPOINT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "QGLViewer/vec.h"
00012 #include "SelectableThing.h"
00013 #include <QGLViewer/qglviewer.h>
00014 #include <qobject.h>
00015
00016 using namespace std;
00017 using namespace qglviewer;
00019 class TDPoint : public SelectableThing
00020 {
00025 public :
00028 bool IsAPoint(){return true;};
00031 bool IsAPatch(){return false;};
00034 TDPoint* GetPoint(){return this;};
00037 BaryPatch* GetPatch(){return NULL;};
00039 TDPoint(int ThingName, SelectableThing** Workspace): SelectableThing(ThingName,Workspace)
00040 {
00041 };
00043 TDPoint(int ThingName, SelectableThing** Workspace, Vec Position): SelectableThing(ThingName,Workspace)
00044 {
00045 _ThingGlobalFrame.setPosition(Position);
00046 };
00053 void draw(ManipulatedFrame* MF)
00054 {
00055 if(_IsSelected)
00056
00057
00058
00059 {
00060 glColor3f(_Color[0], _Color[1], _Color[2]);
00061
00062 _ThingGlobalFrame.setPosition(MF->inverseCoordinatesOf(_ThingLocalFrame.position()));
00063 }
00064 else
00065
00066
00067
00068 {
00069 glColor3f(_Color[0]/2., _Color[1]/2., _Color[2]/2.);
00070
00071 _ThingLocalFrame.setPosition(MF->coordinatesOf(_ThingGlobalFrame.position()));
00072 }
00073 glPushName(_ThingName);
00074 glPushMatrix();
00075 glMultMatrixd(_ThingGlobalFrame.matrix());
00076 glutSolidSphere(0.005,6,6);
00077 glPopMatrix();
00078 glPopName();
00079 }
00081 void UpdateNameTag()
00082 {
00083 _NameTag = "Point " + QString::number(WhatsMyNumber());
00084 };
00086 int WhatsMyNumber()
00087 {
00088 int CountWorkspacePoints = 0;
00089 for(int i=0;i<_ThingName;i++)
00090 {
00091 if ((_Workspace[i])&&(_Workspace[i]->IsAPoint()))
00092 CountWorkspacePoints++;
00093 }
00094 return CountWorkspacePoints;
00095 };
00098 int Clear()
00099 {
00100
00101
00102 };
00104 void SnapToGrid(float GridSpace, ManipulatedFrame* MF)
00105 {
00106
00107 Vec Pos = _ThingGlobalFrame.position();
00108 _ThingGlobalFrame.setPosition(Round(Pos[0]/GridSpace)*GridSpace,Round(Pos[1]/GridSpace)*GridSpace,Round(Pos[2]/GridSpace)*GridSpace);
00109 _ThingLocalFrame.setPosition(MF->coordinatesOf(_ThingGlobalFrame.position()));
00110 }
00111 };
00112 #endif