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

A widget that holds an image. More...

#include <GtkCRNImage.h>

+ Inheritance diagram for GtkCRN::Image:
+ Collaboration diagram for GtkCRN::Image:

Classes

struct  Line
 
struct  OverlayConfig
 An overlay configuration. More...
 
struct  OverlayItem
 An overlay item. More...
 
struct  Point
 
struct  Polygon
 
struct  Rectangle
 
struct  Text
 

Public Types

enum  MouseMode {
  MouseMode::NONE, MouseMode::SCROLL, MouseMode::DRAW, MouseMode::MOVE,
  MouseMode::STRETCH_LEFT, MouseMode::STRETCH_BOTTOM_LEFT, MouseMode::STRETCH_BOTTOM, MouseMode::STRETCH_BOTTOM_RIGHT,
  MouseMode::STRETCH_RIGHT, MouseMode::STRETCH_TOP_RIGHT, MouseMode::STRETCH_TOP, MouseMode::STRETCH_TOP_LEFT,
  MouseMode::MOVEPOINT, MouseMode::USER
}
 State of the mouse activity. More...
 
enum  Overlay {
  Overlay::None = 0, Overlay::Rectangle, Overlay::Point, Overlay::Line,
  Overlay::Text, Overlay::User, Overlay::Polygon
}
 Overlay types and mouse selection modes. More...
 

Public Member Functions

 Image ()
 Constructor. More...
 
virtual ~Image () override
 Destructor. More...
 
void set_rulers_visible (bool is_visible)
 Are the rulers visible? More...
 
const crn::Point2DIntget_offset ()
 Returns to offset of the image (at scale 1:1) More...
 
void set_pixbuf (Glib::RefPtr< Gdk::Pixbuf > pb)
 Sets the new image to display. More...
 
double get_zoom () const
 Gets the zoom level. More...
 
void set_zoom (double z)
 Sets the zoom level. More...
 
void zoom_in ()
 Increments the zoom level by 10%. More...
 
void zoom_out ()
 Decrements the zoom level by 10%. More...
 
void zoom_100 ()
 Sets the zoom level to 100%. More...
 
void zoom_fit ()
 Sets the zoom level to fit the image's size. More...
 
void focus_on (int x, int y)
 Focus the image on a point. More...
 
void force_redraw ()
 Force the image to redraw. More...
 
void set_user_cursor (const Gdk::Cursor &cur)
 Sets the cursor in user mouse mode. More...
 
Glib::RefPtr< Gtk::ActionGroup > get_actions ()
 Creates a tool button connected to the zoom_fit method. More...
 
sigc::signal< void,
crn::String, crn::String,
MouseMode
signal_overlay_changed ()
 Returns the signal associated to changes in selections. Binds to void on_overlay_changed(crn::String overlay_id, crn::String overlay_item_id, GtkCRN::Image::MouseMode mm). More...
 
sigc::signal< void, guint,
guint32, std::vector
< std::pair< crn::String,
crn::String > >, int, int > 
signal_rmb_clicked ()
 Returns a signal that can be used to generate pop-up menus. Binds to void on_rmb_clicked(guint mouse_button, guint32 time, std::vector<std::pair<crn::String, crn::String> > overlay_items_under_mouse, int x_on_image, int y_on_image). More...
 
sigc::signal< void, int, int > signal_user_mouse ()
 Returns a signal that indicates a user mouse click. Binds to void on_mouse_clicked(int x, int y). More...
 
sigc::signal< void,
Glib::RefPtr< Gdk::Pixbuf > > 
signal_drawing ()
 Returns a signal that indicates that the image will be redrawn. Binds to void on_redraw(Glib::RefPtr<Gdk::Pixbuf> new_image). More...
 
sigc::signal< void > signal_zoom_changed ()
 Returns a signal that indicates that the zoom was changed. Binds to void on_zoom_changed(). More...
 
sigc::signal< void, int, int > signal_scrolled_event ()
 Returns a signal emitted when the image is scrolled. Binds to void on_scroll(int x, int y). More...
 
Gtk::Adjustment & get_hadjustment ()
 Gets the horizontal adjustment of the scrollbars. More...
 
Gtk::Adjustment & get_vadjustment ()
 Gets the vertical adjustment of the scrollbars. More...
 
OverlayConfigget_overlay_config (const crn::String &id)
 Gets the configuration of an overlay. More...
 
void show_overlay (const crn::String &id)
 Shows an hidden overlay. More...
 
void hide_overlay (const crn::String &id)
 Hides an overlay. More...
 
void set_overlay_visible (const crn::String &id, bool visible)
 Shows or hides an overlay. More...
 
void clear_overlays ()
 Clears all overlays. More...
 
void clear_overlay (const crn::String &id)
 Clears an overlay. More...
 
void add_overlay_item (const crn::String &overlay_id, const crn::String &item_id, const crn::Rect &r, const crn::StringUTF8 &label="")
 Adds a rectangle to an overlay. More...
 
void add_overlay_item (const crn::String &overlay_id, const crn::String &item_id, const crn::Point2DInt &point, const crn::StringUTF8 &label="")
 Adds a point to an overlay. More...
 
void add_overlay_item (const crn::String &overlay_id, const crn::String &item_id, const crn::Point2DInt &p1, const crn::Point2DInt &p2, const crn::StringUTF8 &label="")
 Adds a line to an overlay. More...
 
void add_overlay_item (const crn::String &overlay_id, const crn::String &item_id, const std::vector< crn::Point2DInt > &p, const crn::StringUTF8 &label="")
 Adds a polygon to an overlay. More...
 
void add_overlay_item (const crn::String &overlay_id, const crn::String &item_id, std::vector< crn::Point2DInt > &&p, const crn::StringUTF8 &label="")
 Adds a polygon to an overlay. More...
 
void add_overlay_item (const crn::String &overlay_id, const crn::String &item_id, const crn::StringUTF8 &label, const crn::Point2DInt &position)
 Adds a text to an overlay. More...
 
OverlayItemget_overlay_item (const crn::String &overlay_id, const crn::String &item_id)
 Gets an overlay item. More...
 
const OverlayItemget_overlay_item (const crn::String &overlay_id, const crn::String &item_id) const
 Gets an overlay item. More...
 
void remove_overlay_item (const crn::String &overlay_id, const crn::String &item_id)
 Removes an overlay item. More...
 
void set_selection_type (Overlay typ)
 Sets the mouse selection type. More...
 
Overlay get_selection_type () const
 Gets the mouse selection type. More...
 
OverlayConfigget_selection_config ()
 Gets the mouse selection configuration. More...
 
bool has_selection () const
 Is there a mouse selection? More...
 
void clear_selection ()
 Clears the mouse selection. More...
 
const crn::Rectget_selection_as_rect () const
 Gets the mouse selection as a rectangle. More...
 
const crn::Point2DIntget_selection_as_point () const
 Gets the mouse selection as a point. More...
 
std::pair< crn::Point2DInt,
crn::Point2DInt
get_selection_as_line () const
 Gets the mouse selection as a line. More...
 
void set_selection (const crn::Rect &r)
 Sets the mouse selection. More...
 
void set_selection (const crn::Point2DInt &p)
 Sets the mouse selection. More...
 
void set_selection (const crn::Point2DInt &p1, const crn::Point2DInt &p2)
 Sets the mouse selection. More...
 

Static Public Member Functions

static const crn::Stringselection_overlay ()
 Returns the name of the mouse selection overlay. More...
 

Detailed Description

A widget that holds an image.

An image widget with scrollbars, optional rulers, zoom facilities and multiple selections.

Selections are combinations of a label and/or a rectangle. They are stored in selection lists that define the colors and the behaviour of the selections.

Definition at line 43 of file GtkCRNImage.h.

Member Enumeration Documentation

State of the mouse activity.

Enumerator
NONE 
SCROLL 
DRAW 
MOVE 
STRETCH_LEFT 
STRETCH_BOTTOM_LEFT 
STRETCH_BOTTOM 
STRETCH_BOTTOM_RIGHT 
STRETCH_RIGHT 
STRETCH_TOP_RIGHT 
STRETCH_TOP 
STRETCH_TOP_LEFT 
MOVEPOINT 
USER 

Definition at line 116 of file GtkCRNImage.h.

Overlay types and mouse selection modes.

Enumerator
None 
Rectangle 
Point 
Line 
Text 
User 
Polygon 

Definition at line 144 of file GtkCRNImage.h.

Constructor & Destructor Documentation

Image::Image ( )

Constructor.

Constructor

Definition at line 39 of file GtkCRNImage.cpp.

Image::~Image ( )
overridevirtual

Destructor.

Destructor

Definition at line 150 of file GtkCRNImage.cpp.

Member Function Documentation

void Image::add_overlay_item ( const crn::String overlay_id,
const crn::String item_id,
const crn::Rect r,
const crn::StringUTF8 label = "" 
)

Adds a rectangle to an overlay.

Adds a rectangle to an overlay

Parameters
[in]overlay_idthe id of the overlay in which the rectangle will be added
[in]item_idthe id of the item to add
[in]rthe rectangle to add
[in]labelthe label of the rectangle (optional)

Definition at line 2023 of file GtkCRNImage.cpp.

void Image::add_overlay_item ( const crn::String overlay_id,
const crn::String item_id,
const crn::Point2DInt point,
const crn::StringUTF8 label = "" 
)

Adds a point to an overlay.

Adds a point to an overlay

Parameters
[in]overlay_idthe id of the overlay in which the point will be added
[in]item_idthe id of the item to add
[in]pointthe point to add
[in]labelthe label of the point (optional)

Definition at line 2036 of file GtkCRNImage.cpp.

void Image::add_overlay_item ( const crn::String overlay_id,
const crn::String item_id,
const crn::Point2DInt p1,
const crn::Point2DInt p2,
const crn::StringUTF8 label = "" 
)

Adds a line to an overlay.

Adds a line to an overlay

Parameters
[in]overlay_idthe id of the overlay in which the line will be added
[in]item_idthe id of the item to add
[in]p1the first point of the line
[in]p2the second point of the line
[in]labelthe label of the line (optional)

Definition at line 2050 of file GtkCRNImage.cpp.

void Image::add_overlay_item ( const crn::String overlay_id,
const crn::String item_id,
const std::vector< crn::Point2DInt > &  p,
const crn::StringUTF8 label = "" 
)

Adds a polygon to an overlay.

Adds a polygon to an overlay

Parameters
[in]overlay_idthe id of the overlay in which the line will be added
[in]item_idthe id of the item to add
[in]p1the first point of the line
[in]p2the second point of the line
[in]labelthe label of the line (optional)
Exceptions
ExceptionDimensionthe polygon must have more than two points

Definition at line 2077 of file GtkCRNImage.cpp.

void Image::add_overlay_item ( const crn::String overlay_id,
const crn::String item_id,
std::vector< crn::Point2DInt > &&  p,
const crn::StringUTF8 label = "" 
)

Adds a polygon to an overlay.

Adds a polygon to an overlay

Parameters
[in]overlay_idthe id of the overlay in which the line will be added
[in]item_idthe id of the item to add
[in]p1the first point of the line
[in]p2the second point of the line
[in]labelthe label of the line (optional)
Exceptions
ExceptionDimensionthe polygon must have more than two points

Definition at line 2095 of file GtkCRNImage.cpp.

void Image::add_overlay_item ( const crn::String overlay_id,
const crn::String item_id,
const crn::StringUTF8 label,
const crn::Point2DInt position 
)

Adds a text to an overlay.

Adds a text to an overlay

Parameters
[in]overlay_idthe id of the overlay in which the text will be added
[in]item_idthe id of the item to add
[in]labelthe label of the point (optional)
[in]positionthe position of the text on the image

Definition at line 2062 of file GtkCRNImage.cpp.

void Image::clear_overlay ( const crn::String id)

Clears an overlay.

Clears an overlay

Parameters
[in]idthe id of the overlay

Definition at line 2178 of file GtkCRNImage.cpp.

void Image::clear_overlays ( )

Clears all overlays.

Clears all overlays

Definition at line 2167 of file GtkCRNImage.cpp.

void Image::clear_selection ( )

Clears the mouse selection.

Clears the mouse selection

Definition at line 2202 of file GtkCRNImage.cpp.

void Image::focus_on ( int  x,
int  y 
)

Focus the image on a point.

Focuses the image on a point. If the point is outside of the image, the focus is made on the nearest point in the image.

Parameters
[in]xthe abscissa of the point to focus on
[in]ythe ordinate of the point to focus on

Definition at line 271 of file GtkCRNImage.cpp.

void GtkCRN::Image::force_redraw ( )
inline

Force the image to redraw.

Definition at line 82 of file GtkCRNImage.h.

Glib::RefPtr<Gtk::ActionGroup> GtkCRN::Image::get_actions ( )
inline

Creates a tool button connected to the zoom_fit method.

Creates a tool button connected to the zoom_fit method. Valid names are:

  • image-zoom-in
  • image-zoom-out
  • image-zoom-100
  • image-zoom-fit
  • image-clear-user-selection

Definition at line 112 of file GtkCRNImage.h.

Gtk::Adjustment& GtkCRN::Image::get_hadjustment ( )
inline

Gets the horizontal adjustment of the scrollbars.

Definition at line 134 of file GtkCRNImage.h.

const crn::Point2DInt& GtkCRN::Image::get_offset ( )
inline

Returns to offset of the image (at scale 1:1)

Definition at line 62 of file GtkCRNImage.h.

OverlayConfig& GtkCRN::Image::get_overlay_config ( const crn::String id)
inline

Gets the configuration of an overlay.

Definition at line 232 of file GtkCRNImage.h.

Image::OverlayItem & Image::get_overlay_item ( const crn::String overlay_id,
const crn::String item_id 
)

Gets an overlay item.

Gets an overlay item

Exceptions
crn::ExceptionDomainOverlay not found
crn::ExceptionNotFoundOverlay item not found
Parameters
[in]overlay_idthe id of the overlay
[in]item_idthe id of the item
Returns
a reference to the item

Definition at line 2112 of file GtkCRNImage.cpp.

const Image::OverlayItem & Image::get_overlay_item ( const crn::String overlay_id,
const crn::String item_id 
) const

Gets an overlay item.

Gets an overlay item

Exceptions
crn::ExceptionDomainOverlay not found
crn::ExceptionNotFoundOverlay item not found
Parameters
[in]overlay_idthe id of the overlay
[in]item_idthe id of the item
Returns
a const reference to the item

Definition at line 2130 of file GtkCRNImage.cpp.

std::pair< crn::Point2DInt, crn::Point2DInt > Image::get_selection_as_line ( ) const

Gets the mouse selection as a line.

Gets the mouse selection as a line

Exceptions
crn::ExceptionNotFoundNo selection found
crn::ExceptionDomainThe selection is not a line
Returns
the selection as a line

Definition at line 2262 of file GtkCRNImage.cpp.

const crn::Point2DInt & Image::get_selection_as_point ( ) const

Gets the mouse selection as a point.

Gets the mouse selection as a point

Exceptions
crn::ExceptionNotFoundNo selection found
crn::ExceptionDomainThe selection is not a point
Returns
the selection as a point

Definition at line 2240 of file GtkCRNImage.cpp.

const crn::Rect & Image::get_selection_as_rect ( ) const

Gets the mouse selection as a rectangle.

Gets the mouse selection as a rectangle

Exceptions
crn::ExceptionNotFoundNo selection found
crn::ExceptionDomainThe selection is not a rectangle
Returns
the selection as a rectangle

Definition at line 2218 of file GtkCRNImage.cpp.

OverlayConfig& GtkCRN::Image::get_selection_config ( )
inline

Gets the mouse selection configuration.

Definition at line 267 of file GtkCRNImage.h.

Overlay GtkCRN::Image::get_selection_type ( ) const
inline

Gets the mouse selection type.

Definition at line 265 of file GtkCRNImage.h.

Gtk::Adjustment& GtkCRN::Image::get_vadjustment ( )
inline

Gets the vertical adjustment of the scrollbars.

Definition at line 140 of file GtkCRNImage.h.

double GtkCRN::Image::get_zoom ( ) const
inline

Gets the zoom level.

Definition at line 66 of file GtkCRNImage.h.

bool Image::has_selection ( ) const

Is there a mouse selection?

Is there a mouse selection?

Returns
true if there is a mouse selection, false else

Definition at line 2192 of file GtkCRNImage.cpp.

void GtkCRN::Image::hide_overlay ( const crn::String id)
inline

Hides an overlay.

Definition at line 236 of file GtkCRNImage.h.

void Image::remove_overlay_item ( const crn::String overlay_id,
const crn::String item_id 
)

Removes an overlay item.

Removes an overlay item

Exceptions
crn::ExceptionDomainOverlay not found
crn::ExceptionNotFoundOverlay item not found
Parameters
[in]overlay_idthe id of the overlay
[in]item_idthe id of the item

Definition at line 2147 of file GtkCRNImage.cpp.

const crn::String & Image::selection_overlay ( )
static

Returns the name of the mouse selection overlay.

Definition at line 2207 of file GtkCRNImage.cpp.

void Image::set_overlay_visible ( const crn::String id,
bool  visible 
)

Shows or hides an overlay.

Shows or hides an overlay

Parameters
[in]idthe id of the overlay
[in]visibleshall the overlay be displayed?

Definition at line 2338 of file GtkCRNImage.cpp.

void Image::set_pixbuf ( Glib::RefPtr< Gdk::Pixbuf >  pb)

Sets the new image to display.

Sets the new image to display

Parameters
[in]pbthe new image (nullptr to unset the image)

Definition at line 181 of file GtkCRNImage.cpp.

void Image::set_rulers_visible ( bool  is_visible)

Are the rulers visible?

Are the rulers visible?

Parameters
[in]is_visibleare the ruler visible?

Definition at line 161 of file GtkCRNImage.cpp.

void Image::set_selection ( const crn::Rect r)

Sets the mouse selection.

Sets the mouse selection

Exceptions
crn::ExceptionInvalidArgumentThe selection is not a rectangle
Parameters
[in]rthe new selection

Definition at line 2283 of file GtkCRNImage.cpp.

void Image::set_selection ( const crn::Point2DInt p)

Sets the mouse selection.

Sets the mouse selection

Exceptions
crn::ExceptionInvalidArgumentThe selection is not a point
Parameters
[in]pthe new selection

Definition at line 2300 of file GtkCRNImage.cpp.

void Image::set_selection ( const crn::Point2DInt p1,
const crn::Point2DInt p2 
)

Sets the mouse selection.

Sets the mouse selection

Exceptions
crn::ExceptionInvalidArgumentThe selection is not a line
Parameters
[in]p1the first point of the new selection
[in]p2the second point of the new selection

Definition at line 2318 of file GtkCRNImage.cpp.

void Image::set_selection_type ( Overlay  typ)

Sets the mouse selection type.

Sets the mouse selection type

Exceptions
ExceptionInvalidArgumentCannot set selection type to Text or Polygon
Parameters
[in]typthe type of selection. Can be Overlay::Rectangle, Overlay::Line, Overlay::Point, Overlay::None, Overlay::User

Definition at line 1988 of file GtkCRNImage.cpp.

void Image::set_user_cursor ( const Gdk::Cursor &  cur)

Sets the cursor in user mouse mode.

Sets the cursor in user mouse mode

Parameters
[in]curthe cursor to use in user mouse mode

Definition at line 293 of file GtkCRNImage.cpp.

void Image::set_zoom ( double  z)

Sets the zoom level.

Sets the zoom level

Exceptions
Glib::OptionErrornull or negative zoom
Parameters
[in]zthe new zoom level (must be > 0)

Definition at line 206 of file GtkCRNImage.cpp.

void GtkCRN::Image::show_overlay ( const crn::String id)
inline

Shows an hidden overlay.

Definition at line 234 of file GtkCRNImage.h.

sigc::signal<void, Glib::RefPtr<Gdk::Pixbuf> > GtkCRN::Image::signal_drawing ( )
inline

Returns a signal that indicates that the image will be redrawn. Binds to void on_redraw(Glib::RefPtr<Gdk::Pixbuf> new_image).

Definition at line 124 of file GtkCRNImage.h.

sigc::signal<void, crn::String, crn::String, MouseMode> GtkCRN::Image::signal_overlay_changed ( )
inline

Returns the signal associated to changes in selections. Binds to void on_overlay_changed(crn::String overlay_id, crn::String overlay_item_id, GtkCRN::Image::MouseMode mm).

Definition at line 118 of file GtkCRNImage.h.

sigc::signal<void, guint, guint32, std::vector<std::pair<crn::String, crn::String> >, int, int > GtkCRN::Image::signal_rmb_clicked ( )
inline

Returns a signal that can be used to generate pop-up menus. Binds to void on_rmb_clicked(guint mouse_button, guint32 time, std::vector<std::pair<crn::String, crn::String> > overlay_items_under_mouse, int x_on_image, int y_on_image).

Definition at line 120 of file GtkCRNImage.h.

sigc::signal<void, int, int> GtkCRN::Image::signal_scrolled_event ( )
inline

Returns a signal emitted when the image is scrolled. Binds to void on_scroll(int x, int y).

Definition at line 128 of file GtkCRNImage.h.

sigc::signal<void, int, int> GtkCRN::Image::signal_user_mouse ( )
inline

Returns a signal that indicates a user mouse click. Binds to void on_mouse_clicked(int x, int y).

Definition at line 122 of file GtkCRNImage.h.

sigc::signal<void> GtkCRN::Image::signal_zoom_changed ( )
inline

Returns a signal that indicates that the zoom was changed. Binds to void on_zoom_changed().

Definition at line 126 of file GtkCRNImage.h.

void Image::zoom_100 ( )

Sets the zoom level to 100%.

Sets the zoom level to 100%

Definition at line 243 of file GtkCRNImage.cpp.

void Image::zoom_fit ( )

Sets the zoom level to fit the image's size.

Sets the zoom level to fit the image's size

Definition at line 254 of file GtkCRNImage.cpp.

void Image::zoom_in ( )

Increments the zoom level by 10%.

Increments the zoom level by 10%

Definition at line 219 of file GtkCRNImage.cpp.

void Image::zoom_out ( )

Decrements the zoom level by 10%.

Decrements the zoom level by 10%

Definition at line 230 of file GtkCRNImage.cpp.


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