]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actiondimension.h
f207d86c824de01ff912a6178d84f84c35b82ce5
[architektonas] / src / actions / rs_actiondimension.h
1 /****************************************************************************
2 ** $Id: rs_actiondimension.h 1119 2004-04-12 22:44:04Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the qcadlib Library project.
7 **
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
12 **
13 ** Licensees holding valid qcadlib Professional Edition licenses may use 
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #ifndef RS_ACTIONDIMENSION_H
28 #define RS_ACTIONDIMENSION_H
29
30 #include "rs_previewactioninterface.h"
31 #include "rs_dimension.h"
32
33 /**
34  * Base class for dimension actions.
35  *
36  * @author Andrew Mustun
37  */
38 class RS_ActionDimension : public RS_PreviewActionInterface {
39     //Q_OBJECT
40 public:
41     RS_ActionDimension(const char* name,
42                        RS_EntityContainer& container,
43                        RS_GraphicView& graphicView);
44     ~RS_ActionDimension();
45
46     virtual void reset();
47
48     virtual void init(int status=0);
49
50     virtual void hideOptions();
51     virtual void showOptions();
52
53     virtual void updateMouseCursor();
54     virtual void updateToolBar();
55
56     QString getText() {
57                 if (!data.text.isEmpty()) {
58                         return data.text;
59                 }
60         
61         QString l = label;
62
63         if (l.isEmpty() &&
64             (diameter==true || !tol1.isEmpty() || !tol2.isEmpty())) {
65             l = "<>";
66         }
67
68         if (diameter==true) {
69             l = QChar(0x2205) + l;
70         }
71
72         if (!tol1.isEmpty() || !tol2.isEmpty()) {
73             l += QString("\\S%1\\%2;").arg(tol1).arg(tol2);
74         }
75
76         return l;
77     }
78         
79     void setText(const QString& t) {
80         data.text = t;
81         }
82
83         QString getLabel() {
84                 return label;
85         }
86     void setLabel(const QString& t) {
87         //data.text = t;
88         label = t;
89     }
90         QString getTol1() {
91                 return tol1;
92         }
93     void setTol1(const QString& t) {
94         tol1 = t;
95     }
96         QString getTol2() {
97                 return tol2;
98         }
99     void setTol2(const QString& t) {
100         tol2 = t;
101     }
102         bool getDiameter() {
103                 return diameter;
104         }
105     void setDiameter(bool d) {
106         diameter = d;
107     }
108
109     static bool isDimensionAction(RS2::ActionType type) {
110         return (type==RS2::ActionDimAligned ||
111                 type==RS2::ActionDimLinear ||
112                 type==RS2::ActionDimAngular ||
113                 type==RS2::ActionDimDiametric ||
114                 type==RS2::ActionDimRadial);
115     }
116
117 protected:
118     /**
119      * Generic dimension data.
120      */
121     RS_DimensionData data;
122
123     QString label;
124     QString tol1;
125     QString tol2;
126     bool diameter;
127
128
129     /**
130      * Commands.
131      */
132     /*
133       QString cmdText;
134       QString cmdText2;
135     */
136 };
137
138 #endif