NCBI C++ ToolKit
style_manager.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: style_manager.hpp 59476 2013-08-28 11:25:58Z thiessen $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Paul Thiessen
27 *
28 * File Description:
29 * manager object to track drawing style of objects at various levels
30 *
31 * ===========================================================================
32 */
33 
34 #ifndef CN3D_STYLE_MANAGER__HPP
35 #define CN3D_STYLE_MANAGER__HPP
36 
37 #include <corelib/ncbistl.hpp>
38 #include <corelib/ncbiobj.hpp>
39 
43 
44 #include <string>
45 #include <list>
46 #include <map>
47 #include <vector>
48 
49 #include "vector_math.hpp"
50 
51 class wxWindow;
52 
53 
54 BEGIN_SCOPE(Cn3D)
55 
56 // for hydrophobicity and charge coloring
57 extern const double UNKNOWN_HYDROPHOBICITY;
58 extern double GetHydrophobicity(char code);
59 extern int GetCharge(char code);
60 
61 
62 // StyleSettings is a complete set of instructions on how to draw a set of
63 // molecules. It is used for "global" settings as well as for individual
64 // annotations. It is meant to contain all settings that can be saved on
65 // a per-output file basis.
66 
67 // values of enumerations must match those in cn3d.asn!
68 
70 {
71 public:
72  // for different types of backbone displays
74  eOff = 1,
75  eTrace = 2,
76  ePartial = 3,
77  eComplete = 4
78  };
79 
80  // available drawing styles (not all necessarily applicable to all objects)
82  // for atoms and bonds
83  eWire = 1,
84  eTubes = 2,
87  eWireWorm = 5,
88  eTubeWorm = 6,
89 
90  // for 3d-objects
92  eWithoutArrows = 8
93  };
94 
95  // available color schemes (not all necessarily applicable to all objects)
96  enum eColorScheme {
97  eElement = 1,
98  eObject = 2,
99  eMolecule = 3,
100  eDomain = 4,
101  eResidue = 20,
105  eCharge = 15,
106  eRainbow = 16,
108 
109  // different alignment conservation coloring (currently only used for proteins)
110  eAligned = 7,
112  eVariety = 9,
115  eFit = 12,
116  eBlockFit = 17,
118  eBlockRowFit = 19
119  };
120 
121  typedef struct {
126  } BackboneStyle;
127 
128  typedef struct {
129  bool isOn;
133  } GeneralStyle;
134 
135  enum eLabelType {
137  eThreeLetter = 2
138  };
139 
140  enum eNumberType {
142  eSequentialNumbering = 1, // from 1 by residues present, to match sequence loc
143  ePDBNumbering = 2 // use number assigned by PDB
144  };
145 
146  typedef struct {
147  int spacing;
150  bool
151  terminiOn, // label chain termini
152  white; // use white labels (or if bg is light, use black for contrast)
153  } LabelStyle;
154 
156 
163 
165 
167 
169 
172 
173  // to set to predetermined renderings
181  };
183 
184  // to set to predetermined colors
205  };
207 
208  // default labeling style
209  void SetDefaultLabeling(void);
210 
211  // default and copy constructors
213  {
217  }
218  StyleSettings(const StyleSettings& orig) { *this = orig; }
219 
220  // copy settings
222 
223  // to convert to/from asn
224  bool SaveSettingsToASN(ncbi::objects::CCn3d_style_settings *styleASN) const;
225  bool LoadSettingsFromASN(const ncbi::objects::CCn3d_style_settings& styleASN);
226 };
227 
228 
229 class StructureSet;
230 class StructureObject;
231 class Residue;
232 class AtomPntr;
233 class AtomCoord;
234 class Bond;
235 class BondStyle;
236 class AtomStyle;
237 class Object3D;
238 class ObjectStyle;
239 class Helix3D;
240 class HelixStyle;
241 class Strand3D;
242 class StrandStyle;
243 class Molecule;
244 class MoleculeIdentifier;
245 class AnnotateDialog;
246 
248 {
249 public:
250  StyleManager(const StructureSet *set);
251 
252  // display styles for various types of objects
263  };
264 
265  const Vector& GetBackgroundColor(void) const { return globalStyle.backgroundColor; }
266 
267  // style accessors for individual objects
268  bool GetAtomStyle(const Residue *residue, const AtomPntr& atom,
269  const AtomCoord *coord, AtomStyle *atomStyle,
270  const StyleSettings::BackboneStyle* *saveBackboneStyle = NULL,
271  const StyleSettings::GeneralStyle* *saveGeneralStyle = NULL) const;
272  bool GetBondStyle(const Bond *bond,
273  const AtomPntr& atom1, const AtomCoord *coord1,
274  const AtomPntr& atom2, const AtomCoord *coord2,
275  double bondLength, BondStyle *bondStyle) const;
276  bool GetHelixStyle(const StructureObject *object,
277  const Helix3D& helix, HelixStyle *helixStyle) const;
278  bool GetStrandStyle(const StructureObject *object,
279  const Strand3D& strand, StrandStyle *strandStyle) const;
280 
281  // bring up dialog to edit global style; returns true if style changed
282  bool EditGlobalStyle(wxWindow *parent);
283 
284  // edit user annotations; returns true if any style changed
285  bool EditUserAnnotations(wxWindow *parent);
286 
287  // check style option consistency
288  bool CheckStyleSettings(StyleSettings *settings);
289  bool CheckGlobalStyleSettings(void);
290 
291  // load/save asn style dictionary to/from current styles
292  ncbi::objects::CCn3d_style_dictionary * CreateASNStyleDictionary(void) const;
293  bool LoadFromASNStyleDictionary(const ncbi::objects::CCn3d_style_dictionary& styleDictionary);
294 
295  // add a new user style with default settings; returns true if successful,
296  // and sets style ID assigned to the new style and pointer to the new style structure
297  bool AddUserStyle(int *id, StyleSettings **newStyle);
298 
299  // remove a style; returns false if a user style of the given ID is not found
300  bool RemoveUserStyle(int id);
301 
302  // StyleSettings accessors
303  const StyleSettings& GetGlobalStyle(void) const { return globalStyle; }
304  const StyleSettings& GetStyleForResidue(const StructureObject *object,
305  int moleculeID, int residueID) const;
306  const Vector& GetObjectColor(const Molecule *molecule) const;
307  const StyleSettings * GetUserStyle(int id) const
308  {
309  StyleMap::const_iterator style = userStyles.find(id);
310  return ((style != userStyles.end()) ? &(style->second) : NULL);
311  }
313  {
314  StyleMap::iterator style = userStyles.find(id);
315  return ((style != userStyles.end()) ? &(style->second) : NULL);
316  }
317 
318  // checks for presence of active user styles
319  bool MoleculeHasUserStyle(const StructureObject *object, int moleculeID) const;
320  bool ResidueHasUserStyle(const StructureObject *object, int moleculeID, int residueID) const;
321 
322  // predefined styles
325 
326  // set global style
327  bool SetGlobalStyle(const ncbi::objects::CCn3d_style_settings& styleASN);
328 
329  // load/save asn user annotations
330  bool SaveToASNUserAnnotations(ncbi::objects::CCn3d_user_annotations *annotations) const;
331  bool LoadFromASNUserAnnotations(const ncbi::objects::CCn3d_user_annotations& annotations);
332 
333  // typedefs for UserAnnotation
334  typedef std::map < const MoleculeIdentifier * , std::vector < bool > > ResidueMap;
335  class UserAnnotation : public ncbi::CObject {
336  public:
338  int styleID;
341  };
342  typedef std::list < ncbi::CRef < UserAnnotation > > UserAnnotationList;
343 
344  // add a new (empty) annotation; returns a pointer to the new UserAnnotation structure
346 
347  // remove an annotation; returns false if the given annotation isn't found
348  bool RemoveUserAnnotation(UserAnnotation *annotation);
349 
350  // sets the displayed status of the given annotation; returns false if annotation not found.
351  // Should use this rather than setting UserAnnotation.isDisplayed directly.
352  bool DisplayUserAnnotation(UserAnnotation *annotation, bool display);
353 
354  // moves the priority of annotation up (moveUp==true) or down (moveUp==false);
355  // returns false if annotation not found
356  bool MoveUserAnnotation(UserAnnotation *annotation, bool moveUp);
357 
358  // annotation list accessors
361 
362 private:
365 
366  // a set of user styles, each with its own unique integer id
367  typedef std::map < int , StyleSettings > StyleMap;
369 
370  // the priority-ordered list of annotations, including which are currently displayed;
371  // lowest-indexed annotation has highest priority (to reflect GUI list where the
372  // annotation on top of the stack has priority)
374 
375  bool GetObjectStyle(const StructureObject *object, const Object3D& object3D,
376  const StyleSettings::GeneralStyle& generalStyle, ObjectStyle *objectStyle) const;
377 };
378 
379 // the following are convenience containers to tell the Draw functions how
380 // to render various individual objects
381 
383 {
384 public:
387  double radius, alpha;
388  unsigned int name;
391 };
392 
394 {
395 public:
396  typedef struct {
399  double radius;
400  bool atomCap;
401  unsigned int name;
402  } EndStyle;
404  bool midCap;
405  double tension;
406 };
407 
409 {
410 public:
414 };
415 
416 class HelixStyle : public ObjectStyle
417 {
418 public:
420 };
421 
422 class StrandStyle : public ObjectStyle
423 {
424 public:
425  double width, thickness;
426 };
427 
428 END_SCOPE(Cn3D)
429 
430 #endif // CN3D_STYLE_MANAGER__HPP
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
std::string centerLabel
bool isHighlighted
unsigned int name
StyleManager::eDisplayStyle style
double tension
EndStyle end1
EndStyle end2
Definition: bond.hpp:50
double arrowTipWidthProportion
double arrowBaseWidthProportion
StyleManager::eDisplayStyle style
double arrowLength
std::map< int, StyleSettings > StyleMap
bool LoadFromASNStyleDictionary(const ncbi::objects::CCn3d_style_dictionary &styleDictionary)
const UserAnnotationList & GetUserAnnotations(void) const
bool GetStrandStyle(const StructureObject *object, const Strand3D &strand, StrandStyle *strandStyle) const
void SetGlobalRenderingStyle(StyleSettings::ePredefinedRenderingStyle style)
bool CheckStyleSettings(StyleSettings *settings)
const StyleSettings & GetStyleForResidue(const StructureObject *object, int moleculeID, int residueID) const
UserAnnotation * AddUserAnnotation(void)
std::map< const MoleculeIdentifier *, std::vector< bool > > ResidueMap
bool RemoveUserStyle(int id)
const StyleSettings & GetGlobalStyle(void) const
bool DisplayUserAnnotation(UserAnnotation *annotation, bool display)
const StructureSet * structureSet
ncbi::objects::CCn3d_style_dictionary * CreateASNStyleDictionary(void) const
bool MoleculeHasUserStyle(const StructureObject *object, int moleculeID) const
bool GetObjectStyle(const StructureObject *object, const Object3D &object3D, const StyleSettings::GeneralStyle &generalStyle, ObjectStyle *objectStyle) const
bool GetAtomStyle(const Residue *residue, const AtomPntr &atom, const AtomCoord *coord, AtomStyle *atomStyle, const StyleSettings::BackboneStyle **saveBackboneStyle=NULL, const StyleSettings::GeneralStyle **saveGeneralStyle=NULL) const
bool GetHelixStyle(const StructureObject *object, const Helix3D &helix, HelixStyle *helixStyle) const
bool RemoveUserAnnotation(UserAnnotation *annotation)
bool GetBondStyle(const Bond *bond, const AtomPntr &atom1, const AtomCoord *coord1, const AtomPntr &atom2, const AtomCoord *coord2, double bondLength, BondStyle *bondStyle) const
bool AddUserStyle(int *id, StyleSettings **newStyle)
bool SaveToASNUserAnnotations(ncbi::objects::CCn3d_user_annotations *annotations) const
bool SetGlobalStyle(const ncbi::objects::CCn3d_style_settings &styleASN)
StyleSettings globalStyle
StyleSettings * GetUserStyle(int id)
bool EditUserAnnotations(wxWindow *parent)
bool ResidueHasUserStyle(const StructureObject *object, int moleculeID, int residueID) const
const Vector & GetObjectColor(const Molecule *molecule) const
bool EditGlobalStyle(wxWindow *parent)
bool LoadFromASNUserAnnotations(const ncbi::objects::CCn3d_user_annotations &annotations)
UserAnnotationList & GetUserAnnotations(void)
const Vector & GetBackgroundColor(void) const
StyleManager(const StructureSet *set)
bool MoveUserAnnotation(UserAnnotation *annotation, bool moveUp)
StyleMap userStyles
UserAnnotationList userAnnotations
const StyleSettings * GetUserStyle(int id) const
std::list< ncbi::CRef< UserAnnotation > > UserAnnotationList
bool CheckGlobalStyleSettings(void)
void SetGlobalColorScheme(StyleSettings::ePredefinedColorScheme scheme)
LabelStyle nucleotideLabels
GeneralStyle helixObjects
Vector backgroundColor
GeneralStyle connections
bool SaveSettingsToASN(ncbi::objects::CCn3d_style_settings *styleASN) const
GeneralStyle heterogens
GeneralStyle proteinSidechains
BackboneStyle nucleotideBackbone
bool LoadSettingsFromASN(const ncbi::objects::CCn3d_style_settings &styleASN)
GeneralStyle solvents
GeneralStyle nucleotideSidechains
double spaceFillProportion
void SetDefaultLabeling(void)
void SetRenderingStyle(ePredefinedRenderingStyle style)
GeneralStyle strandObjects
LabelStyle proteinLabels
double strandThickness
BackboneStyle proteinBackbone
void SetColorScheme(ePredefinedColorScheme scheme)
StyleSettings & operator=(const StyleSettings &v)
StyleSettings(const StyleSettings &orig)
Vector virtualDisulfideColor
Definition: set.hpp:45
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
The NCBI C++/STL use hints.
StyleManager::eDisplayStyle style
Definition: inftrees.h:24
double GetHydrophobicity(char code)
const double UNKNOWN_HYDROPHOBICITY
int GetCharge(char code)
Modified on Sat Apr 13 11:44:54 2024 by modify_doxy.py rev. 669887