00001
00002
00003 #include "VisRoot/VisRootBrowser/interface/VisRootBrowser.h"
00004 #include "VisRoot/VisRootModel/interface/VisRootModel.h"
00005 #include "VisRoot/VisRootModel/interface/VisRootRep.h"
00006 #include "Iguana/Framework/interface/IgState.h"
00007 #include "Iguana/Framework/interface/IgRep.h"
00008 #include "Iguana/Framework/interface/IgRepSet.h"
00009 #include "Iguana/Framework/interface/IgRepresentable.h"
00010 #include "Iguana/Framework/interface/IgSelectionService.h"
00011 #include "Iguana/Framework/interface/IgSelectionMessage.h"
00012 #include "Iguana/Studio/interface/IgQtSite.h"
00013 #include <classlib/utils/DebugAids.h>
00014 #include <classlib/utils/Callback.h>
00015 #include <TQtWidget.h>
00016 #include <qmessagebox.h>
00017 #include <qlayout.h>
00018 #include <qsize.h>
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 const char *
00031 VisRootBrowser::catalogLabel (void)
00032 { return "Root"; }
00033
00034 QWidget *
00035 VisRootBrowser::initialise (IgState *, IgSite *site)
00036 {
00037
00038 QWidget *w = new QWidget (IgQtSite::hostFrom (site));
00039 (new QVBoxLayout (w))->setAutoAdd (true);
00040 QSize size = IgQtSite::hostFrom (site)->size();
00041 if (size.width () > 1)
00042 w->resize (size);
00043 w->show ();
00044
00045 return w;
00046 }
00047
00048 VisRootBrowser::VisRootBrowser (IgState *state,
00049 IgSite *site,
00050 VisRootModel *)
00051 : TQtWidget (initialise (state, site)),
00052 m_state (state),
00053 m_site (site),
00054 m_model (0)
00055 {
00056 if (!m_model)
00057 m_model = new VisRootModel (state);
00058
00059 m_model->canvas (this->Canvas ());
00060
00061 ASSERT (IgSelectionService::get (m_state));
00062 IgSelectionService::get (m_state)
00063 ->add (lat::CreateCallback (this, &VisRootBrowser::selectMessage));
00064
00065 VisRootModel::Dispatcher *modelDispatcher =
00066 m_model->dispatcher (VisRootModel::ModelChanged);
00067
00068 ASSERT (modelDispatcher);
00069
00070 modelDispatcher
00071 ->add (lat::CreateCallback (this, &VisRootBrowser::modelChanged));
00072 this->size ();
00073
00074 show ();
00075 }
00076
00077 void
00078 VisRootBrowser::browse (IgRepresentable *object)
00079 {
00080
00081 VisRootRep *rep = dynamic_cast <VisRootRep *> (
00082 IgRepSet::lookup (object, m_model, true));
00083 ASSERT (rep);
00084 }
00085
00086 void
00087 VisRootBrowser::selectMessage (IgSelectionMessage message)
00088 {
00089
00090
00091
00092 VisRootRep *selectedRep = ! message.context () ? 0
00093 : dynamic_cast<VisRootRep *>
00094 (IgRepSet::lookup (message.context (),
00095 m_model,
00096 true));
00097 (void) selectedRep;
00098 }
00099
00100 void
00101 VisRootBrowser::modelChanged (VisRootModelEvent event)
00102 {
00103 VisRootModel *model = event.source ();
00104 ASSERT (model);
00105 }
00106
00107 void
00108 VisRootBrowser::print (void)
00109 {
00110 QMessageBox::warning (0,
00111 "Warning",
00112 "Printing for the ROOT view is not implemented yet.");
00113 }