Chemical Data Processing Library Python API - Version 1.2.0
Classes | Public Member Functions | Static Public Attributes | Properties | List of all members
CDPL.Vis.StructureGridView2D Class Reference

Implements the 2D visualization of multiple chemical structures arrange in a grid. More...

+ Inheritance diagram for CDPL.Vis.StructureGridView2D:

Classes

class  Cell
 Data structure storing the contents of a grid cell. More...
 

Public Member Functions

None __init__ ()
 Constructs and initializes a StructureGridView2D instance for the visualization of multiple chemical structures.
 
None __init__ (StructureGridView2D grid_view)
 Constructs a copy of the StructureGridView2D instance grid_view. More...
 
bool write (str file_name)
 
bool write (str file_name, str fmt)
 
bool write (str file_name, Base.DataFormat fmt)
 
bool write (Base.OStream os, str fmt)
 
bool write (Base.OStream os, Base.DataFormat fmt)
 
FontMetrics getFontMetrics ()
 Returns a reference to the used font metrics object. More...
 
None setCellSize (float width, float height)
 Allows to specify the desired width and height of the cells in grid output renderings. More...
 
float getCellWidth ()
 Returns the active grid cell width. More...
 
float getCellHeight ()
 Returns the active grid cell height. More...
 
None resize (int num_rows, int num_cols)
 Chnages the current number of grid rows and columns. More...
 
int getNumRows ()
 Returns the current number of grid rows. More...
 
int getNumColumns ()
 Returns the current number of grid columns. More...
 
None clearStructures ()
 Clears all specified structures. More...
 
None clearAllText ()
 Clears all specified text blocks. More...
 
StructureGridView2D assign (StructureGridView2D grid_view)
 Performs a copy assignment of the specified StructureGridView2D instance. More...
 
Cell __call__ (int row, int col)
 Returns the Cell instance storing the contents of the specified grid cell. More...
 
Cell __getitem__ (tuple row_and_col)
 
- Public Member Functions inherited from CDPL.Vis.View2D
None render (Renderer2D renderer)
 Renders the visual representation of the model using the specified Vis.Renderer2D instance. More...
 
None setFontMetrics (FontMetrics font_metrics)
 Specifies a font metrics object that will be used to measure the dimension of text labels. More...
 
None getModelBounds (Rectangle2D bounds)
 Calculates the bounding rectangle of the visualized model. More...
 
- Public Member Functions inherited from CDPL.Base.ControlParameterContainer
None setParameter (LookupKey key, Any value)
 
bool removeParameter (LookupKey key)
 Removes the entry for the control-parameter specified by key. More...
 
Any getParameter (LookupKey key, bool throw_=False, bool local=False)
 Returns the value of the control-parameter specified by key. More...
 
Any getParameterOrDefault (LookupKey key, Any def_value, bool local=False)
 
bool isParameterSet (LookupKey key, bool local=False)
 Tells whether or not a value has been assigned to the control-parameter specified by key. More...
 
None clearParameters ()
 Erases all container entries. More...
 
None addParameters (ControlParameterContainer cntnr)
 Adds the control-parameter value entries in the ControlParameterContainer instance cntnr. More...
 
None copyParameters (ControlParameterContainer cntnr)
 Replaces the current set of properties by a copy of the entries in cntnr. More...
 
int getNumParameters ()
 Returns the number of container entries. More...
 
int registerParameterChangedCallback (VoidLookupKeyAnyFunctor func)
 Registers a callback target function that gets invoked when the value of a control-parameter has changed. More...
 
None unregisterParameterChangedCallback (int id)
 Unregisters the callback specified by id. More...
 
int registerParameterRemovedCallback (VoidLookupKeyFunctor func)
 Registers a callback target function that gets invoked when a control-parameter entry has been removed. More...
 
None unregisterParameterRemovedCallback (int id)
 Unregisters the callback specified by id. More...
 
int registerParentChangedCallback (VoidFunctor func)
 Registers a callback target function that gets invoked when the parent container has been changed or was detached. More...
 
None unregisterParentChangedCallback (int id)
 Unregisters the callback specified by id. More...
 
ControlParameterContainer getParent ()
 Returns a reference to the parent control-parameter container. More...
 
None setParent (ControlParameterContainer cntnr)
 Sets or removes the parent control-parameter container used to resolve requests for missing entries. More...
 
list getParameterKeys ()
 
list getParameterValues ()
 
list getParameters ()
 Returns a reference to itself. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
Any __getitem__ (LookupKey key)
 
None __setitem__ (LookupKey key, Any value)
 
bool __delitem__ (LookupKey self)
 
bool __contains__ (LookupKey self, bool key)
 Returns the result of the membership test operation self in arg1. More...
 
int __len__ ()
 

Static Public Attributes

float DEF_CELL_WIDTH = 250.0
 The default grid cell width.
 
float DEF_CELL_HEIGHT = 250.0
 The default grid cell height.
 

Properties

 cellWidth = property(getCellWidth)
 
 cellHeight = property(getCellHeight)
 
 numRows = property(getNumRows)
 
 numColumns = property(getNumColumns)
 
 fontMetrics = property(getFontMetrics, setFontMetrics)
 
- Properties inherited from CDPL.Base.ControlParameterContainer
 objectID = property(getObjectID)
 
 parent = property(getParent, setParent)
 
 parameterKeys = property(getParameterKeys)
 
 parameterValues = property(getParameterValues)
 
 parameters = property(getParameters)
 
 numParameters = property(getNumParameters)
 

Detailed Description

Implements the 2D visualization of multiple chemical structures arrange in a grid.

StructureGridView2D visualizes multiple chemical structures as 2D structure diagrams arranged in a grid of arbitrary size.

StructureGridView2D relies on Vis.StructureView2D for structure visualization and thus supports all all of its parameters controlling the graphical details of the generated structure diagrams (colors, fonts, line-widths etc.). Structure visualization parameters of a StructureGridView2D instance can be set for individual grid cells as well as for the whole grid. Furthermore, any Chem.Atom, Chem.Bond and Chem.MolecularGraph relevant for 2D visualization properties will also be regarded (see Vis.StructureView2D for the list of supported properties). Properties of the visualized structures have a higher priority than the corresponding control-parameters of the grid cells hosting the structures. Likewise, control-parameters set for individual grid cells override the corresponding settings of the StructureGridView2D instance.

Each grid cell can host up to nine text blocks which are located at the corners, edges and the cell center. Text blocks are stored as Vis.TextBlockPrimitive2D instances which allow the text to span multiple lines and support the styling (colors, italic, bold, sub/super-scripting, etc.) of individual text fragments.

StructureGridView2D supports the following control-parameters in addition to the ones regarded by Vis.StructureView2D:

Control-ParameterDescription
Vis.ControlParameter.OUTPUT_SCALING_FACTORSpecifies a factor for the scaling of logical to drawing surface coordinates
Vis.ControlParameter.GRID_VIEW_BORDER_PENSpecifies the pen used for drawing a rectangle enclosing all cells of the grid
Vis.ControlParameter.GRID_VIEW_ROW_SEPARATOR_PENSpecifies the pen used for drawing lines separating the grid rows
Vis.ControlParameter.GRID_VIEW_COLUMN_SEPARATOR_PENSpecifies the pen used for drawing lines separating the grid columns
Vis.ControlParameter.GRID_VIEW_MARGINSpecifies the amount of free space added around the grid borderline
Vis.ControlParameter.GRID_VIEW_CELL_PADDINGSpecifies the amount of free space added around the content of the grid cells
Vis.ControlParameter.GRID_VIEW_TEXT_FONTSpecifies the font used for text blocks
Vis.ControlParameter.GRID_VIEW_TEXT_COLORSpecifies the default text color

Default values for most of the control-parameters are defined in namespace Vis.ControlParameterDefault.

Since
1.2

Constructor & Destructor Documentation

◆ __init__()

None CDPL.Vis.StructureGridView2D.__init__ ( StructureGridView2D  grid_view)

Constructs a copy of the StructureGridView2D instance grid_view.

Parameters
grid_viewThe StructureGridView2D instance to copy;

Member Function Documentation

◆ write() [1/5]

bool CDPL.Vis.StructureGridView2D.write ( str  file_name)
Parameters
file_name
Returns

◆ write() [2/5]

bool CDPL.Vis.StructureGridView2D.write ( str  file_name,
str  fmt 
)
Parameters
file_name
fmt
Returns

◆ write() [3/5]

bool CDPL.Vis.StructureGridView2D.write ( str  file_name,
Base.DataFormat  fmt 
)
Parameters
file_name
fmt
Returns

◆ write() [4/5]

bool CDPL.Vis.StructureGridView2D.write ( Base.OStream  os,
str  fmt 
)
Parameters
os
fmt
Returns

◆ write() [5/5]

bool CDPL.Vis.StructureGridView2D.write ( Base.OStream  os,
Base.DataFormat  fmt 
)
Parameters
os
fmt
Returns

◆ getFontMetrics()

FontMetrics CDPL.Vis.StructureGridView2D.getFontMetrics ( )

Returns a reference to the used font metrics object.

Returns
A reference to the used font metrics object, or None if none was specified.

◆ setCellSize()

None CDPL.Vis.StructureGridView2D.setCellSize ( float  width,
float  height 
)

Allows to specify the desired width and height of the cells in grid output renderings.

The default width and height is given by the constants DEF_CELL_WIDTH and DEF_CELL_HEIGHT, respectively.

Parameters
widthThe new cell width.
heightThe new cell height.
Exceptions
Base.ValueErrorif either width or height is negative.

◆ getCellWidth()

float CDPL.Vis.StructureGridView2D.getCellWidth ( )

Returns the active grid cell width.

Returns
The active grid cell width.

◆ getCellHeight()

float CDPL.Vis.StructureGridView2D.getCellHeight ( )

Returns the active grid cell height.

Returns
The active grid cell height.

◆ resize()

None CDPL.Vis.StructureGridView2D.resize ( int  num_rows,
int  num_cols 
)

Chnages the current number of grid rows and columns.

The grid gets resized dynamically if a cell outside the currently sized grid is requested by call. Calling this method is thus only necessary if a specific grid size is desired. Any already existing cells that are located outside the new grid dimensions will be deleted.

Parameters
num_rowsThe new numer of grid rows.
num_colsThe new numer of grid columns.

◆ getNumRows()

int CDPL.Vis.StructureGridView2D.getNumRows ( )

Returns the current number of grid rows.

Returns
The current number of grid rows.

◆ getNumColumns()

int CDPL.Vis.StructureGridView2D.getNumColumns ( )

Returns the current number of grid columns.

Returns
The current number of grid columns.

◆ clearStructures()

None CDPL.Vis.StructureGridView2D.clearStructures ( )

Clears all specified structures.

See also
Cell.clearStructure()

◆ clearAllText()

None CDPL.Vis.StructureGridView2D.clearAllText ( )

Clears all specified text blocks.

See also
Cell.clearAllText()

◆ assign()

StructureGridView2D CDPL.Vis.StructureGridView2D.assign ( StructureGridView2D  grid_view)

Performs a copy assignment of the specified StructureGridView2D instance.

Parameters
grid_viewThe StructureGridView2D instance to copy.
Returns
A reference to itslef.

◆ __call__()

Cell CDPL.Vis.StructureGridView2D.__call__ ( int  row,
int  col 
)

Returns the Cell instance storing the contents of the specified grid cell.

If row and col specify a cell outside of the current grid bounds the grid will not be automatically resized to accommodate the new cell. For such cells a reference to an "empty" Cell instance is returned. The same is done for not yet touched cells (within the current grid bounds).

Parameters
rowThe zero-based row index of the cell.
colThe zero-based columns index of the cell.
Returns
A reference to the Cell instance.

◆ __getitem__()

Cell CDPL.Vis.StructureGridView2D.__getitem__ ( tuple  row_and_col)
Parameters
row_and_col
Returns