QtSingleRegionShape.qo.h
Go to the documentation of this file.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 #ifndef QTSINGLEREGIONSHAPE_QO_H
00028 #define QTSINGLEREGIONSHAPE_QO_H
00029
00030 #include <QWidget>
00031
00032 #include <display/RegionShapes/QtSingleRegionShape.ui.h>
00033 #include <display/RegionShapes/QtEditRegionShape.ui.h>
00034
00035 #include <display/RegionShapes/RegionShape.h>
00036 #include <display/RegionShapes/RSUtils.qo.h>
00037
00038 #include <casa/namespace.h>
00039
00040 namespace casa {
00041
00042 class QtRegionShapeManager;
00043 class QtDisplayPanel;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 class QtSingleRegionShape : public QWidget, Ui::SingleRegionShape {
00054 Q_OBJECT
00055
00056 friend class QtEditRegionShape;
00057
00058 public:
00059
00060
00061
00062
00063 QtSingleRegionShape(RegionShape* shape, QtRegionShapeManager* parent,
00064 bool reportDrawErrors = false,
00065 RegionShape* compositeParent = NULL);
00066
00067
00068 ~QtSingleRegionShape();
00069
00070
00071 RegionShape* shape();
00072
00073
00074 RegionShape* compositeParent();
00075
00076
00077 QtRegionShapeManager* manager();
00078
00079
00080 QtDisplayPanel* panel();
00081
00082
00083
00084 void setShouldDelete(bool shouldDelete = true);
00085
00086
00087 void refresh();
00088
00089
00090
00091 bool isShown() const;
00092
00093
00094 void showHide(bool show, bool reportErrors = true);
00095
00096 public slots:
00097
00098 void edit();
00099
00100 private:
00101 RegionShape* m_shape;
00102 RegionShape* m_compositeParent;
00103 QtRegionShapeManager* m_parent;
00104 QtDisplayPanel* m_panel;
00105 bool m_shouldDelete;
00106
00107
00108
00109 void setupGUI();
00110
00111
00112 void registerShape();
00113
00114
00115 void unregisterShape();
00116
00117 private slots:
00118
00119 void showHide_(bool show) {
00120 showHide(show, true);
00121 }
00122
00123
00124
00125 void deleteShape();
00126 };
00127
00128
00129
00130
00131 class QtRSOption : public QHBoxLayout {
00132 Q_OBJECT
00133
00134 public:
00135
00136 QtRSOption(RegionShape::OptionType type, const String& name,
00137 const RSOption& value, const vector<String>& choices);
00138
00139
00140 ~QtRSOption();
00141
00142
00143 RSOption value() const;
00144
00145 private:
00146
00147 RegionShape::OptionType m_type;
00148
00149
00150
00151 QLineEdit* m_string;
00152 QComboBox* m_choice;
00153 QDoubleSpinBox* m_double;
00154 QCheckBox* m_bool;
00155 vector<QLineEdit*> m_stringArray;
00156 vector<QComboBox*> m_choiceArray;
00157 vector<String> m_choices;
00158 QToolButton* m_lessButton, *m_moreButton;
00159
00160
00161 private slots:
00162
00163 void moreArray();
00164
00165
00166 void lessArray();
00167 };
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 class QtEditRegionShape : public QWidget, Ui::EditRegionShape {
00180 Q_OBJECT
00181
00182 public:
00183
00184
00185
00186
00187 static const String SEXAGESIMAL;
00188 static const String UNKNOWN;
00189
00190
00191
00192 static vector<String> systems() {
00193 static vector<String> v(6);
00194 v[0] = MDirection::showType(MDirection::B1950);
00195 v[1] = MDirection::showType(MDirection::J2000);
00196 v[2] = MDirection::showType(MDirection::GALACTIC);
00197 v[3] = MDirection::showType(MDirection::SUPERGAL);
00198 v[4] = MDirection::showType(MDirection::ECLIPTIC);
00199 v[5] = RSUtils::PIXEL;
00200 return v;
00201 }
00202
00203 static QComboBox* systemsChooser() {
00204 vector<String> v = systems();
00205 QComboBox* b = new QComboBox();
00206 for(unsigned int i = 0; i < v.size(); i++) b->addItem(v[i].c_str());
00207 return b;
00208 }
00209
00210
00211
00212
00213
00214 QtEditRegionShape(QtSingleRegionShape* shape);
00215
00216
00217
00218 QtEditRegionShape(RegionShape* shape, QtRegionShapeManager* manager,
00219 QWidget* coordWidget = NULL, bool showPosition = true,
00220 bool showSize = true, String applyButtonText = "");
00221
00222
00223 ~QtEditRegionShape();
00224
00225
00226
00227
00228
00229 String chosenCoordinateSystem() const;
00230 String chosenPositionUnit() const;
00231 String chosenSizeUnit() const;
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 bool enteredCoordinatesAreValid(String& reason) const;
00242
00243 public slots:
00244
00245 void apply();
00246
00247 signals:
00248
00249
00250 void applyClicked();
00251
00252 private:
00253
00254 bool m_creation;
00255
00256
00257 QtSingleRegionShape* m_shape;
00258
00259
00260 RegionShape* m_cShape;
00261
00262
00263 QtRegionShapeManager* m_manager;
00264
00265
00266 vector<QLineEdit*> m_coordEdits;
00267
00268
00269 vector<RegionShape::CoordinateParameterType> m_coordTypes;
00270
00271
00272 String m_lastSystem, m_lastPosUnit, m_lastSizeUnit;
00273
00274
00275 QtColorWidget* m_lineColor;
00276
00277
00278 QtColorWidget* m_ltColor;
00279
00280
00281 QtColorWidget* m_labelColor;
00282
00283
00284 vector<QtRSOption*> m_optWidgets;
00285
00286
00287 vector<RegionShape::OptionType> m_optTypes;
00288
00289
00290
00291 void init(QWidget* coordWidget = NULL, bool showPosition = true,
00292 bool showSize = true, String applyButtonText = "");
00293
00294
00295
00296 void setupGui();
00297
00298
00299
00300
00301 double convertToRS(int index, bool& ok) const;
00302
00303
00304
00305 void displayCoordinates(const vector<double>& coords);
00306
00307
00308
00309
00310
00311 static vector<String> positionUnits() {
00312 static vector<String> v(5);
00313 v[0] = RSValue::DEG;
00314 v[1] = RSValue::RAD;
00315 v[2] = SEXAGESIMAL;
00316 v[3] = RSValue::HMS;
00317 v[4] = RSValue::DMS;
00318 return v;
00319 }
00320
00321
00322 static vector<String> sizeUnits() {
00323 static vector<String> v(4);
00324 v[0] = RSValue::DEG;
00325 v[1] = RSValue::RAD;
00326 v[2] = RSValue::ARCSEC;
00327 v[3] = RSValue::ARCMIN;
00328 return v;
00329 }
00330
00331 private slots:
00332
00333
00334 void coordSystemChanged();
00335
00336
00337 void coordReset();
00338
00339
00340 void linethrough();
00341
00342
00343 void applySlot() {
00344 if(m_creation) emit applyClicked();
00345 else apply();
00346 }
00347 };
00348
00349 }
00350
00351 #endif