00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4WorkSpace.h"
00017
00018 #include "TPad.h"
00019 #include "TROOT.h"
00020
00021 #include "TGo4ViewPanel.h"
00022 #include "QGo4Widget.h"
00023
00024 TGo4WorkSpace* TGo4WorkSpace::fInstance = 0;
00025
00026 TGo4WorkSpace* TGo4WorkSpace::Instance()
00027 {
00028 return fInstance;
00029 }
00030
00031 TGo4WorkSpace::TGo4WorkSpace(QWidget* parent) :
00032 QWorkspace(parent),
00033 fxActivePanel(0),
00034 fxActivePad(0),
00035 fxSelectedPad(0)
00036 {
00037 setSizeIncrement( QSize( 100, 100 ) );
00038 setBaseSize( QSize( 100, 100 ) );
00039
00040 connect(this,SIGNAL(windowActivated(QWidget*)), this, SLOT(windowActivatedSlot(QWidget*)));
00041
00042 if (fInstance==0) fInstance = this;
00043 }
00044
00045 void TGo4WorkSpace::closeEvent(QCloseEvent * ce)
00046 {
00047 ce->accept();
00048 delete this;
00049 }
00050
00051 TGo4WorkSpace::~TGo4WorkSpace()
00052 {
00053 if (fInstance==this) fInstance=0;
00054 }
00055
00056 bool TGo4WorkSpace::eventFilter( QObject *fx , QEvent* e )
00057 {
00058 switch (e->type()) {
00059 case QEvent::Move:
00060 return false;
00061 break;
00062 case QEvent::Resize :
00063 return false;
00064 break;
00065 case QEvent::Paint :
00066 return false;
00067 break;
00068 }
00069
00070 if(e->type()==QEvent::MouseButtonRelease) {
00071 if (fxActivePanel!=0)
00072 fxActivePanel->CheckResizeFlags();
00073 }
00074
00075 return QWorkspace::eventFilter( fx , e );
00076 }
00077
00078 TPad* TGo4WorkSpace::GetSelectedPad()
00079 {
00080 return fxSelectedPad;
00081 }
00082
00083 void TGo4WorkSpace::SetSelectedPad(TPad* pad)
00084 {
00085 fxSelectedPad = pad;
00086 gROOT->SetSelectedPad(pad);
00087 gPad = pad;
00088 }
00089
00090 TGo4ViewPanel* TGo4WorkSpace::GetActivePanel()
00091 {
00092 return fxActivePanel;
00093 }
00094
00095 void TGo4WorkSpace::windowActivatedSlot(QWidget* w)
00096 {
00097 TGo4ViewPanel* panel = dynamic_cast<TGo4ViewPanel*> (w);
00098 if ((panel!=0) && (fxActivePanel != panel))
00099 panel->SetActivePad(panel->GetActivePad());
00100 }
00101
00102 void TGo4WorkSpace::ResponseOnPanelEvent(int funcid, TGo4ViewPanel* panel, TPad* pad)
00103 {
00104 if (panel==0) return;
00105
00106 switch (funcid) {
00107 case QGo4Widget::panel_Activated: {
00108 if ((fxActivePanel!=panel) && (fxActivePanel!=0))
00109 fxActivePanel->SetActivePad(0);
00110
00111 bool changed = (fxActivePanel != panel) || (fxActivePad != pad);
00112 fxActivePanel = panel;
00113 fxActivePad = pad;
00114
00115 if (changed)
00116 emit panelSignal(panel, pad, QGo4Widget::panel_Activated);
00117
00118 break;
00119 }
00120
00121 case QGo4Widget::panel_Modified: {
00122 emit panelSignal(panel, pad, QGo4Widget::panel_Modified);
00123 break;
00124 }
00125
00126 case QGo4Widget::panel_Updated: {
00127 emit panelSignal(panel, pad, QGo4Widget::panel_Updated);
00128 if ((panel==fxActivePanel) && (pad==fxActivePad))
00129 emit panelSignal(panel, pad, QGo4Widget::panel_ActiveUpdated);
00130 break;
00131 }
00132
00133 case QGo4Widget::panel_PadDeleted: {
00134 if (GetSelectedPad()==pad) SetSelectedPad(0);
00135 if (fxActivePad==pad) fxActivePad=0;
00136 emit panelSignal(panel, pad, QGo4Widget::panel_PadDeleted);
00137 break;
00138 }
00139
00140 case QGo4Widget::panel_Deleted: {
00141 if (GetSelectedPad()!=0)
00142 if (panel->IsPanelPad(GetSelectedPad()))
00143 SetSelectedPad(0);
00144 if (fxActivePanel==panel) {
00145 fxActivePanel = 0;
00146 fxActivePad = 0;
00147 }
00148 emit panelSignal(panel, pad, QGo4Widget::panel_Deleted);
00149 break;
00150 }
00151 }
00152 }
00153
00154
00155