Go to the documentation of this file.00001 #ifndef TRANSFORMS_H_12324142424121
00002 #define TRANSFORMS_H_12324142424121
00003
00004 #include <QString>
00005 #include <QStringList>
00006 #include <QPen>
00007
00008 #include <QtDebug>
00009
00010
00011
00012
00013 QString toMarkerColor(const QString &color);
00014
00015 QString trLineStyle(const Qt::PenStyle &style);
00016 int trLineStyleI(const Qt::PenStyle &style);
00017 Qt::PenStyle trLineStyle(const QString &style);
00018 Qt::PenStyle trLineStyle(int i);
00019
00020 QString trFillStatus(const Qt::BrushStyle &status);
00021 int trFillStatusI(const Qt::BrushStyle &status);
00022 Qt::BrushStyle trFillStatus(const QString &status);
00023 Qt::BrushStyle trFillStatus(int i);
00024
00025 QString trBool(bool is);
00026 bool trBool(const QString &is);
00027
00028 int trLoopVarDirection(int trLoopDirection);
00029 int trCLoopDirection(int trLoopDirection);
00030 int trLoopDirection(int trCLoopDirection);
00031 int trLoopType(int direction);
00032
00033 int trAngleFromDirection(int dir);
00034
00035 QString trMouseAction(unsigned char mouseAction);
00036
00037
00038
00039
00040
00041 inline QString toMarkerColor(const QString &color)
00042 {
00043
00044 if (color.toLower() != "darkgray" && color.toLower() != "black" && color.toLower() != "gray")
00045 return "gray";
00046 else
00047 return "lightblue";
00048 }
00049
00050 inline QString trLineStyle(const Qt::PenStyle &style){
00051 if (style == Qt::NoPen) return "none";
00052 else if (style == Qt::DashLine) return "dashed";
00053 else if (style == Qt::DotLine) return "dotted";
00054 else return "solid";
00055 }
00056
00057 inline int trLineStyleI(const Qt::PenStyle &style){
00058 switch (style){
00059 case Qt::SolidLine: return 0;
00060 case Qt::DashLine: return 1;
00061 case Qt::DotLine: return 2;
00062 default: return 3;
00063 }
00064 }
00065
00066 inline Qt::PenStyle trLineStyle(const QString &style){
00067 if (style == "none") return Qt::NoPen;
00068 else if (style == "dashed") return Qt::DashLine;
00069 else if (style == "dotted") return Qt::DotLine;
00070 else return Qt::SolidLine;
00071 }
00072
00073 inline Qt::PenStyle trLineStyle(int i){
00074 switch (i){
00075 case 0: return Qt::SolidLine;
00076 case 1: return Qt::DashLine;
00077 case 2: return Qt::DotLine;
00078 default: return Qt::NoPen;
00079 }
00080 }
00081
00082 inline QString trFillStatus(const Qt::BrushStyle &status){
00083 if (status == Qt::SolidPattern) return "solid";
00084 else if (status == Qt::BDiagPattern) return "hlines";
00085 else if (status == Qt::FDiagPattern) return "vlines";
00086 else if (status == Qt::DiagCrossPattern) return "crosshatch";
00087 else if (status == Qt::NoBrush) return "none";
00088 else return "solid";
00089 }
00090
00091 inline int trFillStatusI(const Qt::BrushStyle &status){
00092 switch (status){
00093 case Qt::SolidPattern: return 0;
00094 case Qt::FDiagPattern: return 1;
00095 case Qt::BDiagPattern: return 2;
00096 case Qt::DiagCrossPattern: return 3;
00097 default: return 4;
00098 }
00099 }
00100
00101 inline Qt::BrushStyle trFillStatus(const QString &status){
00102 if (status == "hlines") return Qt::BDiagPattern;
00103 else if (status == "vlines") return Qt::FDiagPattern;
00104 else if (status == "crosshatch") return Qt::DiagCrossPattern;
00105 else if (status == "none") return Qt::NoBrush;
00106 else return Qt::SolidPattern;
00107 }
00108
00109 inline Qt::BrushStyle trFillStatus(int i){
00110 switch (i){
00111 case 0: return Qt::SolidPattern;
00112 case 1: return Qt::FDiagPattern;
00113 case 2: return Qt::BDiagPattern;
00114 case 3: return Qt::DiagCrossPattern;
00115 default: return Qt::NoBrush;
00116 }
00117 }
00118
00119 inline QString trBool(bool is){
00120 if (is)
00121 return "true";
00122 else
00123 return "false";
00124 }
00125
00126 inline bool trBool(const QString &is){
00127 if (is == "true")
00128 return true;
00129 else
00130 return false;
00131 }
00132
00133 inline int trCLoopDirection(int trLoopDirection)
00134 {
00135 return trLoopDirection + SOUTH_WEST + 1;
00136 }
00137
00138 inline int trLoopVarDirection(int trLoopDireciton)
00139 {
00140 return trLoopDireciton + SOUTH_WEST*2 + 2;
00141 }
00142
00143 inline int trLoopDirection(int trDirection)
00144 {
00145 if (trDirection > SOUTH_WEST*2 + 1)
00146 {
00147 return trDirection - SOUTH_WEST*2 - 2;
00148 }
00149 else if(trDirection > SOUTH_WEST)
00150 {
00151 return trDirection - SOUTH_WEST - 1;
00152 }
00153 else return trDirection;
00154 }
00155
00156 inline int trLoopType(int direction)
00157 {
00158 if (direction > SOUTH_WEST*2 + 1)
00159 {
00160 return 2;
00161 }
00162 else if(direction > SOUTH_WEST)
00163 {
00164 return 1;
00165 }
00166 else return 0;
00167 }
00168
00169 inline int trAngleFromDirection(int dir)
00170 {
00171 switch (dir)
00172 {
00173 case NORTH:
00174 return (90);
00175 case SOUTH:
00176 return (270);
00177 case EAST:
00178 return (0);
00179 case WEST:
00180 return (180);
00181 case NORTH_EAST:
00182 return (45);
00183 case NORTH_WEST:
00184 return (135);
00185 case SOUTH_EAST:
00186 return (315);
00187 case SOUTH_WEST:
00188 return (225);
00189 default:
00190 RELLOG("direction out of range!!!");
00191 return (90);
00192 }
00193 }
00194
00195
00196
00197
00198
00199
00200 inline QString trMouseAction(unsigned char mouseAction)
00201 {
00202 switch(mouseAction)
00203 {
00204 case 0:
00205 return "eNoMouseAction";
00206 break;
00207 case 1:
00208 return "eMoveItem";
00209 break;
00210 case 2:
00211 return "eMoveMultItem";
00212 break;
00213 case 3:
00214 return "eInsertItem";
00215 break;
00216 case 4:
00217 return "eSelectItem";
00218 break;
00219 case 5:
00220 return "eSelectMultipleItems";
00221 break;
00222 case 6:
00223 return "eShowPopup";
00224 break;
00225 case 7:
00226 return "eShowSelectionPopup";
00227 break;
00228 default:
00229 RELLOG("Unknown mouse action!, define it in trMouseAction");
00230 return "<unknown>Action";
00231 }
00232 }
00233
00234 #endif //TRANSFORMS_H_12324142424121