Changeset 2384 for trunk/MagicSoft/Cosy/gui
- Timestamp:
- 10/15/03 17:28:35 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/gui/MGCosy.cc
r2280 r2384 26 26 #include "MCosy.h" 27 27 #include "MGList.h" 28 #include "MDriveCom.h" 28 29 #include "MGAccuracy.h" 29 30 #include "MGCoordinates.h" … … 34 35 35 36 #undef DEBUG 36 #define EXPERT 37 //#define EXPERT 38 //#define HAS_DEMO 37 39 38 40 ClassImp(MGCosy); … … 41 43 #define IDM_TEXT 2 42 44 #define IDM_ASPECT 3 45 43 46 44 47 enum … … 386 389 TGCompositeFrame *tf6 = fTab->AddTab("Gear"); 387 390 #endif 388 /*TGCompositeFrame *tf3 =*/// fTab->AddTab("Demo"); 391 #ifdef HAS_DEMO 392 /*TGCompositeFrame *tf3 =*/ fTab->AddTab("Demo"); 393 #endif 389 394 390 395 fCZdAz = new MGCoordinates(tf1, kETypeZdAz); … … 984 989 void MGCosy::UpdateZdAz(ZdAz &soll) 985 990 { 986 soll *= 360/2/TMath::Pi();991 soll *= kRad2Deg; 987 992 988 993 static Int_t zd=~0; … … 1055 1060 UpdateZdAz(soll); 1056 1061 1057 #define kError 0x01 1058 #define kMoving 0x02 1059 #define kTracking 0x04 1060 #define kStopping 0x08 1061 #define kStopped 0x10 1062 1063 EnableLabel(fError, stat&kError); 1064 EnableLabel(fMoving, stat&kMoving); 1065 EnableLabel(fTracking, stat&kTracking); 1066 EnableLabel(fStopping, stat&kStopping); 1067 EnableLabel(fStopped, stat&kStopped); 1068 EnableLabel(fRaSoll, stat&kTracking); 1069 EnableLabel(fDecSoll, stat&kTracking); 1070 EnableLabel(fZdSoll, stat&kMoving); 1071 EnableLabel(fAzSoll, stat&kMoving); 1062 EnableLabel(fError, stat&MDriveCom::kError); 1063 EnableLabel(fMoving, stat&MDriveCom::kMoving); 1064 EnableLabel(fTracking, stat&MDriveCom::kTracking); 1065 EnableLabel(fStopping, stat&MDriveCom::kStopping); 1066 EnableLabel(fStopped, stat&MDriveCom::kStopped); 1067 EnableLabel(fRaSoll, stat&MDriveCom::kTracking); 1068 EnableLabel(fDecSoll, stat&MDriveCom::kTracking); 1069 EnableLabel(fZdSoll, stat&MDriveCom::kMoving); 1070 EnableLabel(fAzSoll, stat&MDriveCom::kMoving); 1072 1071 1073 1072 SetLabelColor(fAvailMac1, stat2&0x01); … … 1078 1077 SetLabelColor(fAvailSe3, stat2&0x20); 1079 1078 1080 if (stat& kTracking)1079 if (stat&MDriveCom::kTracking) 1081 1080 { 1082 1081 fAccuracy->Update(pos, acc); … … 1187 1186 // ************************** For demo purpose ********************** 1188 1187 // 1189 /* 1188 #ifdef HAS_DEMO 1189 1190 1190 #include <TRandom.h> 1191 1191 class MDemo : public MThread … … 1200 1200 void SetQueue(MsgQueue *q) { fQueue = q; } 1201 1201 1202 bool Wait(int s, int m) 1203 { 1204 int i = 0; 1205 while (!HasStopFlag() && i++<m) 1206 usleep(s); 1207 if (HasStopFlag()) 1208 return false; 1209 return true; 1210 } 1211 1212 bool Move(float zd, float az, int s, int m) 1213 { 1214 ZdAz dest1(zd, az); 1215 fQueue->PostMsg(WM_POSITION1, &dest1, sizeof(dest1)); 1216 return Wait(s, m); // 30s? 1217 } 1218 1202 1219 virtual void *Thread() 1203 1220 { 1204 while (1) 1221 if (!Move(90, -65, 1000000, 27)) 1222 return NULL; 1223 1224 Int_t i=1; 1225 while (i-->0) 1205 1226 { 1206 1227 Timer tm; 1207 1228 tm.Now(); 1208 1229 1209 //fQueue->PostMsg(WM_STOP, 0, 0); 1210 1211 ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90); 1212 1213 cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl; 1214 1215 fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1)); 1216 1217 int i = 0; 1218 while (!HasStopFlag() && i++<5) // 30s 1219 usleep(1000000); 1220 if (HasStopFlag()) 1230 if (!Move(75, -80, 1000000, 13)) 1221 1231 break; 1222 1223 //ZdAz dest2(5, 30); 1224 //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2)); 1225 //if (HasStopFlag()) 1226 // break; 1232 if (!Move(60, -65, 1000000, 13)) 1233 break; 1234 if (!Move(75, -50, 1000000, 13)) 1235 break; 1236 if (!Move(90, -65, 1000000, 13)) 1237 break; 1227 1238 } 1239 if (!Move(60, -65, 1000000, 17)) 1240 return NULL; 1241 if (!Move(90, -65, 1000000, 19)) 1242 return NULL; 1243 if (!Move(90, -10, 1000000, 28)) 1244 return NULL; 1245 1228 1246 cout << "Demo Thread: done." << endl; 1229 1247 return NULL; … … 1248 1266 demo.Stop(); 1249 1267 } 1250 */ 1268 #endif //HAS_DEMO 1269 1251 1270 /* 1252 1271 void MGCosy::StartCalib() … … 1344 1363 fQueue->Proc(WM_GEAR, (void*)1); 1345 1364 return kTRUE; 1346 /* 1365 #ifdef HAS_DEMO 1347 1366 case 5: 1348 1367 StartDemo(); 1349 1368 return kTRUE; 1350 */ 1369 #endif 1351 1370 } 1352 1371 return kTRUE; … … 1354 1373 case kPB_STOP: 1355 1374 cout << "Sending stop movement msg." << endl; 1356 //StopDemo(); 1375 #ifdef HAS_DEMO 1376 StopDemo(); 1377 #endif 1357 1378 fQueue->PostMsg(WM_STOP, 0, 0); 1358 1379 if (fTab->GetCurrent()==3) -
trunk/MagicSoft/Cosy/gui/MGImage.cc
r2278 r2384 52 52 fDefGC = gVirtualX->CreateGC(fId, 0); 53 53 fImage = (XImage*)gVirtualX->CreateImage(fWidth, fHeight); 54 55 cout << "Detected Color Depth: " << gVirtualX->GetDepth() << endl; 54 56 } 55 57 … … 82 84 } 83 85 84 void MGImage::DrawImg (const byte *buffer)86 void MGImage::DrawImg32(char *d, char *s, char *e) 85 87 { 86 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 87 return; 88 89 char *d = fImage->data; 90 char *e = (char*)(buffer+fWidth*fHeight); 91 char *s = (char*)buffer; 92 93 // FIXME: This loop depends on the screen color depth 88 // d=destination, s=source, e=end 94 89 while (s<e) 95 90 { … … 99 94 d++; 100 95 } 101 102 SetBit(kNeedRedraw);103 104 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap);105 96 } 106 97 107 void MGImage::DrawColImg (const byte *gbuf, const byte *cbuf)98 void MGImage::DrawColImg32(char *d, char *s1, char *s2, char *e) 108 99 { 109 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 110 return; 111 112 char *d = fImage->data; 113 char *e = (char*)(gbuf+fWidth*fHeight); 114 char *s1 = (char*)gbuf; 115 char *s2 = (char*)cbuf; 116 117 // FROM libAfterImage: 118 // ------------------- 119 //#define ALPHA_TRANSPARENT 0x00 120 //#define ALPHA_SEMI_TRANSPARENT 0x7F 121 //#define ALPHA_SOLID 0xFF 122 // * Lowermost 8 bits - Blue channel 123 // * bits 8 to 15 - Green channel 124 // * bits 16 to 23 - Red channel 125 // * bits 24 to 31 - Alpha channel 126 //#define ARGB32_White 0xFFFFFFFF 127 //#define ARGB32_Black 0xFF000000 128 129 // FIXME: This loop depends on the screen color depth 100 // d=destination, s1=source1, s2=source2, e=end 130 101 while (s1<e) 131 102 { … … 147 118 } 148 119 } 120 } 121 122 void MGImage::DrawImg(const byte *buffer) 123 { 124 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 125 return; 126 127 switch (gVirtualX->GetDepth()) 128 { 129 case 32: 130 DrawImg32(fImage->data, (char*)buffer, (char*)(buffer+fWidth*fHeight)); 131 break; 132 default: 133 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl; 134 } 149 135 150 136 SetBit(kNeedRedraw); … … 152 138 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap); 153 139 } 140 141 void MGImage::DrawColImg(const byte *gbuf, const byte *cbuf) 142 { 143 if (pthread_mutex_trylock((pthread_mutex_t*)fMuxPixmap)) 144 return; 145 146 // FROM libAfterImage: 147 // ------------------- 148 //#define ALPHA_TRANSPARENT 0x00 149 //#define ALPHA_SEMI_TRANSPARENT 0x7F 150 //#define ALPHA_SOLID 0xFF 151 // * Lowermost 8 bits - Blue channel 152 // * bits 8 to 15 - Green channel 153 // * bits 16 to 23 - Red channel 154 // * bits 24 to 31 - Alpha channel 155 //#define ARGB32_White 0xFFFFFFFF 156 //#define ARGB32_Black 0xFF000000 157 158 // FIXME: This loop depends on the screen color depth 159 switch (gVirtualX->GetDepth()) 160 { 161 case 32: 162 DrawColImg32(fImage->data, (char*)gbuf, (char*)cbuf, (char*)(gbuf+fWidth*fHeight)); 163 break; 164 default: 165 cout << "Sorry, " << gVirtualX->GetDepth() << "bit color depth not yet implemented." << endl; 166 } 167 168 SetBit(kNeedRedraw); 169 170 pthread_mutex_unlock((pthread_mutex_t*)fMuxPixmap); 171 } -
trunk/MagicSoft/Cosy/gui/MGImage.h
r2278 r2384 35 35 enum { kNeedRedraw = BIT(17) }; 36 36 37 void DrawImg32(char *d, char *s, char *e); 38 void DrawColImg32(char *d, char *s1, char *s2, char *e); 39 37 40 public: 38 41 MGImage(const TGWindow* p, UInt_t w, UInt_t h, UInt_t options = kSunkenFrame, ULong_t back = fgDefaultFrameBackground); -
trunk/MagicSoft/Cosy/gui/Makefile
r2278 r2384 21 21 22 22 INCLUDES = -I. -I.. -I../base -I../slalib -I../candrv -I../incl \ 23 -I../catalog -I../videodev -I../main -I../caos 23 -I../catalog -I../videodev -I../main -I../caos -I../tcpip 24 24 25 25 # @code
Note:
See TracChangeset
for help on using the changeset viewer.