libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | List of all members
crn::xml::AltoWrapper Class Reference

XML Alto file wrapper to crn::Document. More...

#include <CRNAltoWrapper.h>

Classes

class  Page
 Page proxy. More...
 
class  Space
 Page space proxy. More...
 
class  TextBlock
 Text block proxy. More...
 
class  TextLine
 Text line proxy. More...
 
class  View
 Wrapper on a view. More...
 
class  ViewLock
 Internal class used to save modifications at the right time. More...
 
class  Word
 Word proxy. More...
 

Public Member Functions

 AltoWrapper (const AltoWrapper &)=delete
 
 AltoWrapper (AltoWrapper &&)=default
 
 ~AltoWrapper ()
 
AltoWrapperoperator= (const AltoWrapper &)=delete
 
AltoWrapperoperator= (AltoWrapper &&)=default
 
void Synchronize (bool reset=false)
 Creates CRNBlocks and ids where there is none. More...
 
const String AddView (const Path &imagename, const Path &altoname="")
 Adds a view to the document. More...
 
SDocument GetDocument ()
 
SCDocument GetDocument () const
 
Word GetWord (const WordPath &p)
 Gets a Word by path. More...
 
TextLine GetTextLine (const TextLinePath &p)
 Gets a TextLine by path. More...
 
TextBlock GetTextBlock (const BlockPath &p)
 Gets a TextBlock by path. More...
 
Space GetSpace (const SpacePath &p)
 Gets a Space by path. More...
 
Page GetPage (const PagePath &p)
 Gets a Page by path. More...
 
std::vector< StringGetViewIds () const
 Gets the list of the view ids of the document. More...
 
View GetView (const String &view_id)
 Gets a view by id. More...
 
size_t GetNbViews () const
 Returns the number of views. More...
 
View GetView (size_t index)
 Gets a view by index. More...
 
void ResizeWord (const WordPath &p, const crn::Rect &r)
 Changes the size of a word and all its parents if needed. More...
 
void ResizeTextLine (const TextLinePath &p, const crn::Rect &r, bool erase_oob)
 Changes the size of a line and all its parents if needed. More...
 
void ResizeTextBlock (const BlockPath &p, const crn::Rect &r, bool erase_oob)
 Changes the size of a text block and all its parents if needed. More...
 
void ResizeSpace (const SpacePath &p, const crn::Rect &r, bool erase_oob)
 Changes the size of a space and all its parents if needed. More...
 

Static Public Member Functions

static std::unique_ptr
< AltoWrapper
NewFromDir (const crn::Path &directory, const crn::Path &documentname, const crn::Path &imagedirectory="", crn::Progress *prog=nullptr, bool throw_exceptions=true)
 Creates a wrapper from a directory containing Altos. More...
 
static std::unique_ptr
< AltoWrapper
NewFromDirs (const crn::Path &image_directory, const crn::Path &xml_directory, const crn::Path &documentname, crn::Progress *prog=nullptr, bool throw_exceptions=true)
 Creates a wrapper from two directories containing images and Altos with the same base names. More...
 
static std::unique_ptr
< AltoWrapper
NewFromDocument (const crn::SDocument &document, bool create_altos=false, bool throw_exceptions=true)
 Creates a wrapper from a crn::Document that was created by Nimrod. More...
 
static std::unique_ptr
< AltoWrapper
NewFromDocument (const crn::Path &documentname, bool create_altos=false, bool throw_exceptions=true)
 Creates a wrapper from a crn::Document that was created by Nimrod. More...
 
template<typename Iter >
static std::unique_ptr
< AltoWrapper
NewFromImages (Iter begin_, Iter end_, const crn::Path &documentname, bool throw_exceptions=true)
 Creates a wrapper from a list of images. More...
 
template<typename Iter >
static std::unique_ptr
< AltoWrapper
NewFromList (Iter begin_, Iter end_, const crn::Path &documentname, crn::Progress *prog=nullptr, bool throw_exceptions=true)
 Creates a wrapper from list of images and Alto paths (such as a map or any container<pair>) More...
 
static const StringAltoPathKey ()
 
static const StringPageKey ()
 
static const StringSpaceKey ()
 
static const StringTextBlockKey ()
 
static const StringIllustrationKey ()
 
static const StringGraphicalElementKey ()
 
static const StringComposedBlockKey ()
 
static const StringTextLineKey ()
 
static const StringWordKey ()
 

Detailed Description

XML Alto file wrapper to crn::Document.

A class that associates a crn::Document to XML Alto files

Author
Yann LEYDIER

Definition at line 168 of file CRNAltoWrapper.h.

Constructor & Destructor Documentation

crn::xml::AltoWrapper::AltoWrapper ( const AltoWrapper )
delete
crn::xml::AltoWrapper::AltoWrapper ( AltoWrapper &&  )
default
crn::xml::AltoWrapper::~AltoWrapper ( )
inline

Definition at line 173 of file CRNAltoWrapper.h.

Member Function Documentation

const String AltoWrapper::AddView ( const Path imagename,
const Path altoname = "" 
)

Adds a view to the document.

Adds a view to the document

Exceptions
ExceptionInvalidArgumentnull filename
ExceptionIOthe image could not be loaded (file not found or invalid image format)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory alto element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]imagenamethe image to add
[in]altonamethe path to the associated alto or "" to create a new alto
Returns
the id of the new view

Definition at line 399 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::AltoPathKey ( )
static

the key to access the Alto path in a wrapped crn::Document

Definition at line 121 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::ComposedBlockKey ( )
static

the key to access the composed blocks in a wrapped crn::Block

Definition at line 151 of file CRNAltoWrapper.cpp.

SDocument crn::xml::AltoWrapper::GetDocument ( )
inline

Definition at line 220 of file CRNAltoWrapper.h.

SCDocument crn::xml::AltoWrapper::GetDocument ( ) const
inline

Definition at line 221 of file CRNAltoWrapper.h.

size_t crn::xml::AltoWrapper::GetNbViews ( ) const
inline

Returns the number of views.

Definition at line 739 of file CRNAltoWrapper.h.

AltoWrapper::Page AltoWrapper::GetPage ( const PagePath p)

Gets a Page by path.

Gets a Page by path

Exceptions
ExceptionDomainindex out of bounds
ExceptionIOcannot open image
ExceptionNotFoundid not found
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]pthe path to the page
Returns
a wrapper on the page

Definition at line 726 of file CRNAltoWrapper.cpp.

AltoWrapper::Space AltoWrapper::GetSpace ( const SpacePath p)

Gets a Space by path.

Gets a Space by path

Exceptions
ExceptionDomainindex out of bounds
ExceptionIOcannot open image
ExceptionNotFoundid not found
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]pthe path to the space
Returns
a wrapper on the space

Definition at line 710 of file CRNAltoWrapper.cpp.

AltoWrapper::TextBlock AltoWrapper::GetTextBlock ( const BlockPath p)

Gets a TextBlock by path.

Gets a TextBlock by path

Exceptions
ExceptionDomainindex out of bounds
ExceptionIOcannot open image
ExceptionNotFoundid not found
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]pthe path to the text block
Returns
a wrapper on the text block

Definition at line 694 of file CRNAltoWrapper.cpp.

AltoWrapper::TextLine AltoWrapper::GetTextLine ( const TextLinePath p)

Gets a TextLine by path.

Gets a TextLine by path

Exceptions
ExceptionDomainindex out of bounds
ExceptionIOcannot open image
ExceptionNotFoundid not found
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]pthe path to the line
Returns
a wrapper on the line

Definition at line 678 of file CRNAltoWrapper.cpp.

AltoWrapper::View AltoWrapper::GetView ( const String view_id)

Gets a view by id.

Gets a view by id

Exceptions
ExceptionIOcannot open image
ExceptionNotFoundid not found
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]view_idthe id of the view to get
Returns
a wrapper on the view and its alto

Definition at line 591 of file CRNAltoWrapper.cpp.

AltoWrapper::View AltoWrapper::GetView ( size_t  index)

Gets a view by index.

Gets a view by id

Exceptions
ExceptionDomainindex out of bounds
ExceptionIOcannot open image
ExceptionNotFoundid not found
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]indexthe index of the view to get
Returns
a wrapper on the view and its alto

Definition at line 607 of file CRNAltoWrapper.cpp.

std::vector<String> crn::xml::AltoWrapper::GetViewIds ( ) const
inline

Gets the list of the view ids of the document.

Definition at line 735 of file CRNAltoWrapper.h.

AltoWrapper::Word AltoWrapper::GetWord ( const WordPath p)

Gets a Word by path.

Gets a Word by path

Exceptions
ExceptionDomainindex out of bounds
ExceptionIOcannot open image
ExceptionNotFoundid not found
ExceptionRuntimeunsupported image format (not BW, Gray nor RGB)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]pthe path to the word
Returns
a wrapper on the word

Definition at line 662 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::GraphicalElementKey ( )
static

the key to access the graphical elements in a wrapped crn::Block

Definition at line 146 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::IllustrationKey ( )
static

the key to access the illustrations in a wrapped crn::Block

Definition at line 141 of file CRNAltoWrapper.cpp.

std::unique_ptr< AltoWrapper > AltoWrapper::NewFromDir ( const crn::Path directory,
const crn::Path documentname,
const crn::Path imagedirectory = "",
crn::Progress prog = nullptr,
bool  throw_exceptions = true 
)
static

Creates a wrapper from a directory containing Altos.

Creates a wrapper from a directory containing Altos

Exceptions
ExceptionIOcannot open directory
ExceptionIOthe image could not be loaded (file not found or invalid image format)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory alto element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]directorythe path to the XML Alto files
[in]documentnamethe file name of the crn::Document to create
[in]imagedirectory[Optional] the path to the images if it's different from the XML path
[in]proga progress object
[in]throw_exceptionsshall an exception be thrown on character encoding conversion error?
Returns
a new Alto Wrapper

Definition at line 194 of file CRNAltoWrapper.cpp.

std::unique_ptr< AltoWrapper > AltoWrapper::NewFromDirs ( const crn::Path image_directory,
const crn::Path xml_directory,
const crn::Path documentname,
crn::Progress prog = nullptr,
bool  throw_exceptions = true 
)
static

Creates a wrapper from two directories containing images and Altos with the same base names.

Creates a wrapper from two directories containing images and Altos with the same base names

Exceptions
ExceptionIOcannot open directory
ExceptionIOthe image could not be loaded (file not found or invalid image format)
ExceptionInvalidArgumentnull node in alto
ExceptionNotFoundan mandatory alto element or attribute was not found
ExceptionIOcannot read alto file
Parameters
[in]image_directorythe path to the images
[in]xml_directorythe path to the alto files
[in]documentnamethe file name of the crn::Document to create
[in]proga progress object
[in]throw_exceptionsshall an exception be thrown on character encoding conversion error?
Returns
a new Alto Wrapper

Definition at line 255 of file CRNAltoWrapper.cpp.

std::unique_ptr< AltoWrapper > AltoWrapper::NewFromDocument ( const crn::SDocument &  document,
bool  create_altos = false,
bool  throw_exceptions = true 
)
static

Creates a wrapper from a crn::Document that was created by Nimrod.

Creates a wrapper from a crn::Document that was created by Nimrod

Exceptions
crn::ExceptionInvalidArgumentnot a Nimrod document
Parameters
[in]documentthe indexed document
[in]create_altosshall empty altos be created if the needed?
[in]throw_exceptionsshall an exception be thrown on character encoding conversion error?
Returns
a new Alto Wrapper

Definition at line 311 of file CRNAltoWrapper.cpp.

std::unique_ptr< AltoWrapper > AltoWrapper::NewFromDocument ( const crn::Path documentname,
bool  create_altos = false,
bool  throw_exceptions = true 
)
static

Creates a wrapper from a crn::Document that was created by Nimrod.

Creates a wrapper from a crn::Document that was created by Nimrod

Exceptions
ExceptionIOcannot read file
ExceptionUninitializedempty file
ExceptionRuntimenot a document file
ExceptionNotFoundnot base directory found
ExceptionIOcannot create directory
Parameters
[in]documentnamethe name of the indexed document
[in]create_altosshall empty altos be created if the needed?
[in]throw_exceptionsshall an exception be thrown on character encoding conversion error?
Returns
a new Alto Wrapper

Definition at line 336 of file CRNAltoWrapper.cpp.

template<typename Iter >
static std::unique_ptr<AltoWrapper> crn::xml::AltoWrapper::NewFromImages ( Iter  begin_,
Iter  end_,
const crn::Path documentname,
bool  throw_exceptions = true 
)
inlinestatic

Creates a wrapper from a list of images.

Parameters
[in]begin_the first element of the list
[in]end_the end of the list
[in]documentnamethe path of the crn::Document to create
[in]throw_exceptionsshall an exception be thrown on character encoding conversion error?

Definition at line 191 of file CRNAltoWrapper.h.

template<typename Iter >
static std::unique_ptr<AltoWrapper> crn::xml::AltoWrapper::NewFromList ( Iter  begin_,
Iter  end_,
const crn::Path documentname,
crn::Progress prog = nullptr,
bool  throw_exceptions = true 
)
inlinestatic

Creates a wrapper from list of images and Alto paths (such as a map or any container<pair>)

Parameters
[in]begin_the first element of the list
[in]end_the end of the list
[in]documentnamethe path of the crn::Document to create
[in]proga progress object
[in]throw_exceptionsshall an exception be thrown on character encoding conversion error?

Definition at line 206 of file CRNAltoWrapper.h.

AltoWrapper& crn::xml::AltoWrapper::operator= ( const AltoWrapper )
delete
AltoWrapper& crn::xml::AltoWrapper::operator= ( AltoWrapper &&  )
default
const String & AltoWrapper::PageKey ( )
static

the key to access the pages in a wrapped crn::Block

Definition at line 126 of file CRNAltoWrapper.cpp.

void AltoWrapper::ResizeSpace ( const SpacePath p,
const crn::Rect r,
bool  erase_oob 
)

Changes the size of a space and all its parents if needed.

Changes the size of a space and all its parents if needed

Exceptions
ExceptionNotFoundinvalid path
crn::ExceptionDomainbounding box is too small to hold the content
Parameters
[in]pthe path to the space
[in]rthe new bounding box
[in]erase_oobshall the out of bounds contained elements be erased?

Definition at line 772 of file CRNAltoWrapper.cpp.

void AltoWrapper::ResizeTextBlock ( const BlockPath p,
const crn::Rect r,
bool  erase_oob 
)

Changes the size of a text block and all its parents if needed.

Changes the size of a text block and all its parents if needed

Exceptions
ExceptionNotFoundinvalid path
crn::ExceptionDomainbounding box is too small to hold the content
Parameters
[in]pthe path to the block
[in]rthe new bounding box
[in]erase_oobshall the out of bounds contained elements be erased?

Definition at line 760 of file CRNAltoWrapper.cpp.

void AltoWrapper::ResizeTextLine ( const TextLinePath p,
const crn::Rect r,
bool  erase_oob 
)

Changes the size of a line and all its parents if needed.

Changes the size of a text line and all its parents if needed

Exceptions
ExceptionNotFoundinvalid path
crn::ExceptionDomainbounding box is too small to hold the content
Parameters
[in]pthe path to the word
[in]rthe new bounding box
[in]erase_oobshall the out of bounds contained elements be erased?

Definition at line 748 of file CRNAltoWrapper.cpp.

void AltoWrapper::ResizeWord ( const WordPath p,
const crn::Rect r 
)

Changes the size of a word and all its parents if needed.

Changes the size of a word and all its parents if needed

Exceptions
ExceptionNotFoundinvalid path
Parameters
[in]pthe path to the word
[in]rthe new bounding box

Definition at line 736 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::SpaceKey ( )
static

the key to access the spaces in a wrapped crn::Block

Definition at line 131 of file CRNAltoWrapper.cpp.

void AltoWrapper::Synchronize ( bool  reset = false)

Creates CRNBlocks and ids where there is none.

Creates ids where there is none and builds the CRNBlock trees

Parameters
[in]resetshall the blocks be rebuild

Definition at line 427 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::TextBlockKey ( )
static

the key to access the text block in a wrapped crn::Block

Definition at line 136 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::TextLineKey ( )
static

the key to access the text lines in a wrapped crn::Block

Definition at line 156 of file CRNAltoWrapper.cpp.

const String & AltoWrapper::WordKey ( )
static

the key to access the words in a wrapped crn::Block

Definition at line 161 of file CRNAltoWrapper.cpp.


The documentation for this class was generated from the following files: