Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

QUserPanel.ui.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 // this function called by Go4 GUI to start user panel
00017 
00018 #include <sstream>
00019 #include <stdlib.h>
00020 using namespace std;
00021 
00022 extern "C" void* StartUserPanel(void* parent)
00023 {
00024    return new QUserPanel((QWidget*) parent);
00025 
00026 //  Use this code to hide main go4 window and show only user gui
00027 
00028 //  QWidget* w = (QWidget*) parent;
00029 //  w->parentWidget()->hide();
00030 //   return new QUserPanel(0);
00031 
00032 }
00033 
00034 // *********************************************************
00035 
00036 void QUserPanel::init()
00037 {
00038    DragLbl->setText("");
00039    DragItemLbl->setText("");
00040    DragClassLbl->setText("");
00041    DragKindLbl->setText("");
00042 
00043    PrintLbl->setText("");
00044 }
00045 
00046 void QUserPanel::destroy()
00047 {
00048    fxDrawCanvas->getCanvas()->Clear();
00049 }
00050 
00051 QString QUserPanel::kindString(int kind)
00052 {
00053    QString kndlabel;
00054 
00055    switch(kind) {
00056       case TGo4Access::kndNone: kndlabel = "unknown"; break;
00057       case TGo4Access::kndObject: kndlabel = "object"; break;
00058       case TGo4Access::kndFolder: kndlabel = "folder"; break;
00059       case TGo4Access::kndTreeBranch: kndlabel = "tree brunch"; break;
00060       case TGo4Access::kndTreeLeaf: kndlabel = "tree leaf"; break;
00061       case TGo4Access::kndGo4Param: kndlabel = "go4 parameter"; break;
00062       case TGo4Access::kndDataMember: kndlabel = "event data member"; break;
00063       case TGo4Access::kndEventElement: kndlabel = "event element"; break;
00064       default: kndlabel = "undefined"; break;
00065    }
00066 
00067    kndlabel = QString("Kind of draged item: ") + kndlabel +
00068               " (" + QString::number(kind) + ")";
00069 
00070    return kndlabel;
00071 }
00072 
00073 bool QUserPanel::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
00074 {
00075    bool res = false;
00076 
00077    switch (TabWidget->currentPageIndex()) {
00078       case 0:
00079         DragLbl->setText("Go4 GUI asks if widget accept dragged item");
00080         DragItemLbl->setText(itemname);
00081         DragClassLbl->setText(QString("Class: ") + (cl==0 ? "not exists (known)" : cl->GetName()));
00082         DragKindLbl->setText(kindString(kind));
00083         res = cl!=0;
00084         break;
00085 
00086      case 1:
00087         PrintLbl->setText(QString("Class: ") + (cl==0 ? "not exists (known)" : cl->GetName()));
00088         res = cl!=0;
00089         break;
00090    }
00091    // we will accept only items with known classes
00092    return res;
00093 }
00094 
00095 void QUserPanel::DropItem(const char* itemname, TClass* cl, int kind)
00096 {
00097    switch (TabWidget->currentPageIndex()) {
00098       case 0:
00099          DragLbl->setText("User dropped item");
00100          DragItemLbl->setText(itemname);
00101          DragClassLbl->setText(cl==0 ? "No class specified" : cl->GetName());
00102          DragKindLbl->setText(kindString(kind));
00103          break;
00104       case 1:
00105          if (cl==0) {
00106             PrintLbl->setText("Can not drop item of uncknown class");
00107          } else {
00108             PrintLbl->setText(QString("Print item: ") + itemname);
00109             RemoveLink("PrintItem");
00110             AddLink(itemname, "PrintItem");
00111             PrintObject(GetLinked("PrintItem", 2));
00112          }
00113 
00114          break;
00115       case 2:
00116         DrawObjectOnCanvas(itemname);
00117         break;
00118    }
00119 }
00120 
00121 void QUserPanel::linkedObjectUpdated(const char* linkname, TObject* obj)
00122 {
00123     if (strcmp(linkname, "PrintItem")==0)
00124       PrintObject(obj);
00125     else
00126     if (strcmp(linkname, "DrawItem")==0) {
00127        fxDrawCanvas->getCanvas()->Clear();
00128        fxDrawCanvas->getCanvas()->cd();
00129        obj->Draw("");
00130        fxDrawCanvas->getCanvas()->Update();
00131     }
00132 }
00133 
00134 void QUserPanel::linkedObjectRemoved(const char* linkname)
00135 {
00136     if (strcmp(linkname, "PrintItem")==0)
00137       PrintObject(0);
00138     else
00139     if (strcmp(linkname, "DrawItem")==0) {
00140       RemoveLink("DrawItem");
00141       fxDrawCanvas->getCanvas()->Clear();
00142       fxDrawCanvas->getCanvas()->Update();
00143     }
00144 }
00145 
00146 void QUserPanel::InfoBtn_clicked()
00147 {
00148    ShowItemInfo(DragItemLbl->text());
00149 }
00150 
00151 void QUserPanel::EditBtn_clicked()
00152 {
00153    EditItem(DragItemLbl->text());
00154 }
00155 
00156 
00157 void QUserPanel::DrawBtn_clicked()
00158 {
00159    DrawItem(DragItemLbl->text());
00160 }
00161 
00162 void QUserPanel::PrintObject(TObject* obj)
00163 {
00164     PrintEdit->clear();
00165     if (obj==0) return;
00166 
00167     if (stdoutButton->isChecked()) {
00168        cout.flush();
00169        char sbuf[30000];
00170        memset(sbuf, 0, 30000);
00171        std::setvbuf(stdout, sbuf, _IOFBF, 30000);
00172        obj->Print("");
00173        std::setvbuf(stdout, 0, _IONBF, 0);
00174        PrintEdit->setText(sbuf);
00175     } else {
00176        cout.flush();
00177        ostringstream strout;
00178        streambuf* cout_buffer = cout.rdbuf();
00179        cout.rdbuf(strout.rdbuf());
00180        obj->Print("");
00181        cout << endl;
00182        cout.flush();
00183        cout.rdbuf(cout_buffer);
00184        PrintEdit->setText(strout.str().c_str());
00185     }
00186 }
00187 
00188 void QUserPanel::CanvasDropEventSlot(QDropEvent* event, TPad* pad)
00189 {
00190    QString eventstr;
00191    if (!QTextDrag::decode(event, eventstr)) return;
00192    event->accept();
00193    DrawObjectOnCanvas(eventstr.latin1());
00194 }
00195 
00196 void QUserPanel::DoCanvasResizeSlot()
00197 {
00198    fxDrawCanvas->checkResizeFlag();
00199 }
00200 
00201 void QUserPanel::DrawObjectOnCanvas(const char* itemname)
00202 {
00203    RemoveLink("DrawItem");
00204    AddLink(itemname, "DrawItem");
00205    TObject* obj = GetLinked("DrawItem", 2);
00206    if (obj!=0) {
00207       fxDrawCanvas->getCanvas()->Clear();
00208       fxDrawCanvas->getCanvas()->cd();
00209       obj->Draw("");
00210       fxDrawCanvas->getCanvas()->Update();
00211    }
00212 }
00213 
00214 
00215 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:31 2008 for Go4-v3.04-1 by  doxygen 1.4.2