CMS 3D CMS Logo

VisConfigEditor.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisFramework/VisFrameworkBase/interface/VisConfigEditor.h"
00004 #include "VisFramework/VisFrameworkBase/interface/VisConfiguration.h"
00005 #include "VisFramework/VisFrameworkBase/interface/VisParamEditor.h"
00006 #include "Iguana/Studio/interface/IgQtLock.h"
00007 #include <qvariant.h>
00008 #include <qheader.h>
00009 #include <qlineedit.h>
00010 #include <qlistview.h>
00011 #include <qpushbutton.h>
00012 #include <qlayout.h>
00013 #include <qmessagebox.h>
00014 #include <qtooltip.h>
00015 #include <qwhatsthis.h>
00016 #include <iostream>
00017 #include <map>
00018 #include <string>
00019 
00020 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00021 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00022 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00023 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00024 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00025 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00026 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00027 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00028 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00029 
00030 VisConfigEditor::VisConfigEditor (IgState *state, QWidget* parent,  const char* name, WFlags fl)
00031     : QWidget (parent, name, fl),
00032       m_state (state)
00033 {
00034     if (!name)
00035         setName ("VisConfigEditor");
00036     resize (613, 534); 
00037     setCaption (trUtf8 ("Configurable Parameters"));
00038     configEditorLayout = new QVBoxLayout (this, 11, 6, "configEditorLayout"); 
00039 
00040     layout2 = new QVBoxLayout (0, 0, 6, "layout2"); 
00041 
00042     configListView = new QListView (this, "configListView");
00043     configListView->addColumn (trUtf8 ("Configurable Parameter Editor"));
00044     configListView->addColumn (trUtf8 ("Value"));
00045     layout2->addWidget (configListView);
00046 
00047     layout1 = new QHBoxLayout (0, 0, 6, "layout1"); 
00048 
00049     helpBtn = new QPushButton (this, "helpBtn");
00050     helpBtn->setText (trUtf8 ("Help"));
00051     QToolTip::add (helpBtn, trUtf8 ("On-line Help", "Help on configurable parameters"));
00052     QWhatsThis::add (helpBtn, trUtf8 ("Help on configurable parameters.", "Help on configurable parameters."));
00053     layout1->addWidget (helpBtn);
00054 
00055     newBtn = new QPushButton (this, "newBtn");
00056     newBtn->setEnabled (false);
00057     newBtn->setText (trUtf8 ("New"));
00058     QToolTip::add (newBtn, trUtf8 ("Add New Parameter"));
00059     QWhatsThis::add (newBtn, trUtf8 ("Add new configurable parameter\n"
00060                                      "and set its value"));
00061     layout1->addWidget (newBtn);
00062 
00063     editBtn = new QPushButton (this, "editBtn");
00064     editBtn->setEnabled (false);
00065     editBtn->setText (trUtf8 ("Edit"));
00066     QToolTip::add (editBtn, trUtf8 ("Modify Value"));
00067     QWhatsThis::add (editBtn, trUtf8 ("Modify configurable parameter value"));
00068     layout1->addWidget (editBtn);
00069 
00070     refreshBtn = new QPushButton (this, "refreshBtn");
00071     refreshBtn->setEnabled (true);
00072     refreshBtn->setText (trUtf8 ("Refresh"));
00073     QToolTip::add (refreshBtn, trUtf8 ("Refresh Parameter List"));
00074     QWhatsThis::add (refreshBtn, trUtf8 ("Re-read the parameters list and update it on the screen"));
00075     layout1->addWidget (refreshBtn);
00076 
00077     okBtn = new QPushButton (this, "okBtn");
00078     okBtn->setText (trUtf8 ("OK"));
00079     okBtn->setOn (false);
00080     okBtn->setDefault (true);
00081     QToolTip::add (okBtn, trUtf8 ("Finish Editor Session"));
00082     layout1->addWidget (okBtn);
00083 
00084     cancelBtn = new QPushButton (this, "cancelBtn");
00085     cancelBtn->setText (trUtf8 ("Cancel"));
00086     QToolTip::add (cancelBtn, trUtf8 ("Terminate Editor Session"));
00087     layout1->addWidget (cancelBtn);
00088     layout2->addLayout (layout1);
00089     configEditorLayout->addLayout (layout2);
00090 
00091     // signals and slots connections
00092     connect (helpBtn, SIGNAL (clicked ()), this, SLOT (helpBtn_clicked ()));
00093     connect (editBtn, SIGNAL (clicked ()), this, SLOT (editBtn_clicked ()));
00094     connect (okBtn, SIGNAL (clicked ()), this, SLOT (okBtn_clicked ()));
00095     connect (cancelBtn, SIGNAL (clicked ()), this, SLOT (cancelBtn_clicked ()));
00096     connect (configListView, SIGNAL (doubleClicked (QListViewItem*)), this, SLOT (configListView_doubleClicked (QListViewItem*)));
00097     connect (configListView, SIGNAL (selectionChanged ()), this, SLOT (configListView_selectionChanged ()));
00098     connect (configListView, SIGNAL (selectionChanged (QListViewItem*)), this, SLOT (configListView_selectionChanged (QListViewItem*)));
00099     connect (refreshBtn, SIGNAL (clicked ()), this, SLOT (refreshBtn_clicked ()));
00100     connect (newBtn, SIGNAL (clicked ()), this, SLOT (newBtn_clicked ()));
00101 }
00102 
00103 /*  
00104  *  Destroys the object and frees any allocated resources
00105  */
00106 VisConfigEditor::~VisConfigEditor ()
00107 {
00108     // no need to delete child widgets, Qt does it all for us
00109 }
00110 
00114 void 
00115 VisConfigEditor::helpBtn_clicked ()
00116 {
00117     QMessageBox::about (this, "Configuration Editor",
00118                         "The configuration editor is an interactive tool\n"
00119                         "for Visualization parameter modification.\n\n"
00120                         "Changing a parameter couses re-draw of the objects which use it.\n"
00121                         "Copyright 2007 CMS\n");
00122 }
00123 
00127 void 
00128 VisConfigEditor::editBtn_clicked ()
00129 {
00130     VisParamEditor* parEditor = new VisParamEditor (m_state, 0, "parEditor");
00131     parEditor->peNameStr->setText (configListView->selectedItem ()->text (0));
00132     parEditor->peValueStr->setText (configListView->selectedItem ()->text (1));
00133     connect (parEditor->peApplyBtn, SIGNAL (clicked ()), this, SLOT (refreshBtn_clicked ()));
00134     connect (parEditor->peOkBtn, SIGNAL (clicked ()), this, SLOT (refreshBtn_clicked ()));
00135     parEditor->peApplyBtn->setEnabled (false);
00136     parEditor->show ();
00137 }
00138 
00143 void 
00144 VisConfigEditor::okBtn_clicked ()
00145 {
00146     this->hide ();
00147 }
00148 
00153 void 
00154 VisConfigEditor::cancelBtn_clicked ()
00155 {
00156     this->hide ();
00157 }
00158 
00163 void 
00164 VisConfigEditor::configListView_doubleClicked (QListViewItem * /* item */)
00165 {
00166     VisParamEditor *parEditor = new VisParamEditor (m_state, 0, "parEditor");
00167     parEditor->peNameStr->setText (configListView->selectedItem ()->text (0));
00168     parEditor->peValueStr->setText (configListView->selectedItem ()->text (1));
00169     connect (parEditor->peApplyBtn, SIGNAL (clicked ()), this, SLOT (refreshBtn_clicked ()));
00170     connect (parEditor->peOkBtn, SIGNAL (clicked ()), this, SLOT (refreshBtn_clicked ()));
00171     parEditor->peApplyBtn->setEnabled (false);
00172     parEditor->show ();
00173 }
00174 
00178 void 
00179 VisConfigEditor::configListView_selectionChanged ()
00180 {
00181     editBtn->setEnabled (true);
00182 }
00183 
00187 void 
00188 VisConfigEditor::configListView_selectionChanged (QListViewItem * /* item */)
00189 {
00190     editBtn->setEnabled (true);
00191 }
00192 
00196 void 
00197 VisConfigEditor::refreshBtn_clicked ()
00198 {
00199     IgQtLock ();
00200 
00201     VisConfiguration::VisState simpConf;
00202     VisConfiguration *configuration = VisConfiguration::get (m_state);
00203     ASSERT (configuration);
00204     configuration->dumpConfig (simpConf);
00205 
00206     configListView->clear ();
00207     editBtn->setEnabled (false);
00208 
00209     typedef std::map< std::string, std::string, std::less< std::string > >::const_iterator SimpConfItr;
00210     SimpConfItr param = simpConf.begin ();
00211     SimpConfItr paramEnd = simpConf.end ();
00212     for ( ; param != paramEnd; ++param) 
00213     {
00214         std::cout << (*param).first << " = " << (*param).second << std::endl;
00215         new QListViewItem (configListView, QString (((*param).first).c_str ()),  QString (((*param).second).c_str ()));
00216     }    
00217 }
00218 
00222 void 
00223 VisConfigEditor::newBtn_clicked ()
00224 {
00225     VisParamEditor *parEditor = new VisParamEditor (m_state, 0, "parEditor");
00226     connect (parEditor->peApplyBtn, SIGNAL (clicked ()), this, SLOT (refreshBtn_clicked ()));
00227     connect (parEditor->peOkBtn, SIGNAL (clicked ()), this, SLOT (refreshBtn_clicked ()));
00228     parEditor->peApplyBtn->setEnabled (false);
00229     parEditor->show ();
00230 }
00231 
00235 void 
00236 VisConfigEditor::show ()
00237 {
00238     refreshBtn_clicked ();
00239     QWidget::show ();
00240 }
00241 
00242 void 
00243 VisConfigEditor::saveConfig ()
00244 {
00245     refreshBtn_clicked ();
00246 }

Generated on Tue Jun 9 17:49:56 2009 for CMSSW by  doxygen 1.5.4