.. oe:namespace:: OEDepict

.. meta::
   :keywords: OEImageGrid, ImageGrid


.. _OEDepict_OEImageGrid:

.. oe:class:: OEImageGrid

   .. oe:api::

      class OEImageGrid

   This class represents :ref:`OEImageGrid <OEDepict_OEImageGrid>` which is a
   layout manager that aligns cells into rows and columns.
   The cells of the grid are equal-sized and evenly spaced.
   See :ref:`Figure: Schematic representation of an OEImageGrid object<figure_OEImageGrid>`.

   .. _figure_OEImageGrid:

   .. figure:: ../images/OEImageGrid.*
      :align:  center

      **Schematic representation of an OEImageGrid object**

   .. note::

      In the image grid, each cell has the same width and height.
      The width and height of the cells are calculated based on the
      height and width of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`,
      its margins and gap set between the cells.

   .. seealso::

      * :ref:`section_image_layout_grid` section
      * :ref:`OEImageTable <OEDepict_OEImageTable>` class

   .. ################################################################
      # Constructors
      ################################################################

   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEImageGrid(OEImageBase& parent, unsigned int rows,
                        unsigned int cols)

      .. oe:language:: python

         .. oe:api:: python

            OEImageGrid(image: OEImageBase, rows: int, cols: int) -> OEImageGrid

      Creates an :ref:`OEImageGrid <OEDepict_OEImageGrid>` object with the specified
      number of rows and columns.

      *parent*
          The :ref:`OEImageBase <OEDepict_OEImageBase>` object on which the
          :ref:`OEImageGrid <OEDepict_OEImageGrid>` object is placed.

      *rows*
         The number of rows in the :ref:`OEImageGrid <OEDepict_OEImageGrid>` object.

      *cols*
         The number of columns in the :ref:`OEImageGrid <OEDepict_OEImageGrid>` object.

      .. note::

         The width and the height of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
         object are identical to the width and height of the *parent*
         :ref:`OEImageBase <OEDepict_OEImageBase>`, respectively.

      .. seealso::

         * :oe:meth:`OEDepict::OEImageGrid::NumCols` method
         * :oe:meth:`OEDepict::OEImageGrid::NumRows` method


   .. ################################################################
      #
      ################################################################

   .. oe:method:: GetCell

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEImageBase* GetCell(unsigned int r, unsigned int c)

      .. oe:language:: python

         .. oe:api:: python

            GetCell(row: int, col: int) -> OEImageBase

      Returns the :ref:`OEImageBase <OEDepict_OEImageBase>` pointer for the cell
      positioned in the :math:`r^{th}` row and :math:`c^{th}` columns.

      *r*
         This value has to be in the range from `1` to
         :oe:meth:`OEDepict::OEImageGrid::NumRows()<OEDepict::OEImageGrid::NumRows>`.

      *c*
         This value has to be in the range from `1` to
         :oe:meth:`OEDepict::OEImageGrid::NumCols()<OEDepict::OEImageGrid::NumCols>`.


   .. ################################################################
      #
      ################################################################

   .. oe:method:: GetCellGap

      .. oe:language:: c++ java csharp

         .. oe:api::

            double GetCellGap() const

      .. oe:language:: python

         .. oe:api:: python

            GetCellGap() -> float

      Returns the space between the cells of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
      object.

      .. seealso::

         * :oe:meth:`OEDepict::OEImageGrid::SetCellGap` method


   .. ################################################################
      #
      ################################################################

   .. oe:method:: GetCellHeight

      .. oe:language:: c++ java csharp

         .. oe:api::

            double GetCellHeight() const

      .. oe:language:: python

         .. oe:api:: python

            GetCellHeight() -> float

      Returns the height of the cells of the
      :ref:`OEImageGrid <OEDepict_OEImageGrid>` object.


   .. ################################################################
      #
      ################################################################

   .. oe:method:: GetCellWidth

      .. oe:language:: c++ java csharp

         .. oe:api::

            double GetCellWidth() const

      .. oe:language:: python

         .. oe:api:: python

            GetCellWidth() -> float

      Returns the width of the cells of the
      :ref:`OEImageGrid <OEDepict_OEImageGrid>` object.


   .. ################################################################
      #
      ################################################################

   .. oe:method:: GetCells

      .. oe:language:: c++ java csharp

         .. oe:api::

            OESystem::OEIterBase<OEImageBase>* GetCells(unsigned int row = 0u,
                                                        unsigned int col = 0u)

      .. oe:language:: python

         .. oe:api:: python

            GetCells(row: int = 0, col: int = 0) -> Iterable[OEImageBase]

      Returns an iterator over the cells of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
      object.
      The cells are returned from left to right and top to bottom order.

      *row*
         This value has to be in the range from `0` to
         :oe:meth:`OEDepict::OEImageGrid::NumRows()<OEDepict::OEImageGrid::NumRows>`.

      *col*
         This value has to be in the range from `0` to
         :oe:meth:`OEDepict::OEImageGrid::NumCols()<OEDepict::OEImageGrid::NumCols>`.

      Example (:ref:`Figure Example of accessing all cells of the grid<figure_ImageGridIter_All>`)

      .. oe:source:: ImageGridIter.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ALL

      .. oe:source:: ImageGridIter.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ALL

      .. oe:source:: ImageGridIter.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ALL

      .. oe:source:: ImageGridIter.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ALL

      .. _figure_ImageGridIter_All:

      .. figure:: ../images/ImageGridIter-all.*
         :align:  center

         **Example of accessing all cells of the grid.**

         *(The numbers inside the cells represent the order in which
         the cells are returned)*

      If the *col* number is zero then :oe:meth:`OEDepict::OEImageGrid::GetCells`
      returns an iterator over the cells of the specified row.

      Example (:ref:`Figure Example of accessing a specific row of the grid<figure_ImageGridIter_Row>`)

      .. oe:source:: ImageGridIter.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ROW

      .. oe:source:: ImageGridIter.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ROW

      .. oe:source:: ImageGridIter.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ROW

      .. oe:source:: ImageGridIter.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-ROW

      .. _figure_ImageGridIter_Row:

      .. figure:: ../images/ImageGridIter-row.*
         :align:  center

         **Example of accessing a specific row of the grid.**

         *(The numbers inside the cells represent the order in which
         the cells are returned)*

      If the *row* number is zero then :oe:meth:`OEDepict::OEImageGrid::GetCells`
      returns an iterator over the cells of the specified column.

      Example (:ref:`Figure Example of accessing a specific column of the grid<figure_ImageGridIter_Col>`)

      .. oe:source:: ImageGridIter.py
         :language: python
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-COL

      .. oe:source:: ImageGridIter.cpp
         :language: c++
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-COL

      .. oe:source:: ImageGridIter.java
         :language: java
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-COL

      .. oe:source:: ImageGridIter.cs
         :language: csharp
         :noindent:
         :frag:     SNIPPET-OEIMAGEGRID-GETCELLS-COL

      .. _figure_ImageGridIter_Col:

      .. figure::  ../images/ImageGridIter-col.*
         :align:  center

         **Example of accessing a specific column of the grid.**

         *(The numbers inside the cells represent the order in which
         the cells are returned)*


   .. ################################################################
      #
      ################################################################

   .. oe:method:: GetMargin

      .. oe:language:: c++ java csharp

         .. oe:api::

            double GetMargin(unsigned int margin) const

      .. oe:language:: python

         .. oe:api:: python

            GetMargin(margin: int) -> float

      Returns the size of a specific margin of the
      :ref:`OEImageGrid <OEDepict_OEImageGrid>` object.

      *margin*
         This value has to be from the :oe:constns:`OEDepict::OEMargin`
         namespace.

      .. seealso::

         * :oe:meth:`OEDepict::OEImageGrid::SetMargin` method
         * :oe:meth:`OEDepict::OEImageGrid::SetMargins` method


   .. ################################################################
      #
      ################################################################

   .. oe:method:: NumCols

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int NumCols() const

      .. oe:language:: python

         .. oe:api:: python

            NumCols() -> int

      Returns the number of columns of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
      object.

   .. ################################################################
      #
      ################################################################

   .. oe:method:: NumRows

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int NumRows() const

      .. oe:language:: python

         .. oe:api:: python

            NumRows() -> int

      Returns the number of rows of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
      object.


   .. ################################################################
      #
      ################################################################

   .. oe:method:: SetCellGap

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool SetCellGap(double size)

      .. oe:language:: python

         .. oe:api:: python

            SetCellGap(size: float) -> bool

      Sets the space between the cells of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
      object to the given size.

      *size*
         This value has to be a positive number.

      .. warning: # IGNORE

         After accessing the cells of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
         object, the space between the cell can not be changed.

      .. seealso::

         * :oe:meth:`OEDepict::OEImageGrid::GetCellGap` method


   .. ################################################################
      #
      ################################################################

   .. oe:method:: SetMargin

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool SetMargin(unsigned int margin, double size)

      .. oe:language:: python

         .. oe:api:: python

            SetMargin(margin: int, size: float) -> bool

      Sets the size of a specific margin of the
      :ref:`OEImageGrid <OEDepict_OEImageGrid>` object.

      *margin*
         This value has to be from the :oe:constns:`OEDepict::OEMargin`
         namespace.

      *size*
         This value has to be a positive number.

      .. warning: IGNORE

         After accessing the cells of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
         object, the margins of the grid can not be changed.

      .. seealso::

         * :oe:meth:`OEDepict::OEImageGrid::GetMargin` method


   .. ################################################################
      #
      ################################################################

   .. oe:method:: SetMargins

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool SetMargins(double size)

      .. oe:language:: python

         .. oe:api:: python

            SetMargins(size: float) -> bool

      Sets the size of all margins of the
      :ref:`OEImageGrid <OEDepict_OEImageGrid>` object.

      *size*
         This value has to be a positive number.

      .. warning: IGNORE

         After accessing the cells of the :ref:`OEImageGrid <OEDepict_OEImageGrid>`
         object, the margins of the grid can not be changed.

      .. seealso::

         * :oe:meth:`OEDepict::OEImageGrid::GetMargin` method

