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 > &
std::map< int, PlotterBase * > m_plotter_map
The mapping from PlotterBase Id to created PlotterBase.
std::list< ViewBase * > m_views
A list of reconstructed views.
virtual ViewBase * createView(PlotterBase *plotter) const =0
Creates a view for the plotter.
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...
void getTupleCuts()
Creates all the TupleCut objects and fills the reference map.
ViewBaseXML * m_view
The singleton instance of a ViewBaseXML object.
virtual XmlElement * createElement(const std::string &tagName)=0
Creates a new DOM element wrapper object and returns a pointer to it.
static CutController * instance()
Returns the pointer to the singleton instance.
void connectDataRep(DataRep *rep, const std::vector< const ViewBase * > &views)
Connects the DataRep object to its appropriate Cut Plotter.
virtual Status openNTuples()
Attempts to open ntuple files in the current document and put them into the map.
void fillNTupleMap()
Fills the NTuple map with NTuple objects currently in memory.
TupleCutXML class interface.
const std::list< ViewBase * > & getFromDocument(ViewFactory *facotry, const std::vector< const ViewBase * > &views)
Restores the views in the current document.
HiNTupleXML * m_ntuple
The singleton instance of the XML handler for data source.
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.
hippodraw::DataRepXML class interface
std::string getName(const XmlElement &tag) const
Returns the name of the HiNTuple object.
virtual void getObjects(const XmlElement *element)
Creates an object derived from ViewBase.
std::list< std::string > m_missing_tuples
A list of missing NTuples.
A class that is does XML serialization and de-serialization of derived classes of DataRep...
virtual Status saveToFile(const std::string &filename)=0
Saves the document to the file.
virtual bool serializeViews(const std::vector< const ViewBase * > &views)
Serializes the ViewBase objects in views and their appropriate subcomponents.
XmlDocument class interface.
XmlController class interface.
bool isPasteboardEmpty()
Returns true if global pasteboard is empty.
std::map< int, const DataSource * > m_tuple_map
A mapping from XML id to created data sources.
std::map< const void *, int > m_addr_map
The map of memory address to unique integer identifier.
TupleCut * getObject(const XmlElement &tag) const
Creates an TupleCut object and sets its properties from the XmlElement.
A pure virtual base class of XML element wrapper.
ViewFactory class interface.
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...
The class expresses a cut on a DataSource, i.e.
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.
const std::list< ViewBase * > & getFromSelectionCopy(ViewFactory *factory, const std::vector< const ViewBase * > &views)
Creates and returns objects that were copied to the selection copy.
virtual int getID() const =0
Returns the ID of the element, if it has one.
void addViews(const std::vector< const ViewBase * > &views)
Adds ViewBase elements to the root of the document.
A abstract base class for font handling.
The base class for the PlotterBase hierarchy.
hippodraw::DataSource class interface.
hippodraw::DataRep * createObject(const XmlElement *element)
Returns a newly created object based on the XmlElement.
std::list< std::string > & getMissingTuples()
Return a list of missing tuples.
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.
virtual void newDocument(const std::string &name)=0
Creates a new document.
A class XML creation and parsing of XmlElement for ViewBase class.
The base class for data representations.
std::map< const DataSource *, XmlElement * > m_data
The map of data sources to XmlElements for the current document.
A singleton class that is does XML serialization and deserialization of derived classes of HiNTuple...
Status openFile(const std::string &filename)
Attempts to open and parse the specified HippoDraw document.
virtual void appendChild(const XmlNode &child)=0
Appends a child element to the element.
An abstract base class of XML document element wrapper.
std::map< int, const TupleCut * > m_tuple_cut_map
A mapping from XML id to created TupleCut.
XmlDocument * m_selectboard
A copy of a selection.
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.
int m_id
The next integer identifier to be generated.
virtual ~XmlController()
The destructor.
const DataSource * getDataSource(int ref_id)
Returns pointer to data source from the xml reference ID.
Status
Status codes for opening an XML document.
std::vector< int > m_missing_ids
A vector of the ids in the Xml file of the missing NTuples.
virtual Status openUpdatedNTuples()
Open the missing tuples updated by GUI.
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...
virtual void createDocument(const std::string &doc_name)
Creates an DOM Document with name doc_name.
int getId(const void *address)
Returns the unique integer identifier for given address.
Status
Return codes of opening file.
XmlDocument * m_pasteboard
The pasteboard object.
A singleton class that is the interface between GUI and the DataSource objects.
TupleCutXML * m_tuple_cut_xml
The singleton instance of the XML handler for TupleCut objects.
XmlElement class interface.
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.
void clearDataSourceMap()
Deletes each element in the map and clears the map.
XmlController()
A default constructor for avoiding creation except by itself or with derived classes.
void getDataSources(std::vector< DataSource * > &, bool all=true) const
Clears and fills the vector with the registered DataSource objects.
The abstract base class for a factory that creates objects closely related to the graphics subsystem ...
The abstract base class for views.
XmlElement * createElement(const ViewBase &view)
Returns a newly created XmlElement with attributes set for view.
void saveToPasteboard(const std::vector< const ViewBase * > &)
Saves the document represented by the list of ViewBase objects to the pasteboard. ...
hippodraw::CutController class interface
static XmlDocument * m_xml_doc
The current document being generated or read.
void saveToDocument(const std::vector< const ViewBase * > &selviews)
Save the ViewBase objects in selview to a XML in memory document.
const DataSource * getObject(const XmlElement &tag) const
Returns the DataSource corresponding to XmlElement.
std::map< const void *, int >::iterator AddrMapIterator_t
The iterator for memory address to unique integer identifier.
XmlElement * createElement(const DataSource &ntuple)
Returns a newly created XmlElement for DataSource.
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.
virtual void getViews()
De-serializes the ViewBase objects.
DataRep * getDataRep(int ref)
Returns a pointer to the DataRep from the xml reference Id.
ViewFactory * m_view_factory
The factory to be used for creating views.
virtual void appendChild(XmlElement &)=0
Appends the root element to the document.
A singleton class that handles the application logic for cuts.
DataSourceController class interface.
FontBase * createFont() const
Creates a empty QtFont object.
ViewBaseXML class interface.
HiNTupleXML class interface.
hippodraw::ViewBase class interface
void fillTupleCutMap(const std::vector< const ViewBase * > &views)
Fills the TupleCut map with TupleCut objecs contained in one in the list of views.
std::map< int, DataRep * > m_datarep_map
A mapping from DataRep Id to created DataRep.
list< QAction * >::iterator it
void getDataReps()
Creates all the DataRep objects and fills the reference 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.
PlotterBase * getPlotter(int ref)
Returns a pointer to the PlotterBase object from the XML refereed Id.
const TupleCut * getTupleCut(int ref_id)
Returns pointer to the TupleCut from the xml reference Id.
static DataSourceController * instance()
Returns the pointer to the singleton instance.
Base class for DataSource.
A class that is does XML serialization and de-serialization of derived classes of TupleCut...