Skip to content

Commit

Permalink
Refactor to use IntPointAndFrameOfReference type
Browse files Browse the repository at this point in the history
Updated method signatures in SingleChannelTileAccessor.cpp and .h to use IntPointAndFrameOfReference instead of separate xPos and yPos parameters. Adjusted libCZI_Compositor.h to reflect these changes and added inline methods for backward compatibility. Updated ISingleChannelTileAccessor destructor to use override keyword for modern C++ standards adherence.
  • Loading branch information
ptahmose committed Dec 11, 2024
1 parent 9135c59 commit e44c627
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 29 deletions.
5 changes: 3 additions & 2 deletions Src/libCZI/SingleChannelTileAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ CSingleChannelTileAccessor::CSingleChannelTileAccessor(const std::shared_ptr<ISu
return bmDest;
}

/*virtual*/void CSingleChannelTileAccessor::Get(libCZI::IBitmapData* pDest, int xPos, int yPos, const IDimCoordinate* planeCoordinate, const Options* pOptions)
/*virtual*/void CSingleChannelTileAccessor::Get(libCZI::IBitmapData* pDest, const IntPointAndFrameOfReference& position, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
this->InternalGet(xPos, yPos, pDest, planeCoordinate, pOptions);
const IntPoint point_raw_sub_block_cs = this->sbBlkRepository->TransformPoint(position, CZIFrameOfReference::RawSubBlockCoordinateSystem).point;
this->InternalGet(point_raw_sub_block_cs.x, point_raw_sub_block_cs.y, pDest, planeCoordinate, pOptions);
}

void CSingleChannelTileAccessor::ComposeTiles(libCZI::IBitmapData* pBm, int xPos, int yPos, const std::vector<IndexAndM>& subBlocksSet, const ISingleChannelTileAccessor::Options& options)
Expand Down
2 changes: 1 addition & 1 deletion Src/libCZI/SingleChannelTileAccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CSingleChannelTileAccessor : public CSingleChannelAccessorBase, public lib
public: // interface ISingleChannelTileAccessor
std::shared_ptr<libCZI::IBitmapData> Get(const libCZI::IntRectAndFrameOfReference& roi, const libCZI::IDimCoordinate* planeCoordinate, const libCZI::ISingleChannelTileAccessor::Options* pOptions) override;
std::shared_ptr<libCZI::IBitmapData> Get(libCZI::PixelType pixeltype, const libCZI::IntRectAndFrameOfReference& roi, const libCZI::IDimCoordinate* planeCoordinate, const Options* pOptions) override;
void Get(libCZI::IBitmapData* pDest, int xPos, int yPos, const libCZI::IDimCoordinate* planeCoordinate, const Options* pOptions) override;
void Get(libCZI::IBitmapData* pDest, const libCZI::IntPointAndFrameOfReference& position, const libCZI::IDimCoordinate* planeCoordinate, const Options* pOptions) override;
private:
void InternalGet(int xPos, int yPos, libCZI::IBitmapData* pBm, const libCZI::IDimCoordinate* planeCoordinate, const libCZI::ISingleChannelTileAccessor::Options* pOptions);
void GetAllSubBlocks(const libCZI::IntRect& roi, const libCZI::IDimCoordinate* planeCoordinate, const std::function<void(int index, int mIndex)>& appender) const;
Expand Down
87 changes: 61 additions & 26 deletions Src/libCZI/libCZI_Compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,73 +221,108 @@ namespace libCZI
};

public:
virtual std::shared_ptr<libCZI::IBitmapData> Get(const libCZI::IntRectAndFrameOfReference& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions) = 0;
/// Gets the tile composite of the specified plane and the specified ROI. The pixeltype is
/// determined by examing the first subblock found in the specified plane (which is an
/// determined by examining the first subblock found in the specified plane (which is an
/// arbitrary subblock). A newly allocated bitmap is returned.
///
/// \param roi The ROI (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param roi The ROI and the coordinate system it is defined in.
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
///
/// \returns A std::shared_ptr<libCZI::IBitmapData> containing the tile-composite.
///
/// ### remarks It needs to be defined what is supposed to happen if there is no subblock found
/// in the specified plane.
std::shared_ptr<libCZI::IBitmapData> Get(const libCZI::IntRect& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
return this->Get(libCZI::IntRectAndFrameOfReference{ libCZI::CZIFrameOfReference::RawSubBlockCoordinateSystem, roi }, planeCoordinate, pOptions);
}
virtual std::shared_ptr<libCZI::IBitmapData> Get(const libCZI::IntRectAndFrameOfReference& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions) = 0;

virtual std::shared_ptr<libCZI::IBitmapData> Get(libCZI::PixelType pixeltype, const libCZI::IntRectAndFrameOfReference& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions) = 0;
/// Gets the tile composite of the specified plane and the specified ROI.
///
/// \param pixeltype The pixeltype.
/// \param roi The ROI (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param roi The ROI and the coordinate system it is defined in.
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
///
/// \return A std::shared_ptr<libCZI::IBitmapData> containing the tile-composite.
std::shared_ptr<libCZI::IBitmapData> Get(libCZI::PixelType pixeltype, const libCZI::IntRect& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
return this->Get(pixeltype, libCZI::IntRectAndFrameOfReference{ libCZI::CZIFrameOfReference::RawSubBlockCoordinateSystem, roi }, planeCoordinate, pOptions);
}
virtual std::shared_ptr<libCZI::IBitmapData> Get(libCZI::PixelType pixeltype, const libCZI::IntRectAndFrameOfReference& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions) = 0;

/// Copy the tile composite into the specified bitmap. The bitmap passed in here determines the width and the height of the ROI
/// (and the pixeltype).
///
/// \param [in] pDest The destination bitmap.
/// \param xPos The x-position of the ROI (width and height are given by pDest) - given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems.
/// \param yPos The y-position of the ROI (width and height are given by pDest) - given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems.
/// \param position The x-position and y-position of the ROI (width and height are given by pDest), and the coordinate system they are defined in.
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
virtual void Get(libCZI::IBitmapData* pDest, int xPos, int yPos, const IDimCoordinate* planeCoordinate, const Options* pOptions) = 0;
virtual void Get(libCZI::IBitmapData* pDest, const IntPointAndFrameOfReference& position, const IDimCoordinate* planeCoordinate, const Options* pOptions) = 0;

/// Gets the tile composite of the specified plane and the specified ROI.
/// The pixeltype is determined by examining the first subblock found in the
/// specified plane (which is an arbitrary subblock). A newly allocated
/// bitmap is returned.
/// \param xPos The x-position (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param yPos The y-position (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param width The width (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param height The height (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param width The width.
/// \param height The height.
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
/// \return A std::shared_ptr<libCZI::IBitmapData> containing the tile-composite.
inline std::shared_ptr<libCZI::IBitmapData> Get(int xPos, int yPos, int width, int height, const IDimCoordinate* planeCoordinate, const Options* pOptions) { return this->Get(libCZI::IntRect{ xPos,yPos,width,height }, planeCoordinate, pOptions); }
std::shared_ptr<libCZI::IBitmapData> Get(int xPos, int yPos, int width, int height, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
return this->Get(libCZI::IntRect{ xPos,yPos,width,height }, planeCoordinate, pOptions);
}

/// Gets the tile composite of the specified plane and the specified ROI.
/// \param pixeltype The pixeltype.
/// \param xPos The x-position.
/// \param yPos The y-position.
/// \param xPos The x-position (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param yPos The y-position (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param width The width.
/// \param height The height.
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
/// \return A std::shared_ptr<libCZI::IBitmapData> containing the tile-composite.
inline std::shared_ptr<libCZI::IBitmapData> Get(libCZI::PixelType pixeltype, int xPos, int yPos, int width, int height, const IDimCoordinate* planeCoordinate, const Options* pOptions) { return this->Get(pixeltype, libCZI::IntRect{ xPos,yPos,width,height }, planeCoordinate, pOptions); }
std::shared_ptr<libCZI::IBitmapData> Get(libCZI::PixelType pixeltype, int xPos, int yPos, int width, int height, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
return this->Get(pixeltype, libCZI::IntRect{ xPos,yPos,width,height }, planeCoordinate, pOptions);
}

/// Gets the tile composite of the specified plane and the specified ROI. The pixeltype is
/// determined by examining the first subblock found in the specified plane (which is an
/// arbitrary subblock). A newly allocated bitmap is returned.
///
/// \param roi The ROI (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
///
/// \returns A std::shared_ptr<libCZI::IBitmapData> containing the tile-composite.
std::shared_ptr<libCZI::IBitmapData> Get(const libCZI::IntRect& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
return this->Get(libCZI::IntRectAndFrameOfReference{ libCZI::CZIFrameOfReference::RawSubBlockCoordinateSystem, roi }, planeCoordinate, pOptions);
}

/// Gets the tile composite of the specified plane and the specified ROI.
///
/// \param pixeltype The pixeltype.
/// \param roi The ROI (given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems).
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
///
/// \return A std::shared_ptr<libCZI::IBitmapData> containing the tile-composite.
std::shared_ptr<libCZI::IBitmapData> Get(libCZI::PixelType pixeltype, const libCZI::IntRect& roi, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
return this->Get(pixeltype, libCZI::IntRectAndFrameOfReference{ libCZI::CZIFrameOfReference::RawSubBlockCoordinateSystem, roi }, planeCoordinate, pOptions);
}

/// Copy the tile composite into the specified bitmap. The bitmap passed in here determines the width and the height of the ROI
/// (and the pixeltype).
///
/// \param [in] pDest The destination bitmap.
/// \param xPos The x-position of the ROI (width and height are given by pDest) - given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems.
/// \param yPos The y-position of the ROI (width and height are given by pDest) - given in _raw-subblock-coordinate-system_, c.f. @ref coordinatesystems.
/// \param planeCoordinate The plane coordinate.
/// \param pOptions Options for controlling the operation.
void Get(libCZI::IBitmapData* pDest, int xPos, int yPos, const IDimCoordinate* planeCoordinate, const Options* pOptions)
{
this->Get(pDest, libCZI::IntPointAndFrameOfReference{ libCZI::CZIFrameOfReference::RawSubBlockCoordinateSystem, { xPos, yPos } }, planeCoordinate, pOptions);
}

protected:
virtual ~ISingleChannelTileAccessor() = default;
~ISingleChannelTileAccessor() override = default;
};

/// Interface for single-channel-pyramidlayer tile accessors.
Expand Down

0 comments on commit e44c627

Please sign in to comment.