00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef __FK_SHAPE_VIEWER_HEADER__
00073 #define __FK_SHAPE_VIEWER_HEADER__
00074
00075 #include <FK/Window.h>
00076 #include <FK/MatExample.h>
00077 #include <FK/Line.h>
00078 #include <FK/Texture.h>
00079 #include <FK/Model.h>
00080 #include <FK/Light.h>
00081 #include <FK/Scene.h>
00082 #include <map>
00083
00084 #ifndef FK_DOXYGEN_USER_PROCESS
00085
00086 enum fk_ShapeGUIMenuItem {
00087 FK_SV_GUI_NONE,
00088 FK_SV_GUI_WRLOPEN,
00089 FK_SV_GUI_STLOPEN,
00090 FK_SV_GUI_DXFOPEN,
00091 FK_SV_GUI_WRLSAVE,
00092 FK_SV_GUI_STLSAVE,
00093 FK_SV_GUI_IMAGESNAP,
00094 FK_SV_GUI_QUIT,
00095 FK_SV_GUI_POLYDRAW,
00096 FK_SV_GUI_EDGEDRAW,
00097 FK_SV_GUI_VERTEXDRAW,
00098 FK_SV_GUI_LIGHTROTATE,
00099 FK_SV_GUI_AXISDRAW,
00100 FK_SV_GUI_AMBIENT,
00101 FK_SV_GUI_DIFFUSE,
00102 FK_SV_GUI_SPECULAR,
00103 FK_SV_GUI_EMISSION,
00104 FK_SV_GUI_SHININESS,
00105 FK_SV_GUI_VERTEXCOLOR,
00106 FK_SV_GUI_EDGECOLOR
00107 };
00108
00109 class fk_GUI_;
00110
00111 #endif
00112
00114
00150 class fk_ShapeViewer : public fk_BaseObject {
00151 private:
00152
00153 fk_Dimension fkWinSize;
00154 fk_Dimension allWinSize;
00155 fk_Dimension groupPos;
00156 fk_Dimension mousePos;
00157
00158 int mouseX, mouseY;
00159
00160
00161 Fl_Window *mainWindow;
00162 fk_Window *viewWin;
00163
00164
00165 fk_GUI_ *gui;
00166
00167
00168 bool changeFlag;
00169 bool lightFlag;
00170 bool materialFlag;
00171 bool moveFlag;
00172 bool oldMoveFlag;
00173 fk_DrawMode drawMode;
00174
00175
00176 fk_Model parentModel;
00177 std::vector<fk_Model *> modelArray;
00178 std::map<int, int> IDMap;
00179 fk_Model lightModel[2], camera, axisModel;
00180 fk_Solid localSolid;
00181 fk_Line axisLine;
00182 fk_Light light;
00183 fk_Scene scene;
00184 std::vector<fk_Material *> polyMaterial;
00185 std::vector<fk_Color *> edgeColor;
00186 std::vector<fk_Color *> vertexColor;
00187
00188 void InitValue(void);
00189 void InitFlag(void);
00190 void InitWindow(void);
00191 void InitGUI(void);
00192 void LightInit(void);
00193 void AxisInit(void);
00194 void ViewInit(void);
00195 void ModelInit(int, fk_Shape *);
00196 void RotateLight(double);
00197 bool MenuSelect(void);
00198 void SetOrientation(double, double, double, double);
00199 void SetAxisLine(double);
00200 void MovePosition(double, double, double);
00201 void DragShape(void);
00202 void KeyHandle(void);
00203 std::string CommonFileChooser(std::string, int, std::string);
00204 void SetAllMaterial(void);
00205 void SetSceneFlg(fk_ShapeGUIMenuItem);
00206
00207 void GetMaterial(int, fk_ShapeGUIMenuItem,
00208 double *, double *, double *);
00209 void SetMaterial(int, fk_ShapeGUIMenuItem,
00210 double, double, double);
00211 void SetDrawMode(void);
00212
00213 public:
00215
00222 fk_ShapeViewer(int w = 300, int h = 360);
00223
00225 virtual ~fk_ShapeViewer();
00226
00228
00229
00231
00250 bool draw(void);
00251
00253
00259 void setWindowSize(int w, int h);
00260
00261
00263
00265
00274 void setShape(fk_Shape *shape);
00275
00277
00287 void setShape(int ID, fk_Shape *shape);
00288
00290
00299 fk_Shape * getShape(int ID = 0);
00300
00302
00307 int getModelNum(void);
00308
00310
00313 void clearModel(void);
00314
00316
00329 virtual bool shapeProcess(fk_Solid *shape);
00330
00331
00333
00334
00336
00364 void setDrawMode(fk_DrawMode mode);
00365
00367
00374 fk_DrawMode getDrawMode(void);
00375
00377
00384 void setBGColor(fk_Color col);
00385
00387
00398 void setBGColor(float r, float g, float b);
00399
00401
00408 fk_Color getBGColor(void);
00409
00411
00417 void setAxisScale(double scale);
00418
00420
00427 double getAxisScale(void);
00428
00430
00435 fk_Vector getCenter(void);
00436
00437
00439
00440
00442
00471 void setDrawMode(int ID, fk_DrawMode mode);
00472
00474
00483 fk_DrawMode getDrawMode(int ID);
00484
00486
00493 void setLineWidth(int ID, double width);
00494
00496
00506 double getLineWidth(int ID);
00507
00509
00516 void setPointSize(int ID, double size);
00517
00519
00529 double getPointSize(int ID);
00530
00532
00540 void setMaterial(int ID, fk_Material mat);
00541
00543
00551 void setEdgeColor(int ID, fk_Color col);
00552
00554
00562 void setVertexColor(int ID, fk_Color col);
00563
00564
00565
00567
00568
00570
00579 void setHead(double angle);
00580
00582
00589 double getHead(void);
00590
00592
00601 void setPitch(double angle);
00602
00604
00611 double getPitch(void);
00612
00614
00623 void setBank(double angle);
00624
00626
00633 double getBank(void);
00634
00636
00643 void setScale(double scale);
00644
00646
00653 double getScale(void);
00654
00655
00656
00658
00659
00661
00671 void setPosition(int ID, fk_Vector pos);
00672
00674
00686 void setPosition(int ID, double x, double y, double z);
00687
00689
00700 void setAngle(int ID, fk_Angle angle);
00701
00703
00717 void setAngle(int ID, double h, double p, double b);
00718
00720
00731 void setVec(int ID, fk_Vector vec);
00732
00734
00747 void setVec(int ID, double x, double y, double z);
00748
00750
00761 void setUpvec(int ID, fk_Vector vec);
00762
00764
00777 void setUpvec(int ID, double x, double y, double z);
00778
00779
00781
00782
00784
00810 void setFrameMode(fk_FrameMode mode);
00811
00813
00820 fk_FrameMode getFrameMode(void);
00821
00823
00839 void setFrameInterval(int ms);
00840
00842
00849 int getFrameInterval(void);
00850
00852
00861 int getSkipFrame(void);
00862
00863
00865
00866
00867
00869
00887 bool snapImage(std::string fileName,
00888 fk_ImageType format = FK_IMAGE_BMP,
00889 fk_SnapProcMode mode = FK_SNAP_GL_FRONT);
00890
00892
00908 bool snapImage(fk_Image *image,
00909 fk_SnapProcMode mode = FK_SNAP_GL_FRONT);
00910
00911
00913
00914
00916
00922 void setPutStrMode(const fk_PutStrMode mode);
00923
00925
00931 fk_PutStrMode getPutStrMode(void);
00932
00934
00940 bool setPutFile(const std::string &str);
00941
00943
00949 void putString(const std::string &str);
00950
00952
00958 void printf(const char *format, ...);
00959
00961
00967 void clearBrowser(void);
00968
00969 };
00970
00971 #endif // !__FK_SHAPE_VIEWER_HEADER__