00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _CIvfFltkWidget_h_
00023 #define _CIvfFltkWidget_h_
00024
00025
00026
00027 #include <ivf/ivfconfig.h>
00028
00029
00030
00031 #include <FL/Fl.H>
00032 #include <FL/gl.h>
00033 #include <GL/glu.h>
00034 #include <FL/Fl_Gl_Window.H>
00035
00036 namespace std {};
00037 using namespace std;
00038
00039
00040
00041 #define IVF_SNAP_ON 0
00042 #define IVF_SNAP_OFF 1
00043
00044
00045
00046 #define IVF_UNKNOWN 0
00047 #define IVF_NODE 1
00048 #define IVF_SOLID_LINE 2
00049
00050
00051
00052 #define IVF_NO_SELECTED_NODES 1001
00053 #define IVF_NODE_CONNECTED 1002
00054 #define IVF_INVALID_NODE_SELECTION 1003
00055 #define IVF_INVALID_SHAPE_SELECTION 1004
00056 #define IVF_INVALID_SELECTION 1005
00057 #define IVF_NO_SELECTED_SHAPES 1006
00058
00059
00060
00061 #define IVF_SELECT 0
00062 #define IVF_SIMPLE_SELECT 500
00063 #define IVF_VIEW 1000
00064 #define IVF_VIEW_ZOOM 1001
00065 #define IVF_VIEW_PAN 1002
00066 #define IVF_CAMERA_TARGET 2010
00067 #define IVF_MOVE 4001
00068 #define IVF_CREATE 3000
00069 #define IVF_CREATE_NODE 3005
00070 #define IVF_CREATE_LINE 3006
00071 #define IVF_CREATE_OBJECT 3500
00072 #define IVF_MANIPULATE 5000
00073
00074
00075
00076 #define IVF_TRANS_MANIP 1000
00077 #define IVF_ROT_MANIP 2000
00078
00079 #define IVF_USER_MODE 10000
00080
00081
00082
00083 #define IVF_BUTTON1 0
00084 #define IVF_BUTTON2 1
00085 #define IVF_BUTTON3 2
00086 #define IVF_NO_BUTTON -1
00087 #define IVF_SHIFT 0
00088 #define IVF_CTRL 1
00089
00090 #include <ivf/IvfBase.h>
00091 #include <ivf/IvfComposite.h>
00092 #include <ivf/IvfCamera.h>
00093 #include <ivf/IvfCulledScene.h>
00094 #include <ivf/IvfExtrusion.h>
00095 #include <ivf/IvfNode.h>
00096 #include <ivf/IvfShape.h>
00097 #include <ivf/IvfBrick.h>
00098 #include <ivf/IvfSolidLine.h>
00099 #include <ivf/IvfWorkspace.h>
00100
00101
00102
00103
00104
00105
00106 #include <ivfmath/IvfPlane.h>
00107 #include <ivfmath/IvfPoint3d.h>
00108
00109 IvfSmartPointer(CIvfFltkWidget);
00110
00123 class IVFFLTK_API CIvfFltkWidget : public Fl_Gl_Window, CIvfBase
00124 {
00125 private:
00126
00127
00128
00129 int m_moving, m_beginX, m_beginY;
00130
00131 int m_currentButton;
00132 int m_currentState;
00133 int m_currentModifier;
00134
00135 int m_editMode;
00136 int m_clickNumber;
00137 int m_snapMode;
00138 bool m_snapToGrid;
00139
00140 int m_manipulatorMode;
00141
00142 double m_workspaceSize;
00143
00144 GLfloat m_angleX;
00145 GLfloat m_angleY;
00146 GLfloat m_moveX;
00147 GLfloat m_moveY;
00148 GLfloat m_zoomX;
00149 GLfloat m_zoomY;
00150
00151 double m_startPos[3];
00152 double m_endPos[3];
00153
00154 double m_manipStartPos[3];
00155 double m_manipEndPos[3];
00156 double m_snapUnit;
00157
00158 double m_rotX, m_rotY, m_rotZ;
00159
00160 CIvfPoint3d m_brick1;
00161 CIvfPoint3d m_brick2;
00162
00163 long m_nNodes;
00164 long m_nLines;
00165
00166 bool m_doOverlay;
00167 bool m_editEnabled;
00168 bool m_selectEnabled;
00169 bool m_initDone;
00170
00171 double m_controlSize;
00172
00173
00174
00175 CIvfWorkspacePtr m_scene;
00176 CIvfShapePtr m_selectedShape;
00177 CIvfCameraPtr m_camera;
00178 CIvfCompositePtr m_selectedShapes;
00179 CIvfLightingPtr m_lighting;
00180 CIvfShapePtr m_lastShape;
00181
00182 protected:
00183
00189 void draw();
00190
00196 int handle(int event);
00197
00198 public:
00209 CIvfFltkWidget(int X, int Y, int W, int H, const char *L=0);
00210
00212 virtual ~CIvfFltkWidget();
00213
00214 IvfClassInfo("CIvfFltkWidget", CIvfBase);
00215
00217 CIvfCamera* getCamera();
00218
00226 void addToScene(CIvfShape* shape);
00227
00233 void deleteSelected();
00234 void deleteSelectedKeep();
00235
00247 void manipulateSelected(int mode);
00248
00250 int getManipulatorMode();
00251
00258 void createLine();
00259
00261 void centerSelected();
00262
00268 void deleteAll();
00269
00271 void resetView();
00272
00273 void clearSelection();
00274 void selectAll();
00275
00289 void setEditMode(int mode);
00290
00292 int getEditMode();
00293
00302 void setWorkspace(double size);
00303
00305 double getWorkspace();
00306
00308 CIvfWorkspace* getScene();
00309
00311 bool getUseOverlay();
00312
00314 void setUseOverlay(bool flag);
00315
00317 void setSelectEnable(bool flag);
00318
00320 void setEditEnabled(bool flag);
00321
00323 void setSnapToGrid(bool flag);
00324
00326 bool getSnapToGrid();
00327
00329 int getCurrentMouseButton();
00330 int getCurrentModifier();
00331
00332 CIvfComposite* getSelectedShapes();
00333
00334 bool isInitialized();
00335
00336 protected:
00337
00338
00339
00340 virtual void doMouseUp(int x, int y);
00341 virtual void doMouseDown(int x, int y);
00342 virtual void doPassiveMotion(int x, int y);
00343 virtual void doMotion(int x, int y);
00344 virtual void doMouse(int x, int y);
00345
00353 virtual void onInit();
00354
00360 virtual void onDestroy();
00361
00384 virtual void onCreateNode(double x, double y, double z, CIvfNode* &newNode);
00385
00407 virtual void onCreateLine(CIvfNode* node1, CIvfNode* node2, CIvfShape* &newLine);
00408
00415 virtual void onSelect(CIvfComposite* selectedShapes);
00416
00422 virtual void onDeSelect();
00431 virtual void onCoordinate(double x, double y, double z);
00432
00440 virtual void onDeleteShape(CIvfShape* shape, bool &doit);
00441
00448 virtual void onInitContext();
00449
00458 virtual void onOverlay();
00459
00466 virtual void onHighlightShape(CIvfShape* shape);
00467
00477 virtual void onMove(CIvfComposite* selectedShapes, double &dx, double &dy, double &dz, bool &doit);
00478
00479 virtual void onSelectFilter(CIvfShape* shape, bool &select);
00480 virtual void onHighlightFilter(CIvfShape*, bool &highlight);
00481 virtual void onMotion(int x, int y);
00482 virtual void onPassiveMotion(int x, int y);
00483 virtual void onMouse(int x, int y);
00484 virtual void onMouseDown(int x, int y);
00485 virtual void onMouseUp(int x, int y);
00486 };
00487
00488 #endif
00489