1
/***************************************************************************
2
* Copyright (c) 2009 J�rgen Riegel <juergen.riegel@web.de> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
24
#ifndef SKETCHERGUI_VIEWPROVIDERSKETCH_H
25
#define SKETCHERGUI_VIEWPROVIDERSKETCH_H
27
#include <Mod/Part/Gui/ViewProvider2DObject.h>
28
#include <Inventor/SbColor.h>
41
class View3DInventorViewer;
46
class SketchFlatInterface;
50
namespace SketcherGui {
53
class SketcherGuiExport ViewProviderSketchSF : public PartGui::ViewProvider2DObject
55
PROPERTY_HEADER(PartGui::ViewProviderSketchSF);
59
ViewProviderSketchSF();
61
virtual ~ViewProviderSketchSF();
63
virtual void attach(App::DocumentObject *);
64
virtual void updateData(const App::Property*);
66
virtual bool setEdit(int ModNum);
67
virtual void unsetEdit(void);
69
/// Is called by the tree if the user double click on the object
70
virtual bool doubleClicked(void);
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
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
92
/// is called by the GuiCommands to set the constraints on the selected items:
93
bool setConstrainOnSelected(int Constrain);
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
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;}
114
Sketcher::SketchObjectSF* getSketchObjectSF(void);
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);
123
void createEditInventorNodes(void);
125
// modes while sketching
131
SbColor PreselectOldColor;
133
// pointer to the Solver
134
Sketcher::SketchFlatInterface *SketchFlat;
136
// nodes for the visuals
137
SoMaterial *PointsMaterials;
138
SoMaterial *CurvesMaterials;
139
SoMaterial *LinesMaterials;
140
SoCoordinate3 *PointsCoordinate;
141
SoCoordinate3 *CurvesCoordinate;
142
SoCoordinate3 *LinesCoordinate;
145
SoPointSet *PointSet;
146
SoSeparator *EditRoot;
149
} // namespace PartGui
152
#endif // SKETCHERGUI_VIEWPROVIDERSKETCH_H