CMS 3D CMS Logo

IgIVView Class Reference

#include <Iguana/GLBrowsers/interface/IgIVView.h>

Inheritance diagram for IgIVView:

IgView

List of all members.

Public Member Functions

void dump (unsigned level, IgTwig *twig)
 IgIVView (IgPage *page)
IgStatestate (void)
 ~IgIVView (void)

Private Attributes

Ig3DBaseWindowm_browser
IgBrowserm_bt
IgStatem_state


Detailed Description

Definition at line 23 of file IgIVView.h.


Constructor & Destructor Documentation

IgIVView::IgIVView ( IgPage page  ) 

Definition at line 42 of file IgIVView.cc.

References arg, Ig3DBaseModel::attachPoint(), IgBrowser::browse(), IgSoTwig::buildFrom(), GenMuonPlsPt100GeV_cfg::cout, IgDocumentDataRoot::currentRoot(), dump(), IgFileFetcher::fetch(), file, EgammaValidation_cff::filename, IgArgsElement::find(), flush(), mergeAndRegister_online::fname, IgBrowserDB::get(), DBSPlugin::get(), IgViewDB::get(), IgQWidgetStackSite::hostWithName(), LOG, IgDocumentDataManager::lookup(), m_browser, m_bt, m_state, Ig3DBaseRep::magic(), Ig3DBaseRep::node(), prof2calltree::node, SiStripLorentzAngle_cfi::read, pydbsAccessor::root, s, IgPage::stackArea(), IgPage::state(), GsfMatrixTools::trace(), and warning.

00043     :IgView (page),
00044      m_state (0),
00045      m_browser (0),
00046      m_bt (0)
00047 {
00048     QString filename;
00049     QString workingDirectory ("./");
00050     QWidget *mainWindow = dynamic_cast<QMainWindow *> (IgQtAppWindowService::get (page->state ())->mainWindow ());
00051     
00052     IgArgsElement *args = IgArgsElement::get (page->state ());
00053     std::string fname;
00054     std::vector<std::string> arg;
00055     arg.push_back ("--ivfile");
00056     arg.push_back ("-iv");
00057     
00058     if (args->find (arg, fname, true)) filename = fname.c_str ();
00059     
00060     if (filename.isEmpty ())
00061         filename = QFileDialog::getOpenFileName (workingDirectory,
00062                                                  "Open Inventor Scenegraph (*.iv)",
00063                                                  mainWindow,
00064                                                  QString::null,
00065                                                  "Select Scenegraph to View");
00066     
00067     if (! filename.isEmpty ())
00068     {
00069         IgDocumentDataManager *dm = IgDocumentDataManager::get (page->state ());
00070         IgState *s =  dm->lookup (0, filename.latin1 ());
00071         
00072         if (s)
00073         {
00074             // Do not open the same file gain 
00075             IgDocumentDataRoot::currentRoot (filename.latin1 ());
00076             return;
00077         }
00078         
00079         // Read in the file
00080         IgFileFetcher *fetcher = IgFileFetcher::get (page->state ());
00081         if (! fetcher)
00082             fetcher = new IgFileFetcher (page->state ());
00083         
00084         std::string local = fetcher->fetch (filename.ascii ());
00085         if (local.empty ())
00086         {
00087             LOG (0, trace, LFivview, "SoReader: " << filename.ascii ()
00088                  << ": error: failed to access file.\n");
00089             QMessageBox::warning (mainWindow,
00090                                   "File open error", 
00091                                   "\""+ filename + "\" file not found.", "Ok");
00092             return;
00093         }
00094         
00095         SoNode      *node = 0;
00096         SoInput     file;
00097         if (! file.openFile (local.c_str ()) 
00098             || ! SoDB::read (&file, node) 
00099             || ! node)
00100         {
00101             LOG (0, trace, LFivview, "SoReader: " << filename.ascii ()
00102                  << ": error: failed to read\n");
00103             QMessageBox::warning (mainWindow,
00104                                   "File Access Error", 
00105                                   "Can not open file \""+ filename + "\" for reading.", "Ok");
00106             return;
00107         }
00108         IgDocumentDataRoot::currentRoot (filename.latin1 ());
00109         
00110         // Construct twigs from the node tree.  This always produces a
00111         // root that contains magic stuff to go into the browser's root
00112         // node, i.e. global magic clip planes etc.
00113         IgSoTwig    *twigs = IgSoTwig::buildFrom (node);
00114         dump (0, twigs);
00115         std::cout << std::flush;
00116         
00117         IgDocumentData::get (page->state ())->root (dynamic_cast<IgSoTwig*>(twigs->child(0)));
00118      
00119         m_state = new IgState (page->state ());
00120         new IgSelectionService (m_state);
00121         
00122         Ig3DModel *model = 0;
00123         IgModelManager::get (m_state)->lookup (m_state, &model);
00124         
00125         model->attachPoint ()->magic (twigs->magic ());
00126         model->attachPoint ()->node (twigs->node ());
00127         
00128         m_browser = dynamic_cast<Ig3DBaseWindow *> (IgViewDB::get ()->create ("3D Window", page ));
00129         
00130         IgQWidgetStackSite *stackArea = dynamic_cast<IgQWidgetStackSite *> (page->stackArea ());
00131         m_bt = IgBrowserDB::get()->create ("Twig", m_state,
00132                                            stackArea->hostWithName (filename.latin1 ()));
00133         m_bt->browse (twigs->child (0));
00134     } 
00135     else 
00136     {
00137         QMessageBox::warning (mainWindow,
00138                               "No file selected", 
00139                               "No OpenInventor file has been selected", "Ok");
00140     }
00141 }

IgIVView::~IgIVView ( void   ) 

Definition at line 143 of file IgIVView.cc.

References m_browser, m_bt, and m_state.

00144 {
00145     if (m_browser)
00146         delete m_browser;
00147     if (m_bt)
00148         delete m_bt;
00149     if (m_state)
00150         delete m_state;
00151 }


Member Function Documentation

void IgIVView::dump ( unsigned  level,
IgTwig twig 
)

Definition at line 154 of file IgIVView.cc.

References ASSERT, IgTwig::cascade(), IgTwig::child(), IgTwig::children(), LOG, n, IgTwig::name(), prof2calltree::node, IgTwig::selfVisible(), and GsfMatrixTools::trace().

Referenced by IgIVView().

00155 {
00156     ASSERT (twig);
00157     LOG (0, trace, LFivview, std::string(level, ' ') << "Twig " << twig->name () 
00158          << (twig->selfVisible () ? " visible" : " invisible")
00159          << (twig->cascade () ? " cascade; " : " no cascade; ")
00160          << ((IgSoTwig *) twig)->node ()->getNumChildren () 
00161          << " OIV children\n" );
00162     for (unsigned n = 0; n < twig->children (); ++n)
00163         dump (level + 2, twig->child (n));
00164 }

IgState * IgIVView::state ( void   )  [inline, virtual]

Reimplemented from IgView.

Definition at line 46 of file IgIVView.h.

References m_state.

00047 { return m_state; }


Member Data Documentation

Ig3DBaseWindow* IgIVView::m_browser [private]

Definition at line 37 of file IgIVView.h.

Referenced by IgIVView(), and ~IgIVView().

IgBrowser* IgIVView::m_bt [private]

Definition at line 38 of file IgIVView.h.

Referenced by IgIVView(), and ~IgIVView().

IgState* IgIVView::m_state [private]

Definition at line 36 of file IgIVView.h.

Referenced by IgIVView(), state(), and ~IgIVView().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:12 2009 for CMSSW by  doxygen 1.5.4