00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "QGo4Widget.h"
00017 #include "qtimer.h"
00018 #include "Riostream.h"
00019
00020 QGo4Widget::QGo4Widget(QWidget * parent, const char * name, WFlags f) :
00021 QWidget(parent, name, f),
00022 fWaitsForObjectCreation(false)
00023 {
00024 setAcceptDrops(TRUE);
00025 fCanDestroyWidget = true;
00026 fBrowserProxy = 0;
00027 fResetWidgetShooted = false;
00028 fBlockUpdate = false;
00029 }
00030
00031 QGo4Widget::~QGo4Widget()
00032 {
00033 RemoveLinksMasked("complete");
00034 }
00035
00036 void QGo4Widget::ObjectCreatedByWidget(const char* itemname, TClass* cl)
00037
00038 {
00039 if (fWaitsForObjectCreation) {
00040 fWaitsForObjectCreation = false;
00041 requestedObjectCreated(itemname, cl);
00042 }
00043 }
00044
00045 void QGo4Widget::ResetWidget()
00046 {
00047
00048 fResetWidgetShooted = true;
00049 RemoveAllLinks();
00050 fWaitsForObjectCreation = false;
00051 fResetWidgetShooted = false;
00052 }
00053
00054 void QGo4Widget::ShootResetWidget()
00055 {
00056 if (fResetWidgetShooted) return;
00057
00058 fResetWidgetShooted = true;
00059
00060 QTimer::singleShot(0, this, SLOT(ResetWidgetSlot()));
00061 }
00062
00063 void QGo4Widget::ShootCloseWidget()
00064 {
00065 if (fResetWidgetShooted) return;
00066
00067 fResetWidgetShooted = true;
00068
00069 QTimer::singleShot(0, this, SLOT(close()));
00070 }
00071
00072
00073 void QGo4Widget::ResetWidgetSlot()
00074 {
00075 ResetWidget();
00076 }
00077
00078
00079 bool QGo4Widget::IsAcceptDrag(const char*, TClass*, int)
00080 {
00081 return false;
00082 }
00083
00084 void QGo4Widget::DropItem(const char*, TClass*, int)
00085 {
00086 }
00087
00088
00089 void QGo4Widget::closeEvent(QCloseEvent* e)
00090 {
00091 if (fCanDestroyWidget) {
00092 e->accept();
00093 delete this;
00094 } else
00095 QWidget::closeEvent(e);
00096 }
00097
00098 void QGo4Widget::dragEnterEvent(QDragEnterEvent *e)
00099 {
00100 emit widgetService(this, service_DragEnter, 0, e);
00101 }
00102
00103 void QGo4Widget::dragMoveEvent(QDragMoveEvent*)
00104 {
00105
00106 }
00107
00108 void QGo4Widget::dropEvent(QDropEvent* e)
00109 {
00110 emit widgetService(this, service_DropEvent, 0, e);
00111 }
00112
00113 void QGo4Widget::AddLink(const char* itemname, const char* linkname)
00114 {
00115 emit widgetService(this, service_AddEditorLink, linkname, (void*) itemname);
00116 }
00117
00118 void QGo4Widget::AddLink(TGo4Slot* slot, const char* linkname)
00119 {
00120 emit widgetService(this, service_AddDirectLink, linkname, (void*) slot);
00121 }
00122
00123 TGo4Slot* QGo4Widget::AddLink(const char* itemname, TGo4Slot* parent)
00124 {
00125 TGo4Slot* res = parent;
00126 emit widgetService(this, service_AddLinkInSlot, itemname, (void*) &res);
00127 return res;
00128 }
00129
00130 TGo4Slot* QGo4Widget::GetTopSlot(bool force)
00131 {
00132 TGo4Slot* res = 0;
00133 emit widgetService(this, service_GetTopSlot, force ? "force" : "normal", (void*) &res);
00134 return res;
00135 }
00136
00137 TGo4Slot* QGo4Widget::AddSlot(const char* slotname)
00138 {
00139 TGo4Slot* res = 0;
00140 emit widgetService(this, service_AddEditorSlot, slotname, (void*) &res);
00141 return res;
00142 }
00143
00144 void QGo4Widget::SetLinkedName(TGo4Slot* slot, const char* itemname)
00145 {
00146 emit widgetService(this, service_SetLinkedName, itemname, (void*) slot);
00147 }
00148
00149 const char* QGo4Widget::GetLinkedName(const char* linkname)
00150 {
00151 const char* res = 0;
00152
00153 emit widgetService(this, service_GetLinkedName, linkname, (void*) &res);
00154
00155 return res;
00156 }
00157
00158 const char* QGo4Widget::GetLinkedName(TGo4Slot* slot)
00159 {
00160 void* res = slot;
00161
00162 emit widgetService(this, service_GetLinkedName2, "", (void*) &res);
00163
00164 return (const char*) res;
00165 }
00166
00167
00168 TObject* QGo4Widget::GetLinked(const char* linkname, int updatelevel)
00169 {
00170 TObject* res = 0;
00171 int func = 0;
00172 switch (updatelevel) {
00173 case 0: func = service_GetLinked0; break;
00174 case 1: func = service_GetLinked1; break;
00175 case 2: func = service_GetLinked2; break;
00176 default: func = service_GetLinked1; break;
00177 }
00178
00179 emit widgetService(this, func, linkname, (void*) &res);
00180
00181 return res;
00182 }
00183
00184 void QGo4Widget::RemoveLink(const char* linkname, bool blockreset)
00185 {
00186 bool oldvalue = fBlockUpdate;
00187 if (blockreset) fBlockUpdate = true;
00188 emit widgetService(this, service_RemoveLink, linkname, 0);
00189 fBlockUpdate = oldvalue;
00190 }
00191
00192 void QGo4Widget::RemoveAllLinks(bool blockreset)
00193 {
00194 bool oldvalue = fBlockUpdate;
00195 if (blockreset) fBlockUpdate = true;
00196 emit widgetService(this, service_RemoveAllLinks, 0, 0);
00197 fBlockUpdate = oldvalue;
00198 }
00199
00200 void QGo4Widget::RemoveLinksMasked(const char* startedwith, bool blockreset)
00201 {
00202 bool oldvalue = fBlockUpdate;
00203 if (blockreset) fBlockUpdate = true;
00204 emit widgetService(this, service_RemoveAllLinks, startedwith, 0);
00205 fBlockUpdate = oldvalue;
00206 }
00207
00208 bool QGo4Widget::BrowserItemRemote(const char* itemname)
00209 {
00210 bool isremote = false;
00211 emit widgetService(this, service_BrowserItemRemote, itemname, (void*) &isremote);
00212 return isremote;
00213 }
00214
00215 TGo4BrowserProxy* QGo4Widget::Browser()
00216 {
00217 if (fBrowserProxy!=0) return fBrowserProxy;
00218
00219 TGo4BrowserProxy* br = 0;
00220 emit widgetService(this, service_Browser, "", (void*) &br);
00221 fBrowserProxy = br;
00222 return br;
00223 }
00224
00225 void QGo4Widget::ConnectPad(TPad* pad)
00226 {
00227 emit widgetService(this, service_ConnectPad, "", (void*) pad);
00228 }
00229
00230 void QGo4Widget::CallPanelFunc(int func, TPad* pad)
00231 {
00232 emit widgetService(this, func, "", (void*) pad);
00233 }
00234
00235
00236 void QGo4Widget::StatusMessage(const char* message)
00237 {
00238 emit widgetService(this, service_StatusMessage, message, 0);
00239 }
00240
00241
00242 void QGo4Widget::ProcessSignal(const char* linkname, bool assigned, TObject* obj, TGo4Slot* slot)
00243 {
00244 if (assigned) {
00245 linkedUpdated(slot, obj);
00246 linkedObjectUpdated(linkname, obj);
00247 } else
00248
00249 if (!IsUpdateBlocked()) {
00250 linkedRemoved(slot, obj);
00251 linkedObjectRemoved(linkname);
00252 }
00253 }
00254
00255 void QGo4Widget::linkedObjectUpdated(const char* , TObject* )
00256 {
00257 }
00258
00259 void QGo4Widget::linkedObjectRemoved(const char* )
00260 {
00261
00262 ShootResetWidget();
00263 }
00264
00265 void QGo4Widget::linkedUpdated(TGo4Slot* , TObject* )
00266 {
00267 }
00268
00269 void QGo4Widget::linkedRemoved(TGo4Slot* , TObject* )
00270 {
00271 }
00272
00273 void QGo4Widget::AskToCreateObject(TClass* cl, int isremote)
00274 {
00275 fWaitsForObjectCreation = (isremote>=0);
00276 QString str = QString::number(isremote);
00277 emit widgetService(this, service_CreateItem, str.latin1(), (void*) cl);
00278 }
00279
00280 void QGo4Widget::InformThatObjectCreated(const char* itemname, TClass* cl)
00281 {
00282 emit widgetService(this, service_ObjectCreated, itemname, cl);
00283 }
00284
00285 void QGo4Widget::requestedObjectCreated(const char* , TClass* )
00286
00287 {
00288 }
00289
00290 void QGo4Widget::ShowItemInfo(const char* itemname)
00291 {
00292 emit widgetService(this, service_ShowInfo, itemname, 0);
00293 }
00294
00295 TGo4ViewPanel* QGo4Widget::CreateViewPanel(int ndiv)
00296 {
00297 QString str = QString::number(ndiv);
00298 TGo4ViewPanel* res = 0;
00299 emit widgetService(this, service_CreateViewPanel, str.latin1(), (void*)&res);
00300 return res;
00301 }
00302
00303 TGo4ViewPanel* QGo4Widget::DrawItem(const char* itemname, TGo4ViewPanel* panel, TPad* pad, bool activate, int updatelevel)
00304 {
00305 void* res[4];
00306 res[0] = panel;
00307 res[1] = pad;
00308 res[2] = &activate;
00309 res[3] = &updatelevel;
00310 emit widgetService(this, service_DrawItem, itemname, res);
00311 return (TGo4ViewPanel*) res[0];
00312 }
00313
00314 TGo4ViewPanel* QGo4Widget::WhereItemDrawn(const char* itemname)
00315 {
00316 TGo4ViewPanel* res = false;
00317 emit widgetService(this, service_WhereItemDrawn, itemname, &res);
00318 return res;
00319 }
00320
00321 void QGo4Widget::UndrawItem(const char* itemname)
00322 {
00323 emit widgetService(this, service_UndrawItem, itemname, 0);
00324 }
00325
00326 void QGo4Widget::HelpWindow(const char* filename, const char* filedir)
00327 {
00328 emit widgetService(this, service_HelpWindow, filename, (void*)filedir);
00329 }
00330
00331
00332 TGo4ViewPanel* QGo4Widget::LastActivePanel()
00333 {
00334 TGo4ViewPanel* res = 0;
00335 emit widgetService(this, service_LastActivePanel, "", (void*)&res);
00336 return res;
00337 }
00338
00339 void QGo4Widget::EditItem(const char* itemname)
00340 {
00341 emit widgetService(this, service_EditItem, itemname, 0);
00342 }
00343
00344 void QGo4Widget::EditObjectInSlot(TGo4Slot* slot)
00345 {
00346 emit widgetService(this, service_EditInSlot, "", (void*) slot);
00347 }
00348
00349 QString QGo4Widget::SaveObjectInMemory(const char* foldername, TObject* obj)
00350 {
00351 void* par = obj;
00352 emit widgetService(this, service_SaveToMemory, foldername, (void*) &par);
00353 QString itemname = "";
00354 if ((par!=obj) && (par!=0)) {
00355 QString* res = (QString*) par;
00356 itemname = *res;
00357 delete res;
00358 }
00359 return itemname;
00360 }
00361
00362 bool QGo4Widget::SaveItemToFile(const char* itemname, const char* subfolder)
00363 {
00364 char buf[1000];
00365 if (subfolder==0) strcpy(buf, ""); else
00366 strcpy(buf, subfolder);
00367 emit widgetService(this, service_SaveItem, itemname, (void*) buf);
00368 return (buf[0]!=0);
00369 }
00370
00371 bool QGo4Widget::UpdateItemInAnalysis(const char* itemname, TObject* obj)
00372 {
00373 TObject* res = obj;
00374 emit widgetService(this, service_UpdateAnalysisItem, itemname, (void*) &res);
00375 return (res!=0);
00376 }
00377
00378 TGo4AnalysisProxy* QGo4Widget::GetAnalysis(const char* itemname)
00379 {
00380 TGo4AnalysisProxy* res = 0;
00381 emit widgetService(this, service_GetAnalysis, itemname, (void*) &res);
00382 return res;
00383 }
00384
00385 void QGo4Widget::CallServiceFunc(int func, const char* str, void* par)
00386 {
00387 emit widgetService(this, func, str, par);
00388 }
00389
00390 void QGo4Widget::ServiceCall(const char* name, void* par)
00391 {
00392 CallServiceFunc(service_General, name, par);
00393 }
00394
00395