QtNewRegionShape.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 QTNEWREGIONSHAPE_QO_H
00028 #define QTNEWREGIONSHAPE_QO_H
00029
00030 #include <QDialog>
00031 #include <QStackedLayout>
00032 #include <QListWidget>
00033 #include <QRadioButton>
00034 #include <QLabel>
00035
00036 #include <display/RegionShapes/QtNewRegionShape.ui.h>
00037 #include <display/RegionShapes/RegionShapes.h>
00038
00039 #include <casa/namespace.h>
00040
00041 namespace casa {
00042
00043 class QtRegionShapeManager;
00044 class QtEditRegionShape;
00045
00046
00047
00048
00049 class QtNewRegionShape : public QWidget, Ui::NewRegionShape {
00050 Q_OBJECT
00051
00052 public:
00053
00054
00055
00056 static vector<pair<String, RegionShape*> >
00057 creationShapes(bool includeComposite = true) {
00058 vector<pair<String, RegionShape*> > v(includeComposite ? 9 : 8);
00059 for(unsigned int i = 0; i < v.size(); i++)
00060 v[i] = pair<String,RegionShape*>(creationName(i),creationShape(i));
00061 return v;
00062 }
00063
00064
00065
00066
00067 std::string errorMessage( ) const { return ""; }
00068
00069 QtNewRegionShape(QtRegionShapeManager* manager,
00070 bool includeComposite = true, bool deleteOnClose = true);
00071
00072
00073 ~QtNewRegionShape();
00074
00075
00076 void showCloseButton(bool show = true);
00077
00078 signals:
00079
00080
00081
00082 void shapeCreated(RegionShape* createdShape);
00083
00084 private:
00085 QtRegionShapeManager* m_manager;
00086 vector<RegionShape*> m_shapes;
00087 QStackedLayout* m_widgets;
00088
00089 static RegionShape* creationShape(int i) {
00090 if(i < 0) return NULL;
00091 else if(i == 0) return new RSEllipse(0,0,0,0);
00092 else if(i == 1) return new RSCircle(0,0,0);
00093 else if(i == 2) return new RSRectangle(0,0,0,0);
00094 else if(i == 3)return new RSPolygon(Vector<double>(),Vector<double>());
00095 else if(i == 4) return new RSLine(0,0,0,0,7);
00096 else if(i == 5) return new RSVector(0,0,0,0,7);
00097 else if(i == 6) return new RSMarker(0,0,Display::X,10);
00098 else if(i == 7) return new RSText(0,0,"");
00099 else if(i == 8) return new RSComposite();
00100 else return NULL;
00101 }
00102 static RegionShape* creationShape(unsigned int i) {
00103 return creationShape((int)i);
00104 }
00105
00106 static String creationName(int i) {
00107 if(i < 0) return "";
00108 else if(i == 0) return "ellipse";
00109 else if(i == 1) return "circle";
00110 else if(i == 2) return "rectangle";
00111 else if(i == 3) return "polygon";
00112 else if(i == 4) return "line";
00113 else if(i == 5) return "vector";
00114 else if(i == 6) return "marker";
00115 else if(i == 7) return "text";
00116 else if(i == 8) return "composite";
00117 else return "";
00118 }
00119 static String creationName(unsigned int i) {
00120 return creationName((int)i);
00121 }
00122
00123 private slots:
00124
00125 void create();
00126 };
00127
00128
00129
00130 class QtNewRSPolygon : public QWidget {
00131 Q_OBJECT
00132
00133 public:
00134
00135 QtNewRSPolygon(RSPolygon* poly, QtRegionShapeManager* manager);
00136
00137
00138 ~QtNewRSPolygon();
00139
00140
00141 bool enteredCoordinatesAreValid(String& reason) const;
00142
00143 public slots:
00144
00145 void apply();
00146
00147 private:
00148 RSPolygon* m_polygon;
00149 QtEditRegionShape* m_editor;
00150 QListWidget* m_coordList;
00151 QFrame* m_coordFrame;
00152 vector<pair<QString, QString> > m_enteredCoords;
00153 QLineEdit* m_coordXEdit, *m_coordYEdit;
00154
00155 private slots:
00156
00157 void addCoordinates();
00158
00159
00160 void listMoveUp();
00161
00162
00163 void listMoveDown();
00164
00165
00166 void listDelete();
00167 };
00168
00169
00170
00171 class QtNewRSComposite : public QWidget {
00172 Q_OBJECT
00173
00174 public:
00175
00176 QtNewRSComposite(RSComposite* comp, QtRegionShapeManager* manager);
00177
00178
00179 ~QtNewRSComposite();
00180
00181
00182
00183 bool enteredValuesAreValid(String& reason) const;
00184
00185 public slots:
00186
00187 void apply();
00188
00189 private:
00190
00191
00192 QtRegionShapeManager* m_manager;
00193 RSComposite* m_composite;
00194 vector<RegionShape*> m_children;
00195 QStackedLayout* m_layout;
00196
00197
00198
00199
00200 QRadioButton* m_dependentChildren;
00201 QRadioButton* m_newShapes;
00202 QLabel* m_dependentLabel1, *m_dependentLabel2;
00203
00204
00205
00206
00207 QListWidget* m_newShapeList;
00208 QComboBox* m_editChooser;
00209 QStackedLayout* m_editWidgets;
00210
00211
00212
00213
00214 QListWidget* m_existingList, *m_moveList;
00215 vector<RegionShape*> m_existingShapes, m_moveShapes;
00216
00217
00218
00219
00220
00221 QWidget* initFirstScreen();
00222 QWidget* initSecondScreen1();
00223 QWidget* initSecondScreen2();
00224
00225
00226
00227
00228 void updateLists();
00229
00230
00231 unsigned int adjustedIndex(int row);
00232
00233 private slots:
00234
00235 void next();
00236
00237
00238
00239
00240 void nAddShape(RegionShape* shape);
00241
00242
00243 void nListUp();
00244
00245
00246 void nListDown();
00247
00248
00249 void nListDelete();
00250
00251
00252
00253
00254 void eAddShape();
00255
00256
00257 void eRemoveShape();
00258
00259
00260 void eListUp();
00261
00262
00263 void eListDown();
00264 };
00265
00266 }
00267
00268 #endif