~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/imageplugins/coreplugin/ratiocrop/imageselectionwidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Description : image selection widget used by ratio crop tool.
8
8
 *
9
9
 * Copyright (C) 2007 by Jaromir Malenko <malenko at email.cz>
10
 
 * Copyright (C) 2004-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 * Copyright (C) 2008 by Roberto Castagnola <roberto dot castagnola at gmail dot com>
 
11
 * Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
12
 *
12
13
 * This program is free software; you can redistribute it
13
14
 * and/or modify it under the terms of the GNU General
22
23
 *
23
24
 * ============================================================ */
24
25
 
25
 
 
26
26
#ifndef IMAGESELECTIONWIDGET_H
27
27
#define IMAGESELECTIONWIDGET_H
28
28
 
49
49
 
50
50
public:
51
51
 
52
 
    enum RatioAspect           // Contrained Aspect Ratio list.
 
52
    enum RatioAspect           // Constrained Aspect Ratio list.
53
53
    {
54
54
        RATIOCUSTOM=0,             // Custom aspect ratio.
55
55
        RATIO01X01,                // 1:1
75
75
        CenterImage                // Center selection to the center of image.
76
76
    };
77
77
 
78
 
    // Proportion : Golden Ratio and Rule of Thirds. More information at this url: 
 
78
    // Proportion : Golden Ratio and Rule of Thirds. More information at this url:
79
79
    // http://photoinf.com/General/Robert_Berdan/Composition_and_the_Elements_of_Visual_Design.htm
80
80
 
81
81
    enum GuideLineType
88
88
 
89
89
public:
90
90
 
91
 
    ImageSelectionWidget(int width, int height, QWidget *parent=0, 
92
 
                         float aspectRatioValue=1.0, int aspectRatio=RATIO01X01, 
93
 
                         int orient=Landscape, int guideLinesType=GuideNone);
 
91
    ImageSelectionWidget(int width, int height, QWidget *parent=0,
 
92
                         int widthRatioValue=1, int heightRatioValue=1,
 
93
                         int aspectRatio=RATIO01X01, int orient=Landscape,
 
94
                         int guideLinesType=GuideNone);
94
95
    ~ImageSelectionWidget();
95
96
 
96
97
    void  setCenterSelection(int centerType=CenterImage);
99
100
    void  setSelectionWidth(int w);
100
101
    void  setSelectionHeight(int h);
101
102
    void  setSelectionOrientation(int orient);
 
103
    void  setPreciseCrop(bool precise);
102
104
    void  setAutoOrientation(bool orientation);
103
105
    void  setSelectionAspectRatioType(int aspectRatioType);
104
 
    void  setSelectionAspectRatioValue(float aspectRatioValue);
 
106
    void  setSelectionAspectRatioValue(int widthRatioValue, int heightRatioValue);
105
107
    void  setGoldenGuideTypes(bool drawGoldenSection,  bool drawGoldenSpiralSection,
106
108
                              bool drawGoldenSpiral,   bool drawGoldenTriangle,
107
109
                              bool flipHorGoldenGuide, bool flipVerGoldenGuide);
108
110
 
109
 
    int   getOriginalImageWidth(void);
110
 
    int   getOriginalImageHeight(void);
111
 
    QRect getRegionSelection(void);
112
 
 
113
 
    int   getMinWidthRange(void);
114
 
    int   getMinHeightRange(void);
115
 
 
116
 
    void  resetSelection(void);
117
 
    void  maxAspectSelection(void);
 
111
    int   getOriginalImageWidth();
 
112
    int   getOriginalImageHeight();
 
113
    QRect getRegionSelection();
 
114
 
 
115
    int   getMinWidthRange();
 
116
    int   getMinHeightRange();
 
117
    int   getMaxWidthRange();
 
118
    int   getMaxHeightRange();
 
119
    int   getWidthStep();
 
120
    int   getHeightStep();
 
121
 
 
122
    bool  preciseCropAvailable();
 
123
 
 
124
    void  resetSelection();
 
125
    void  maxAspectSelection();
118
126
 
119
127
    Digikam::ImageIface* imageIface();
120
128
 
128
136
 
129
137
    void signalSelectionMoved( QRect rect );
130
138
    void signalSelectionChanged( QRect rect );
131
 
    void signalSelectionWidthChanged( int newWidth );
132
 
    void signalSelectionHeightChanged( int newHeight );
133
139
    void signalSelectionOrientationChanged( int newOrientation );
134
140
 
135
141
protected:
140
146
    void mouseMoveEvent ( QMouseEvent * e );
141
147
    void resizeEvent(QResizeEvent * e);
142
148
 
143
 
protected slots:
144
 
 
145
 
    void slotTimerDone(void);
146
 
 
147
149
private:
148
150
 
149
151
    // Recalculate the target selection position and emit 'signalSelectionMoved'.
150
 
    void regionSelectionMoved( bool targetDone );
 
152
    void regionSelectionMoved();
151
153
 
152
 
    void regionSelectionChanged(bool targetDone);
153
 
    void realToLocalRegion(bool updateSizeOnly=false);
154
 
    void localToRealRegion(void);
155
 
    void normalizeRegion(void);
156
 
    void applyAspectRatio(bool WOrH, bool repaintWidget=true, bool updateChange=true);
157
 
    void updatePixmap(void);
158
 
    QPoint computeAspectRatio(QPoint pm, int coef=1);
159
 
    QPoint opposite(void);
 
154
    void regionSelectionChanged();
 
155
    QPoint convertPoint(const QPoint pm, bool localToReal=true);
 
156
    QPoint convertPoint(int x, int y, bool localToReal=true);
 
157
    void normalizeRegion();
 
158
    void reverseRatioValues();
 
159
    int computePreciseSize(int size, int step);
 
160
    void applyAspectRatio(bool useHeight, bool repaintWidget=true);
 
161
    void updatePixmap();
 
162
    QPoint opposite();
160
163
    float distance(QPoint a, QPoint b);
161
164
    void placeSelection(QPoint pm, bool symetric, QPoint center);
162
 
    void setCursorResizing(void);
 
165
    void setCursorResizing();
163
166
 
164
167
private:
165
168