COPASI API  4.16.103
CLRenderResolver.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layout/CLRenderResolver.h,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/09/30 16:35:20 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #ifndef CLRenderResolver_H__
15 #define CLRenderResolver_H__
16 
17 #include <map>
18 #include <string>
19 
22 
24 class CLStyle;
25 class CLColorDefinition;
26 class CLLineEnding;
27 class CLGradientBase;
28 class CLGraphicalObject;
29 class CLColorDefinition;
31 
32 /**
33  * Display list could be used to cache the styles.
34  * For styles with only relative coordinates, a display list for a unit box can
35  * be created. The display list only has to be scaled and translated.
36  * For styles with only absolute coordinates, a display list can be created,
37  * this display list may only be translated, but not scaled later on.
38  * Styles that use relative and absolute coordinates are more difficult. Here
39  * the bounding box has to be known in order to draw the elements.
40  * We could still create one display list per use of the style if that would to
41  * create to many display lists. Another optimization option for this would be to
42  * collect all usages of the style where the boundinng box has the same size into one.
43  * Display lists for line endings could also be useful, the same restriction as
44  * for styles apply here.
45  */
46 
48 {
49 protected:
50  /**
51  * The render information object.
52  * which is created by the flattener.
53  */
55 
56  /**
57  * Flag that determines if the resolver is for a local or a global
58  * render information object.
59  * Currently it is not used at all.
60  */
61  bool mLocal;
62 
63  // we create some maps to have faster access to elements
64 
65  /**
66  * Map to store references to styles based on ids.
67  */
68  std::map<std::string, const CLStyle*> mKeyMap;
69 
70  /**
71  * Map to store references to styles based on roles.
72  */
73  std::map<std::string, const CLStyle*> mRoleMap;
74 
75  /**
76  * Map to store references to styles based on types.
77  */
78  std::map<std::string, const CLStyle*> mTypeMap;
79 
80  /**
81  * Map to store references to colord definitions based on id.
82  */
83  std::map<std::string, const CLColorDefinition*> mColorMap;
84 
85  /**
86  * Map to store references to colord definitions based on id.
87  */
88  std::map<std::string, const CLGradientBase*> mGradientMap;
89 
90  /**
91  * Map to store references to color definitions based on id.
92  */
93  std::map<std::string, const CLLineEnding*> mLineEndingMap;
94 
96 
97  /**
98  * Map to store object roles that were deduced by the renderer
99  * and are used to suplement the layout information in case a default
100  * stylesheet is used.
101  */
102  std::map<const CLMetabReferenceGlyph*, std::string> mDeducedObjectRoles;
103 
104 private:
105  // declare the copy constructor and the assignment operator private
106  // so that they can't be called and that they won't be created by the
107  // compiler.
109  CLRenderResolver& operator=(const CLRenderResolver& /*src*/) {return *this;};
110 
111 public:
112  /**
113  * Constructor that takes a local render information object as the argument
114  * as well as a list of local and a list of global render information objects
115  * that are needed to resolve external references.
116  */
117  CLRenderResolver(const CLLocalRenderInformation& renderInformation,
119  const CCopasiVector<CLGlobalRenderInformation>& globalList);
120 
121  /**
122  * Constructor that takes a global render information object as the argument
123  * and a list of additional global render information objects that might be
124  * needed to resolve external references.
125  * means it should contain all information from referenced render information objects.
126  */
127  CLRenderResolver(const CLGlobalRenderInformation& renderInformation,
128  const CCopasiVector<CLGlobalRenderInformation>& globalList);
129 
130  /**
131  * Destructor.
132  */
134 
135  /**
136  * Method that tries to find the style for the given graphical
137  * object that fits best.
138  * If no style is found NULL is returned.
139  */
140  const CLStyle* resolveStyle(const CLGraphicalObject* pObject) const;
141 
142  /**
143  * Method that tries to find the style for the given role.
144  * If no style is found NULL is returned.
145  */
146  const CLStyle* resolveStyleForRole(const std::string& role) const;
147 
148  /**
149  * Method that tries to find the style for the given type.
150  * If no style is found NULL is returned.
151  */
152  const CLStyle* resolveStyleForType(const std::string& type) const;
153 
154  /**
155  * Method that tries to find the style for the given key.
156  * If no style is found NULL is returned.
157  */
158  const CLStyle* resolveStyleForKey(const std::string& key) const;
159 
160  /**
161  * Returns the gradient definition for a given id.
162  */
163  const CLGradientBase* getGradientBase(const std::string& id) const;
164 
165  /**
166  * Returns the color definition for a given id.
167  */
168  const CLColorDefinition* getColorDefinition(const std::string& id) const;
169 
170  /**
171  * Returns the line ending for a given id.
172  */
173  const CLLineEnding* getLineEnding(const std::string& id) const;
174 
175  /**
176  * Returns the background color.
177  */
178  const CLColorDefinition* getBackgroundColor() const;
179 
180  /**
181  * Sets the deduced object roles.
182  */
183  void setDeducedObjectRoles(const std::map<const CLMetabReferenceGlyph*, std::string>& deducedObjectRoles);
184 
185 protected:
186  /**
187  * This method fills the color, gradient and line ending maps for a render
188  * information object.
189  */
190  void fill_base_maps(const CLRenderInformationBase* pRenderInformation);
191 
192  /**
193  * This method fills the type and role maps for a global render information
194  * object.
195  */
196  void fill_global_maps(const CLGlobalRenderInformation* pRenderInformation);
197 
198  /**
199  * This method fills the type, role and id maps for a local render information
200  * object.
201  */
202  void fill_local_maps(const CLLocalRenderInformation* pRenderInformation);
203 
204  /**
205  * Sets the background color from the given render information.
206  */
207  void setBackgroundColor();
208 };
209 
210 #endif // CLRenderResolver_H__
std::map< std::string, const CLStyle * > mKeyMap
std::map< const CLMetabReferenceGlyph *, std::string > mDeducedObjectRoles
std::map< std::string, const CLGradientBase * > mGradientMap
const CLColorDefinition * getColorDefinition(const std::string &id) const
const CLStyle * resolveStyle(const CLGraphicalObject *pObject) const
void setDeducedObjectRoles(const std::map< const CLMetabReferenceGlyph *, std::string > &deducedObjectRoles)
CLRenderResolver & operator=(const CLRenderResolver &)
void fill_global_maps(const CLGlobalRenderInformation *pRenderInformation)
const CLStyle * resolveStyleForType(const std::string &type) const
std::map< std::string, const CLStyle * > mRoleMap
void fill_base_maps(const CLRenderInformationBase *pRenderInformation)
std::map< std::string, const CLColorDefinition * > mColorMap
CLRenderResolver(const CLRenderResolver &)
const CLColorDefinition * getBackgroundColor() const
std::map< std::string, const CLStyle * > mTypeMap
CLColorDefinition * mpBackgroundColor
const CLLineEnding * getLineEnding(const std::string &id) const
void fill_local_maps(const CLLocalRenderInformation *pRenderInformation)
const CLStyle * resolveStyleForRole(const std::string &role) const
const CLGradientBase * getGradientBase(const std::string &id) const
const CLStyle * resolveStyleForKey(const std::string &key) const
CLRenderInformationBase * mpRenderInformation
std::map< std::string, const CLLineEnding * > mLineEndingMap