NCBI C++ ToolKit
|
Search Toolkit Book for IImageGrabber
#include <gui/widgets/wx/image_grabber.hpp>
Public Types | |
enum | eCaptureResult { eSuccess =0 , eOpenGLError , eFileError , eError } |
enum | eImageNumberingFormat { eSequentialFormat , eCartesionFormat } |
Public Member Functions | |
IImageGrabber () | |
virtual | ~IImageGrabber () |
virtual eCaptureResult | GrabImages (int tex_size, IImageGrabberProgress *p=NULL) |
Grab the requested images. More... | |
eCaptureResult | GrabImage (int tex_size, CVect2< int > img_idx, IImageGrabberProgress *p=NULL) |
Grab a single image for preview purposes. More... | |
eCaptureResult | PreviewImages (int tex_size, int ref_img_width, int ref_img_height, IImageGrabberProgress *p=NULL) |
Grab images to update the on-screen image to approximate final output. More... | |
void | SetPartitions (const CVect2< int > &p) |
Set number of desired image partitions. More... | |
void | SetOutputInfo (const std::string &dir, const std::string &base_name, const std::string &img_format) |
Set file output information. More... | |
void | SetNumberingFormat (eImageNumberingFormat fmt) |
Set the numbering format for sequential image names. More... | |
void | SetTileAspectRatio (float ar) |
Set aspect ratio tiles captured. More... | |
void | SetImageAspectRatio (float ar) |
Set aspect ratio for image as a whole. More... | |
void | SetOutputFormat (const string &f) |
Set output format on which image aspect is based, e.g. A4, US Letter.. More... | |
void | SetPrintingGuidesEnabled (bool b) |
Set to true to put cutting/printing guides on output images. More... | |
void | DisableGouraudShading (bool b) |
Set to true force all triangles to be printed flat (no shadingtype 4) This makes the file compatible with Adobe Illustrator. More... | |
void | SetTitleHeight (TModelUnit h) |
Set size for optional pdf title. More... | |
virtual void | SetOutputStream (CNcbiOstream *ostr) |
Protected Member Functions | |
void | x_RenderGuides (CVect2< size_t > capture_size, const std::string &image_name, std::string image_bottom, std::string image_right, std::string image_top, std::string image_left) |
Render guides around image edge (cut marks + adjacent image names) More... | |
std::string | x_GetImageName (int x, int y) |
Return image filename for a tile index based on the numbering scheme. More... | |
virtual void | x_BeginCaptures (int) |
Called before first image captured. More... | |
virtual void | x_EndCaptures () |
Called after last image captured. More... | |
virtual eCaptureResult | x_CaptureImage (CVect2< int > partitions, CVect2< int > index, CVect2< size_t > &capture_size) |
Must be subclassed to capture an individual image. More... | |
Protected Attributes | |
CVect2< int > | m_ImagePartitions |
Number of partitions (tilings) in x and 1. More... | |
std::string | m_Directory |
Target directory for saved images. More... | |
std::string | m_BaseImageName |
Image name without its appended number (e.g. img for img1, img2...) More... | |
std::string | m_ImageFormat |
Image output format (e.g. jpeg, png...) More... | |
eImageNumberingFormat | m_NumberingFormat |
Numbering format, such as sequential or tiled (x and y) More... | |
bool | m_GuidesEnabled |
If true, printing guides (like where to cut paper) will be added to image edges. More... | |
int | m_GuideWidthX |
If we are making space for printing guides (margins) on the sides, those margins may have different sizes (in x and y) if we are forcing a proportional output size. More... | |
int | m_GuideWidthY |
float | m_TileAspectRatio |
Ratio of width to height (w/h) in captured images. More... | |
string | m_OutputFormat |
Name of output format, e.g. A4, US Letter.. More... | |
float | m_ImageAspectRatio |
Aspect ratio of image from which we are generating tiles. More... | |
bool | m_DisableGouraudShaded |
If true, disable gouraud-shaded polys (shadingtype 4) More... | |
TModelUnit | m_TitleHeight = TModelUnit(0) |
Allow space at the top for a title. More... | |
CIRef< IRender > | m_SavedRender |
Static Protected Attributes | |
static const int | m_GuideWidth = 24 |
Width of printing guides, if enabled. More... | |
Definition at line 97 of file image_grabber.hpp.
Enumerator | |
---|---|
eSuccess | |
eOpenGLError | |
eFileError | |
eError |
Definition at line 100 of file image_grabber.hpp.
Enumerator | |
---|---|
eSequentialFormat | |
eCartesionFormat |
Definition at line 102 of file image_grabber.hpp.
IImageGrabber::IImageGrabber | ( | ) |
Definition at line 67 of file image_grabber.cpp.
References CGlResMgr::GetCurrentRenderer(), CGlResMgr::Instance(), and m_SavedRender.
|
virtual |
Definition at line 78 of file image_grabber.cpp.
References CGlResMgr::Instance(), m_SavedRender, and CGlResMgr::SetCurrentRenderer().
|
inline |
Set to true force all triangles to be printed flat (no shadingtype 4) This makes the file compatible with Adobe Illustrator.
Definition at line 143 of file image_grabber.hpp.
References b, and m_DisableGouraudShaded.
IImageGrabber::eCaptureResult IImageGrabber::GrabImage | ( | int | tex_size, |
CVect2< int > | img_idx, | ||
IImageGrabberProgress * | p = NULL |
||
) |
Grab a single image for preview purposes.
Definition at line 195 of file image_grabber.cpp.
References _TRACE, CGLFrameBuffer::CreateFrameBuffer(), eOpenGLError, eSuccess, CImage::GetHeight(), CImage::GetWidth(), CImage::Init(), CGLFrameBuffer::IsValid(), m_GuidesEnabled, m_ImagePartitions, CGLFrameBuffer::MakeCurrent(), NULL, CImage::SetData(), IImageGrabberProgress::SetGLContext(), IImageGrabberProgress::SetPreviewSubImage(), CVect2< T >::X(), x_BeginCaptures(), x_CaptureImage(), x_EndCaptures(), x_GetImageName(), x_RenderGuides(), and CVect2< T >::Y().
Referenced by CSaveImagesSetupDlg::OnTilePreview().
|
virtual |
Grab the requested images.
Reimplemented in CSVGGrabber, CPdfGrabber, and CPhyloPdfGrabber.
Definition at line 94 of file image_grabber.cpp.
References _TRACE, CGLFrameBuffer::CheckFBOError(), CGlUtils::CheckGlError(), CDirEntry::ConcatPath(), CGLFrameBuffer::CreateFrameBuffer(), eFileError, eOpenGLError, eSuccess, CImage::Flip(), CImage::GetHeight(), CImageIO::GetTypeFromFileName(), CImage::GetWidth(), IImageGrabberProgress::ImageSaved(), CImage::Init(), CGLFrameBuffer::IsValid(), m_BaseImageName, m_Directory, m_GuidesEnabled, m_ImageFormat, m_ImagePartitions, CGLFrameBuffer::MakeCurrent(), NULL, CImage::SetData(), IImageGrabberProgress::SetGLContext(), string, CImageIO::WriteImage(), CVect2< T >::X(), x_BeginCaptures(), x_CaptureImage(), x_EndCaptures(), x_GetImageName(), x_RenderGuides(), and CVect2< T >::Y().
Referenced by CSaveImagesSetupDlg::OnSave().
IImageGrabber::eCaptureResult IImageGrabber::PreviewImages | ( | int | tex_size, |
int | ref_img_width, | ||
int | ref_img_height, | ||
IImageGrabberProgress * | p = NULL |
||
) |
Grab images to update the on-screen image to approximate final output.
Definition at line 273 of file image_grabber.cpp.
References _TRACE, CGLFrameBuffer::CheckFBOError(), CGLFrameBuffer::CreateFrameBuffer(), eError, eOpenGLError, eSuccess, CGLFrameBuffer::GenerateMipMaps(), CGLFrameBuffer::GetTexture(), IImageGrabberProgress::GetTileLocations(), IImageGrabberProgress::ImageSaved(), CGLFrameBuffer::IsValid(), m_GuidesEnabled, m_ImagePartitions, IImageGrabberProgress::CTileOrigin::m_TileIndex, CGLFrameBuffer::MakeCurrent(), max(), NULL, CGLFrameBuffer::ReleaseTexture(), IImageGrabberProgress::SetGLContext(), IImageGrabberProgress::SetReferenceImage(), CGLFrameBuffer::SetTextureFiltering(), CGLFrameBuffer::SetTextureWrap(), ncbi::grid::netcache::search::fields::size, CVect2< T >::X(), x_BeginCaptures(), x_CaptureImage(), x_EndCaptures(), x_GetImageName(), x_RenderGuides(), and CVect2< T >::Y().
Referenced by CSaveImagesSetupDlg::OnPreview().
|
inline |
Set aspect ratio for image as a whole.
Definition at line 136 of file image_grabber.hpp.
References m_ImageAspectRatio.
Referenced by CSaveImagesSetupDlg::OnPreview(), CSaveImagesSetupDlg::OnSave(), and CSaveImagesSetupDlg::OnTilePreview().
|
inline |
Set the numbering format for sequential image names.
Definition at line 132 of file image_grabber.hpp.
References m_NumberingFormat.
Referenced by CSaveImagesSetupDlg::OnPreview(), CSaveImagesSetupDlg::OnSave(), and CSaveImagesSetupDlg::OnTilePreview().
Set output format on which image aspect is based, e.g. A4, US Letter..
Definition at line 138 of file image_grabber.hpp.
References f(), and m_OutputFormat.
void IImageGrabber::SetOutputInfo | ( | const std::string & | dir, |
const std::string & | base_name, | ||
const std::string & | img_format | ||
) |
Set file output information.
Definition at line 84 of file image_grabber.cpp.
References m_BaseImageName, m_Directory, and m_ImageFormat.
Referenced by CSaveImagesSetupDlg::OnPreview(), CSaveImagesSetupDlg::OnSave(), CSaveImagesSetupDlg::OnTilePreview(), CSaveHitMatrixPdfDlg::x_SavePdf(), and CSaveTreePdfDlg::x_SavePdf().
|
inlinevirtual |
Reimplemented in CSVGGrabber, and CPdfGrabber.
Definition at line 148 of file image_grabber.hpp.
Set number of desired image partitions.
Definition at line 126 of file image_grabber.hpp.
References m_ImagePartitions.
Referenced by CSaveImagesSetupDlg::OnPreview(), CSaveImagesSetupDlg::OnSave(), and CSaveImagesSetupDlg::OnTilePreview().
|
inline |
Set to true to put cutting/printing guides on output images.
Definition at line 140 of file image_grabber.hpp.
References b, and m_GuidesEnabled.
Referenced by CSaveImagesSetupDlg::OnPreview(), CSaveImagesSetupDlg::OnSave(), and CSaveImagesSetupDlg::OnTilePreview().
|
inline |
Set aspect ratio tiles captured.
Definition at line 134 of file image_grabber.hpp.
References m_TileAspectRatio.
Referenced by CSaveImagesSetupDlg::OnPreview(), CSaveImagesSetupDlg::OnSave(), and CSaveImagesSetupDlg::OnTilePreview().
|
inline |
Set size for optional pdf title.
Definition at line 146 of file image_grabber.hpp.
References m_TitleHeight.
Referenced by CAlnMultiWidget::SaveVectorImage().
|
inlineprotectedvirtual |
Called before first image captured.
Reimplemented in CSVGGrabber, CPdfGrabber, CPhyloPdfGrabber, and CPhyloImageGrabber.
Definition at line 163 of file image_grabber.hpp.
Referenced by GrabImage(), GrabImages(), and PreviewImages().
|
inlineprotectedvirtual |
Must be subclassed to capture an individual image.
Reimplemented in CPhyloImageGrabber.
Definition at line 167 of file image_grabber.hpp.
References eSuccess.
Referenced by GrabImage(), GrabImages(), and PreviewImages().
|
inlineprotectedvirtual |
Called after last image captured.
Reimplemented in CSVGGrabber, CPdfGrabber, CPhyloPdfGrabber, and CPhyloImageGrabber.
Definition at line 165 of file image_grabber.hpp.
Referenced by GrabImage(), GrabImages(), and PreviewImages().
|
protected |
Return image filename for a tile index based on the numbering scheme.
Definition at line 434 of file image_grabber.cpp.
References eCartesionFormat, NStr::IntToString(), m_BaseImageName, m_ImageFormat, m_ImagePartitions, m_NumberingFormat, string, CVect2< T >::X(), and CVect2< T >::Y().
Referenced by GrabImage(), GrabImages(), and PreviewImages().
|
protected |
Render guides around image edge (cut marks + adjacent image names)
Definition at line 468 of file image_grabber.cpp.
References CGlTextureFont::BeginText(), CGlTextureFont::eFontFace_TimesRoman, CGlTextureFont::EndText(), int, m_GuideWidthX, m_GuideWidthY, max(), min(), CGlTextureFont::SetFontFace(), CGlTextureFont::SetFontSize(), CGlTextureFont::TextWidth(), CGlTextureFont::WriteText(), CVect2< T >::X(), and CVect2< T >::Y().
Referenced by GrabImage(), GrabImages(), and PreviewImages().
|
protected |
Image name without its appended number (e.g. img for img1, img2...)
Definition at line 178 of file image_grabber.hpp.
Referenced by CPhyloPdfGrabber::GrabImages(), GrabImages(), CPdfGrabber::GrabImages(), CSVGGrabber::GrabImages(), SetOutputInfo(), CPhyloPdfGrabber::x_BeginCaptures(), CPdfGrabber::x_BeginCaptures(), CSVGGrabber::x_BeginCaptures(), and x_GetImageName().
|
protected |
Target directory for saved images.
Definition at line 176 of file image_grabber.hpp.
Referenced by CPhyloPdfGrabber::GrabImages(), GrabImages(), CPdfGrabber::GrabImages(), CSVGGrabber::GrabImages(), SetOutputInfo(), CPhyloPdfGrabber::x_BeginCaptures(), CPdfGrabber::x_BeginCaptures(), and CSVGGrabber::x_BeginCaptures().
|
protected |
If true, disable gouraud-shaded polys (shadingtype 4)
Definition at line 206 of file image_grabber.hpp.
Referenced by DisableGouraudShading(), CPdfGrabber::GrabImages(), and CSVGGrabber::GrabImages().
|
protected |
If true, printing guides (like where to cut paper) will be added to image edges.
Definition at line 185 of file image_grabber.hpp.
Referenced by GrabImage(), GrabImages(), PreviewImages(), SetPrintingGuidesEnabled(), and CPhyloImageGrabber::x_BeginCaptures().
Width of printing guides, if enabled.
Definition at line 187 of file image_grabber.hpp.
Referenced by CPhyloImageGrabber::x_BeginCaptures().
|
protected |
If we are making space for printing guides (margins) on the sides, those margins may have different sizes (in x and y) if we are forcing a proportional output size.
These are those sizes (proportional or not)
Definition at line 192 of file image_grabber.hpp.
Referenced by CPhyloImageGrabber::x_BeginCaptures(), CPdfGrabber::x_BeginCaptures(), CSVGGrabber::x_BeginCaptures(), CPhyloImageGrabber::x_CaptureImage(), and x_RenderGuides().
|
protected |
Definition at line 193 of file image_grabber.hpp.
Referenced by CPhyloImageGrabber::x_BeginCaptures(), CPdfGrabber::x_BeginCaptures(), CSVGGrabber::x_BeginCaptures(), CPhyloImageGrabber::x_CaptureImage(), and x_RenderGuides().
|
protected |
Aspect ratio of image from which we are generating tiles.
Definition at line 203 of file image_grabber.hpp.
Referenced by SetImageAspectRatio(), and CPhyloImageGrabber::x_BeginCaptures().
|
protected |
Image output format (e.g. jpeg, png...)
Definition at line 180 of file image_grabber.hpp.
Referenced by CPhyloPdfGrabber::GrabImages(), GrabImages(), CPdfGrabber::GrabImages(), CSVGGrabber::GrabImages(), SetOutputInfo(), CPhyloPdfGrabber::x_BeginCaptures(), CPdfGrabber::x_BeginCaptures(), CSVGGrabber::x_BeginCaptures(), and x_GetImageName().
Number of partitions (tilings) in x and 1.
If x and y are 0, then only a single image is saved.
Definition at line 174 of file image_grabber.hpp.
Referenced by GrabImage(), GrabImages(), PreviewImages(), SetPartitions(), CPhyloImageGrabber::x_BeginCaptures(), and x_GetImageName().
|
protected |
Numbering format, such as sequential or tiled (x and y)
Definition at line 182 of file image_grabber.hpp.
Referenced by SetNumberingFormat(), and x_GetImageName().
|
protected |
Name of output format, e.g. A4, US Letter..
Definition at line 200 of file image_grabber.hpp.
Referenced by SetOutputFormat(), and CPhyloPdfGrabber::x_BeginCaptures().
Definition at line 211 of file image_grabber.hpp.
Referenced by IImageGrabber(), and ~IImageGrabber().
|
protected |
Ratio of width to height (w/h) in captured images.
If the ratio is < 0, then we subdivide the image evenly.
Definition at line 198 of file image_grabber.hpp.
Referenced by SetTileAspectRatio(), and CPhyloImageGrabber::x_BeginCaptures().
|
protected |
Allow space at the top for a title.
Definition at line 209 of file image_grabber.hpp.
Referenced by CPdfGrabber::GrabImages(), CSVGGrabber::GrabImages(), and SetTitleHeight().