14 #include "msdevstudio/MSconfig.h"
40 using namespace hippodraw;
93 if ( status !=
Success )
return status;
110 list < XmlElement * > nodelist;
113 std::list < XmlElement * >::const_iterator first = nodelist.begin();
115 while ( first != nodelist.end() ) {
117 int id = element->
getID ();
122 catch (
const std::runtime_error & ) {
137 std::list < string >::iterator it;
164 const list < ViewBase * > &
167 const std::vector < const ViewBase * > & views )
174 const list < ViewBase * > &
177 const std::vector < const ViewBase * > & views )
184 const list < ViewBase * > &
187 const std::vector < const ViewBase * > & views )
201 const list < ViewBase * > &
216 #ifdef ITERATOR_MEMBER_DEFECT
219 vector < const ViewBase * > ::const_iterator first = views.begin ();
220 while ( first != views.end () ) {
223 if ( yes ==
false )
break;
246 map < const DataSource *, XmlElement * > ::iterator first
248 for ( ; first !=
m_data.end (); ++ first ) {
249 delete first->second;
287 const std::string & filename )
302 addViews (
const std::vector < const ViewBase * > & views )
306 std::vector < const ViewBase * >::const_iterator it = views.begin();
307 for ( ; it != views.end(); ++it ) {
333 std::map < const DataSource *, XmlElement * >::const_iterator it
335 if ( it !=
m_data.end () ) {
350 std::map < int, const DataSource * >::const_iterator it
363 std::map < int, const TupleCut * >::iterator it
378 std::map < int, DataRep * >::iterator it
390 std::map < int, PlotterBase * >::iterator it
411 vector < DataSource * > tuples;
413 #ifdef ITERATOR_MEMBER_DEFECT
416 vector < DataSource * > ::const_iterator first = tuples.begin();
417 for ( ; first != tuples.end(); ++first ) {
418 const void * addr = reinterpret_cast <
const void * > ( *first );
419 int ref =
getId ( addr );
428 vector < const TupleCut * > cut_list;
433 vector < const TupleCut * > :: iterator first = cut_list.begin ();
434 while ( first != cut_list.end () ) {
436 void * addr = reinterpret_cast <
void * > ( &cut );
437 int id =
getId ( addr );
445 list < XmlElement * > nodelist;
448 #ifdef ITERATOR_MEMBER_DEFECT
451 list < XmlElement * > ::const_iterator first = nodelist.begin();
453 for ( ; first != nodelist.end(); ++first ) {
455 int id = element->
getID ();
465 list < XmlElement * > nodelist;
469 std::list < XmlElement * >::const_iterator first = nodelist.begin();
471 for ( ; first != nodelist.end(); ++first ) {
474 vector < TupleCut * > cuts;
476 for (
unsigned int i = 0; i < cuts.size (); i++ ) {
477 int id = element -> getID ();
478 if ( i == 1 )
id = -id;
484 int id = element->
getID ();
498 list < XmlElement * > nodelist;
501 if ( nodelist.empty () )
return;
504 std::list < XmlElement * >::const_iterator first = nodelist.begin ();
505 for ( ; first != nodelist.end(); ++ first ) {
509 m_view -> connectPlotters ( root );
530 std::list < std::string > &
hippodraw::DataRep * createObject(const XmlElement *element)
Returns a newly created object based on the XmlElement.
XmlElement * createElement(const DataSource &ntuple)
Returns a newly created XmlElement for DataSource.
static DataSourceController * instance()
Returns the pointer to the singleton instance.
The abstract base class for views.
hippodraw::CutController class interface
A singleton class that handles the application logic for cuts.
DataSourceController class interface.
HiNTupleXML class interface.
const std::list< ViewBase * > & getFromPasteboard(ViewFactory *factory, const std::vector< const ViewBase * > &views)
Creates and returns a list of objects that was copied to the pasteboard.
virtual XmlElement * createElement(const std::string &tagName)=0
Creates a new DOM element wrapper object and returns a pointer to it.
int m_id
The next integer identifier to be generated.
virtual Status openUpdatedNTuples()
Open the missing tuples updated by GUI.
virtual Status saveToFile(const std::string &filename)=0
Saves the document to the file.
int getId(const void *address)
Returns the unique integer identifier for given address.
PlotterBase * getPlotter(int ref)
Returns a pointer to the PlotterBase object from the XML refereed Id.
Base class for DataSource.
virtual void getViews()
De-serializes the ViewBase objects.
A abstract base class for font handling.
std::string getName(const XmlElement &tag) const
Returns the name of the HiNTuple object.
virtual void newDocument(const std::string &name)=0
Creates a new document.
XmlController()
A default constructor for avoiding creation except by itself or with derived classes.
hippodraw::ViewBase class interface
std::list< ViewBase * > m_views
A list of reconstructed views.
void fillNodeList(const XmlElement *element, std::list< XmlElement * > &nodelist)
Fills the nodelist with immediate child nodes of element with nodes that can be handled by this objec...
void getTupleCuts()
Creates all the TupleCut objects and fills the reference map.
void fillTupleCutList(const std::vector< const ViewBase * > &views, std::vector< const TupleCut * > &cut_list)
Fills the cut_map with the TupleCut objects contained the list of views, if any.
virtual void appendChild(const XmlNode &child)=0
Appends a child element to the element.
A singleton class that is does XML serialization and deserialization of derived classes of HiNTuple...
void saveToDocument(const std::vector< const ViewBase * > &selviews)
Save the ViewBase objects in selview to a XML in memory document.
virtual ~XmlController()
The destructor.
static CutController * instance()
Returns the pointer to the singleton instance.
void fillTupleCutMap(const std::vector< const ViewBase * > &views)
Fills the TupleCut map with TupleCut objecs contained in one in the list of views.
A class that is does XML serialization and de-serialization of derived classes of TupleCut...
std::map< int, DataRep * > m_datarep_map
A mapping from DataRep Id to created DataRep.
void getDataReps()
Creates all the DataRep objects and fills the reference map.
TupleCutXML class interface.
virtual void createDocument(const std::string &doc_name)
Creates an DOM Document with name doc_name.
virtual ViewBase * createView(PlotterBase *plotter) const =0
Creates a view for the plotter.
Status
Return codes of opening file.
hippodraw::DataRepXML class interface
HiNTupleXML * m_ntuple
The singleton instance of the XML handler for data source.
void registerPlotter(int id, PlotterBase *plotter)
Registers the plotter with id.
virtual XmlElement * addDataSource(const DataSource *ntuple)
Adds the DataSource to the document if it doesn't already exist.
const TupleCut * getTupleCut(int ref_id)
Returns pointer to the TupleCut from the xml reference Id.
TupleCutXML * m_tuple_cut_xml
The singleton instance of the XML handler for TupleCut objects.
XmlDocument class interface.
void clearDataSourceMap()
Deletes each element in the map and clears the map.
void getDataSources(std::vector< DataSource * > &, bool all=true) const
Clears and fills the vector with the registered DataSource objects.
XmlController class interface.
bool areDataSourcesSaved(const std::vector< const ViewBase * > &views)
Returns true if all the NTuple objects used by the views have been saved to or read from a file...
XmlElement * createElement(const ViewBase &view)
Returns a newly created XmlElement with attributes set for view.
FontBase * createFont() const
Creates a empty QtFont object.
The abstract base class for a factory that creates objects closely related to the graphics subsystem ...
void saveToPasteboard(const std::vector< const ViewBase * > &)
Saves the document represented by the list of ViewBase objects to the pasteboard. ...
static XmlDocument * m_xml_doc
The current document being generated or read.
std::map< const void *, int >::iterator AddrMapIterator_t
The iterator for memory address to unique integer identifier.
A pure virtual base class of XML element wrapper.
TupleCut * getObject(const XmlElement &tag) const
Creates an TupleCut object and sets its properties from the XmlElement.
The class expresses a cut on a DataSource, i.e.
A class that is does XML serialization and de-serialization of derived classes of DataRep...
DataRep * getDataRep(int ref)
Returns a pointer to the DataRep from the xml reference Id.
Status
Status codes for opening an XML document.
ViewFactory * m_view_factory
The factory to be used for creating views.
std::list< std::string > m_missing_tuples
A list of missing NTuples.
bool isPasteboardEmpty()
Returns true if global pasteboard is empty.
The base class for the PlotterBase hierarchy.
ViewFactory class interface.
std::list< std::string > & getMissingTuples()
Return a list of missing tuples.
A class XML creation and parsing of XmlElement for ViewBase class.
ViewBaseXML class interface.
The base class for data representations.
virtual XmlElement * documentElement() const =0
Returns the root document element.
virtual Status setContent(const std::string &filename)=0
Sets the content of the XML document from the text in the file filename.
virtual Status openNTuples()
Attempts to open ntuple files in the current document and put them into the map.
DataRepXML * m_datarep_xml
The singleton instance of the DataRepXML object.
ViewBase * createView(PlotterBase *)
Creates a new view for the current PlotterBase object and adds it to the list of views.
std::map< int, const TupleCut * > m_tuple_cut_map
A mapping from XML id to created TupleCut.
virtual void getObjects(const XmlElement *element)
Creates an object derived from ViewBase.
XmlDocument * m_selectboard
A copy of a selection.
std::map< int, PlotterBase * > m_plotter_map
The mapping from PlotterBase Id to created PlotterBase.
const DataSource * getDataSource(int ref_id)
Returns pointer to data source from the xml reference ID.
std::vector< int > m_missing_ids
A vector of the ids in the Xml file of the missing NTuples.
const DataSource * getObject(const XmlElement &tag) const
Returns the DataSource corresponding to XmlElement.
virtual int getID() const =0
Returns the ID of the element, if it has one.
bool areDataSourcesSaved(const ViewBase &view)
Returns true if all the NTuple objects used by the view have been save to or read from a file...
void addViews(const std::vector< const ViewBase * > &views)
Adds ViewBase elements to the root of the document.
hippodraw::DataSource class interface.
ViewBaseXML * m_view
The singleton instance of a ViewBaseXML object.
std::map< int, const DataSource * > m_tuple_map
A mapping from XML id to created data sources.
XmlDocument * m_pasteboard
The pasteboard object.
Status saveToFile(const std::vector< const ViewBase * > &views, const std::string &filename)
Saves the document represented by list of ViewBase objects to file with name filename.
XmlElement class interface.
std::map< const void *, int > m_addr_map
The map of memory address to unique integer identifier.
virtual void appendChild(XmlElement &)=0
Appends the root element to the document.
An abstract base class of XML document element wrapper.
std::map< const DataSource *, XmlElement * > m_data
The map of data sources to XmlElements for the current document.
void fillNTupleMap()
Fills the NTuple map with NTuple objects currently in memory.
const std::list< ViewBase * > & getFromDocument(ViewFactory *facotry, const std::vector< const ViewBase * > &views)
Restores the views in the current document.
Status openFile(const std::string &filename)
Attempts to open and parse the specified HippoDraw document.
void saveToSelectionCopy(const std::vector< const ViewBase * > &views)
Saves the document represented by the list of ViewBase objects to the selection copy.
virtual Status openDocument(const std::string &filename)
Opens an existing DOM Document file filename.
void connectDataRep(DataRep *rep, const std::vector< const ViewBase * > &views)
Connects the DataRep object to its appropriate Cut Plotter.
const std::list< ViewBase * > & getFromSelectionCopy(ViewFactory *factory, const std::vector< const ViewBase * > &views)
Creates and returns objects that were copied to the selection copy.
A singleton class that is the interface between GUI and the DataSource objects.
virtual bool serializeViews(const std::vector< const ViewBase * > &views)
Serializes the ViewBase objects in views and their appropriate subcomponents.