VoluMillGUI/ToolpathViewer.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------------
00004 //  Copyright (c) 2007 Celeritive Technologies, Inc.
00005 //
00006 //  Licensed under the Apache License, Version 2.0 (the "License");
00007 //  you may not use this file except in compliance with the License.
00008 //  You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 //  Unless required by applicable law or agreed to in writing, software
00013 //  distributed under the License is distributed on an "AS IS" BASIS,
00014 //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 //  See the License for the specific language governing permissions and
00016 //  limitations under the License.
00017 //
00018 //-------------------------------------------------------------------
00019 
00020 #pragma once
00021 
00022 #include <Geom/Curve.h>
00023 #include <Geom/BoundingBox.h>
00024 #include <Exchange/ToolpathRecords.h>
00025 #include <GL/GLFunctions.h>
00026 #include <boost/thread/thread.hpp>
00027 #include <boost/thread/mutex.hpp>
00028 #include <gl/gl.h>
00029 
00030 struct ViewerGLData
00031 {
00032    ViewerGLData() : m_displayListId (0), m_isDisplayListDirty (true),
00033       m_tmpGraphicsDisplayListId (0), m_selection (-1, -1) {}
00034    GLuint m_displayListId;
00035    bool m_isDisplayListDirty;
00036    GLuint m_tmpGraphicsDisplayListId;
00037    double m_matrix[16];
00038    geom::BoundingBox3d m_bbox;
00039    std::vector<geom::Point3d> m_toolpathTessPts;
00040    std::pair<int, int> m_selection;
00041    geom::Point3d m_selPoint;
00042    int m_numVisibleRecords;
00043    gl::SelectedCurveInfo m_selectedCurveInfo;
00044    HGLRC m_hglrc;
00045 };
00046 
00047 // ToolpathViewer control
00048 
00049 class ToolpathViewer : public CWnd
00050 {
00051         DECLARE_DYNAMIC(ToolpathViewer)
00052 
00053 public:
00054    ToolpathViewer(
00055       const std::vector<geom::CurvePtr2d>& partBoundaries,
00056       const std::vector<geom::CurvePtr2d>& materialBoundaries,
00057       boost::shared_ptr<exchange::ToolpathRecords> pRecords,
00058       double topZ,
00059       double rapidZ,
00060       double deltaZ,
00061       int numberOfCuts, CWnd* pParent = NULL);   // standard constructor
00062         virtual ~ToolpathViewer();
00063 
00064    void oglCreate (CRect rect, CWnd* pParent);
00065 
00066 protected:
00067    // GL-related
00068    void initGL();
00069    void computeBoundingBox();
00070    void buildDisplayList();
00071    void setInitialTransformation();
00072    void renderScene();
00073    void setSelPoint(CPoint point);
00074    void getCurveInfo (std::string* pCurveInfo);
00075 
00076    virtual BOOL OnEraseBkgnd (CDC* pDC);
00077 
00078    CWnd* m_pParent;
00079    boost::shared_ptr<exchange::ToolpathRecords> m_pRecords;
00080    std::vector<geom::CurvePtr2d> m_partBoundaries;
00081    std::vector<geom::CurvePtr2d> m_materialBoundaries;
00082    double m_topZ;
00083    double m_rapidZ;
00084    double m_deltaZ;
00085    int m_numberOfCuts;
00086         // Mouse 
00087         BOOL m_leftButtonDown;
00088         BOOL m_rightButtonDown;
00089    BOOL m_middleButtonDown;
00090         CPoint m_leftDownPos;
00091         CPoint m_rightDownPos;
00092    CPoint m_middleDownPos;
00093 
00094         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00095         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00096         afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00097         afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
00098    afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
00099    afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
00100         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00101    afx_msg void OnPaint();
00102    DECLARE_MESSAGE_MAP()
00103 public:
00104    ViewerGLData m_viewerGLData;
00105    void reset();
00106    void selectLastRecord();
00107 
00108    BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint point);
00109    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00110    virtual void OnSize (UINT nType, int cx, int cy);
00111 };
00112 
00113 class ToolpathViewerDialog : public CDialog
00114 {
00115         DECLARE_DYNAMIC(ToolpathViewerDialog)
00116 
00117 public:
00118    ToolpathViewerDialog(
00119       const std::vector<geom::CurvePtr2d>& partBoundaries,
00120       const std::vector<geom::CurvePtr2d>& materialBoundaries,
00121       boost::shared_ptr<exchange::ToolpathRecords> pRecords,
00122       double topZ,
00123       double rapidZ,
00124       double deltaZ,
00125       int numberOfCuts, CWnd* pParent = NULL);   // standard constructor
00126         virtual ~ToolpathViewerDialog();
00127    virtual BOOL OnInitDialog ();
00128 
00129 // Dialog Data
00130         enum { IDD = IDD_TOOLPATH_VIEWER };
00131 
00132 protected:
00133         ToolpathViewer m_viewer;
00134    CRect m_lastClientRect;
00135 
00136    void moveWindow(CWnd* pWnd, int cx, int cy, int anchorFlags);
00137 
00138    // GL-related
00139         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00140    virtual void OnClose();
00141    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint point);
00142    afx_msg void OnSize(UINT nType, int deltax, int deltay);
00143 public:
00144    afx_msg void OnBnClickedButtonReset();
00145    DECLARE_MESSAGE_MAP()
00146    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00147    afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00148    afx_msg void OnEnKillfocusEditToolpathRecord();
00149    afx_msg void OnEnChangeEditToolpathRecord();
00150    afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
00151 };

Generated on Tue Jan 29 21:37:57 2008 for VoluMill Universal Client by  doxygen 1.4.6