~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Sketcher/Gui/ViewProviderSketchSF.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2010-01-11 08:48:33 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100111084833-4g9vgdqbkw8u34zb
Tags: 0.9.2646.5-1
* New upstream version (closes: #561696).
* Added swig to Build-Depends (closes: #563523, #563772).
* Removed python-opencv from Build-Depends and Recommends (closes: #560768).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (c) 2009 J�rgen Riegel <juergen.riegel@web.de>              *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This library is free software; you can redistribute it and/or         *
 
7
 *   modify it under the terms of the GNU Library General Public           *
 
8
 *   License as published by the Free Software Foundation; either          *
 
9
 *   version 2 of the License, or (at your option) any later version.      *
 
10
 *                                                                         *
 
11
 *   This library  is distributed in the hope that it will be useful,      *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU Library General Public License for more details.                  *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU Library General Public     *
 
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
 
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
 
 
24
#ifndef SKETCHERGUI_VIEWPROVIDERSKETCH_H
 
25
#define SKETCHERGUI_VIEWPROVIDERSKETCH_H
 
26
 
 
27
#include <Mod/Part/Gui/ViewProvider2DObject.h>
 
28
#include <Inventor/SbColor.h>
 
29
 
 
30
 
 
31
class TopoDS_Shape;
 
32
class TopoDS_Face;
 
33
class SoSeparator;
 
34
class SbVec3f;
 
35
class SoCoordinate3;
 
36
class SoPointSet;
 
37
class SoTransform;
 
38
class SoLineSet;
 
39
 
 
40
namespace Gui {
 
41
    class View3DInventorViewer;
 
42
    class SoFCSelection;
 
43
}
 
44
 
 
45
namespace Sketcher {
 
46
    class SketchFlatInterface;
 
47
    class SketchObjectSF;
 
48
}
 
49
 
 
50
namespace SketcherGui {
 
51
 
 
52
 
 
53
class SketcherGuiExport ViewProviderSketchSF : public PartGui::ViewProvider2DObject
 
54
{
 
55
    PROPERTY_HEADER(PartGui::ViewProviderSketchSF);
 
56
 
 
57
public:
 
58
        /// constructor
 
59
        ViewProviderSketchSF();
 
60
        /// destructor
 
61
        virtual ~ViewProviderSketchSF();
 
62
 
 
63
        virtual void attach(App::DocumentObject *);
 
64
        virtual void updateData(const App::Property*);
 
65
 
 
66
        virtual bool setEdit(int ModNum);
 
67
        virtual void unsetEdit(void);
 
68
 
 
69
        /// Is called by the tree if the user double click on the object
 
70
        virtual bool doubleClicked(void);
 
71
 
 
72
        /// is called when the Provider is in edit and the mouse is moved
 
73
        virtual bool mouseMove(const SbVec3f &pNear, const SbVec3f &pFar, const SoPickedPoint* pp);
 
74
        /// is called when the Provider is in edit and a key event ocours. Only ESC ends edit.
 
75
        virtual bool keyPressed(int key);
 
76
        /// is called when the Provider is in edit and the mouse is clicked 
 
77
        virtual bool mouseButtonPressed(int Button, bool pressed, const SbVec3f &point,
 
78
        const SbVec3f &normal, const SoPickedPoint* pp);
 
79
        /// draw the sketch in the inventor nodes
 
80
        void draw(void);
 
81
 
 
82
        /// give the coordinates of a line on the sketch plane in sketcher (2D) coordinates
 
83
        void getCoordsOnSketchPlane(double &u, double &v,const SbVec3f &point, const SbVec3f &normal);
 
84
    /// helper to detect preselection
 
85
    bool handlePreselection(const SoPickedPoint* pp);
 
86
        /// set constrain table
 
87
        enum {
 
88
                CONSTRAIN_LOCK,
 
89
                CONSTRAIN_HORIZONTAL,
 
90
                CONSTRAIN_VERTICAL
 
91
        };
 
92
        /// is called by the GuiCommands to set the constraints on the selected items:
 
93
        bool setConstrainOnSelected(int Constrain);
 
94
 
 
95
        /// mode table
 
96
        enum {
 
97
                STATUS_NONE,
 
98
                STATUS_SKETCH_CreateArc,
 
99
                STATUS_SKETCH_CreateCircle,
 
100
                STATUS_SKETCH_CreateLine,
 
101
                STATUS_SKETCH_CreatePolyline,
 
102
                STATUS_SKETCH_CreateRectangle,
 
103
                STATUS_SKETCH_CreateText,
 
104
                STATUS_SKETCH_DragPoint,
 
105
                STATUS_SKETCH_DoLine,
 
106
                STATUS_SKETCH_DoPolyline
 
107
        };
 
108
        /// is called by GuiCommands to set the drawing mode
 
109
        void setSketchMode(int mode);
 
110
        /// get the sketch mode
 
111
        int getSketchMode(void){return Mode;}
 
112
 
 
113
 
 
114
    Sketcher::SketchObjectSF* getSketchObjectSF(void);
 
115
 
 
116
protected:
 
117
    /// helper to detect whether the picked point lies on the sketch
 
118
    bool isPointOnSketch(const SoPickedPoint* pp) const;
 
119
    /// get called by the container whenever a property has been changed
 
120
    virtual void onChanged(const App::Property* prop);
 
121
 
 
122
    // helper
 
123
    void createEditInventorNodes(void);
 
124
 
 
125
    // modes while sketching
 
126
    int Mode;
 
127
    // dragged point
 
128
    int DragPoint;
 
129
 
 
130
    int PreselectCurve;
 
131
    SbColor PreselectOldColor;
 
132
    int PreselectPoint;
 
133
    // pointer to the Solver
 
134
    Sketcher::SketchFlatInterface *SketchFlat;
 
135
 
 
136
    // nodes for the visuals 
 
137
    SoMaterial    *PointsMaterials;
 
138
    SoMaterial    *CurvesMaterials;
 
139
    SoMaterial    *LinesMaterials;
 
140
    SoCoordinate3 *PointsCoordinate;
 
141
    SoCoordinate3 *CurvesCoordinate;
 
142
    SoCoordinate3 *LinesCoordinate;
 
143
    SoLineSet     *CurveSet;
 
144
    SoLineSet     *LineSet;
 
145
    SoPointSet    *PointSet;
 
146
    SoSeparator   *EditRoot;
 
147
};
 
148
 
 
149
} // namespace PartGui
 
150
 
 
151
 
 
152
#endif // SKETCHERGUI_VIEWPROVIDERSKETCH_H
 
153