• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

libs/libksane/libksane

  • sources
  • kde-4.14
  • kdegraphics
  • libs
  • libksane
  • libksane
ksane_viewer.h
Go to the documentation of this file.
1 /* ============================================================
2 *
3 * This file is part of the KDE project
4 *
5 * Date : 2008-11-15
6 * Description : Preview image viewer that can handle a selection.
7 *
8 * Copyright (C) 2008 by Kare Sars <kare dot sars at iki dot fi>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) version 3, or any
14 * later version accepted by the membership of KDE e.V. (or its
15 * successor approved by the membership of KDE e.V.), which shall
16 * act as a proxy defined in Section 6 of version 3 of the license.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this program. If not, see <http://www.gnu.org/licenses/>.
25 *
26 * ============================================================ */
27 
28 #ifndef KSANE_VIEWER_H
29 #define KSANE_VIEWER_H
30 
31 #include <QGraphicsView>
32 #include <QWheelEvent>
33 
34 namespace KSaneIface
35 {
36 
37 class KSaneViewer : public QGraphicsView
38 {
39  Q_OBJECT
40  public:
41  explicit KSaneViewer(QImage *img, QWidget *parent = 0);
42  ~KSaneViewer();
43 
44  void setQImage(QImage *img);
45  void updateImage();
48  void findSelections(float area = 10000.0);
49 
50  virtual QSize sizeHint() const;
51 
52  public Q_SLOTS:
53 
54  void setTLX(float ratio);
55  void setTLY(float ratio);
56  void setBRX(float ratio);
57  void setBRY(float ratio);
58 
65  void setSelection(float tl_x, float tl_y, float br_x, float br_y);
66  void clearActiveSelection();
67  void clearSavedSelections();
68  void clearSelections();
69 
76  void setHighlightArea(float tl_x, float tl_y, float br_x, float br_y);
77 
81  void setHighlightShown(int percentage, QColor hideColor = Qt::white);
82 
84  void clearHighlight();
85 
86  void zoomIn();
87  void zoomOut();
88  void zoomSel();
89  void zoom2Fit();
90 
91  int selListSize();
92  /* This function returns the active visible selection in index 0 and after that the "saved" ones */
93  bool selectionAt(int index, float &tl_x, float &tl_y, float &br_x, float &br_y);
94 
95  Q_SIGNALS:
96  void newSelection(float tl_x, float tl_y, float br_x, float br_y);
97 
98  protected:
99  void wheelEvent(QWheelEvent *e);
100  void mousePressEvent(QMouseEvent *e);
101  void mouseReleaseEvent(QMouseEvent *e);
102  void mouseMoveEvent(QMouseEvent *e);
103  void drawBackground(QPainter *painter, const QRectF &rect);
104 
105  private:
106  void updateSelVisibility();
107  void updateHighlight();
108  bool activeSelection(float &tl_x, float &tl_y, float &br_x, float &br_y);
109  void refineSelections(int pixelMargin);
110 
111  // fromRow is the row to start the iterations from. fromRow can be grater than toRow.
112  // rowStart is the x1 coordinate of the row
113  // all parameters are corrected to be valid pixel indexes,
114  // but start must be < end
115  int refineRow(int fromRow, int toRow, int rowStart, int rowEnd);
116  int refineColumn(int fromCol, int toCol, int colStart, int colEnd);
117 
118  struct Private;
119  Private * const d;
120 
121 };
122 
123 } // NameSpace KSaneIface
124 
125 
126 #endif
127 
128 
QWidget
KSaneIface::KSaneViewer::mousePressEvent
void mousePressEvent(QMouseEvent *e)
Definition: ksane_viewer.cpp:526
KSaneIface::KSaneViewer::setQImage
void setQImage(QImage *img)
Definition: ksane_viewer.cpp:171
KSaneIface::KSaneViewer::zoom2Fit
void zoom2Fit()
Definition: ksane_viewer.cpp:231
KSaneIface::KSaneViewer::setHighlightArea
void setHighlightArea(float tl_x, float tl_y, float br_x, float br_y)
This function is used to darken everything except what is inside the given area.
Definition: ksane_viewer.cpp:294
QWheelEvent
KSaneIface::KSaneViewer::zoomOut
void zoomOut()
Definition: ksane_viewer.cpp:206
KSaneIface::KSaneViewer::setTLY
void setTLY(float ratio)
Definition: ksane_viewer.cpp:251
QMouseEvent
KSaneIface::KSaneViewer::setBRX
void setBRX(float ratio)
Definition: ksane_viewer.cpp:261
KSaneIface::KSaneViewer::setSelection
void setSelection(float tl_x, float tl_y, float br_x, float br_y)
This function is used to set a selection without the user setting it.
Definition: ksane_viewer.cpp:281
KSaneIface::KSaneViewer::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *e)
Definition: ksane_viewer.cpp:552
KSaneIface::KSaneViewer::drawBackground
void drawBackground(QPainter *painter, const QRectF &rect)
Definition: ksane_viewer.cpp:155
KSaneIface::KSaneViewer::~KSaneViewer
~KSaneViewer()
Definition: ksane_viewer.cpp:162
KSaneIface::KSaneViewer::setHighlightShown
void setHighlightShown(int percentage, QColor hideColor=Qt::white)
This function sets the percentage of the highlighted area that is visible.
Definition: ksane_viewer.cpp:338
QPainter
KSaneIface::KSaneViewer::updateImage
void updateImage()
Definition: ksane_viewer.cpp:188
KSaneIface::KSaneViewer::setTLX
void setTLX(float ratio)
Definition: ksane_viewer.cpp:241
KSaneIface::KSaneViewer::findSelections
void findSelections(float area=10000.0)
Find selections in the picture.
Definition: ksane_viewer.cpp:797
QColor
KSaneIface::KSaneViewer::clearSelections
void clearSelections()
Definition: ksane_viewer.cpp:505
KSaneIface::KSaneViewer::KSaneViewer
KSaneViewer(QImage *img, QWidget *parent=0)
Definition: ksane_viewer.cpp:76
KSaneIface::KSaneViewer::sizeHint
virtual QSize sizeHint() const
Definition: ksane_viewer.cpp:955
QWidget::rect
QRect rect() const
KSaneIface::KSaneViewer::zoomIn
void zoomIn()
Definition: ksane_viewer.cpp:196
KSaneIface::KSaneViewer
Definition: ksane_viewer.h:37
QSize
QImage
KSaneIface::KSaneViewer::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *e)
Definition: ksane_viewer.cpp:610
KSaneIface::KSaneViewer::clearSavedSelections
void clearSavedSelections()
Definition: ksane_viewer.cpp:493
KSaneIface::KSaneViewer::setBRY
void setBRY(float ratio)
Definition: ksane_viewer.cpp:271
QRectF
KSaneIface::KSaneViewer::selectionAt
bool selectionAt(int index, float &tl_x, float &tl_y, float &br_x, float &br_y)
Definition: ksane_viewer.cpp:441
KSaneIface::KSaneViewer::clearActiveSelection
void clearActiveSelection()
Definition: ksane_viewer.cpp:485
KSaneIface::KSaneViewer::newSelection
void newSelection(float tl_x, float tl_y, float br_x, float br_y)
QObject::parent
QObject * parent() const
KSaneIface::KSaneViewer::clearHighlight
void clearHighlight()
This function removes the highlight area.
Definition: ksane_viewer.cpp:404
KSaneIface::KSaneViewer::selListSize
int selListSize()
Definition: ksane_viewer.cpp:431
QGraphicsView
KSaneIface::KSaneViewer::zoomSel
void zoomSel()
Definition: ksane_viewer.cpp:216
KSaneIface::KSaneViewer::wheelEvent
void wheelEvent(QWheelEvent *e)
Definition: ksane_viewer.cpp:512
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:47 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libs/libksane/libksane

Skip menu "libs/libksane/libksane"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal