File indexing completed on 2025-02-02 04:13:25
0001 0002 /* 0003 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org> 0004 All rights reserved. 0005 0006 Redistribution and use in source and binary forms, with or without 0007 modification, are permitted provided that the following conditions 0008 are met: 0009 0010 1. Redistributions of source code must retain the above copyright 0011 notice, this list of conditions and the following disclaimer. 0012 2. Redistributions in binary form must reproduce the above copyright 0013 notice, this list of conditions and the following disclaimer in the 0014 documentation and/or other materials provided with the distribution. 0015 0016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 0028 0029 #define DEBUG_KP_SELECTION 0 0030 0031 0032 #include "layers/selections/image/kpRectangularImageSelection.h" 0033 0034 #include <QBitmap> 0035 #include <QRegion> 0036 0037 0038 struct kpRectangularImageSelectionPrivate 0039 { 0040 }; 0041 0042 0043 kpRectangularImageSelection::kpRectangularImageSelection ( 0044 const kpImageSelectionTransparency &transparency) 0045 : kpAbstractImageSelection (transparency), 0046 d (new kpRectangularImageSelectionPrivate ()) 0047 { 0048 } 0049 0050 kpRectangularImageSelection::kpRectangularImageSelection (const QRect &rect, 0051 const kpImage &baseImage, 0052 const kpImageSelectionTransparency &transparency) 0053 : kpAbstractImageSelection (rect, baseImage, transparency), 0054 d (new kpRectangularImageSelectionPrivate ()) 0055 { 0056 } 0057 0058 kpRectangularImageSelection::kpRectangularImageSelection (const QRect &rect, 0059 const kpImageSelectionTransparency &transparency) 0060 : kpAbstractImageSelection (rect, transparency), 0061 d (new kpRectangularImageSelectionPrivate ()) 0062 { 0063 } 0064 0065 kpRectangularImageSelection::kpRectangularImageSelection (const kpRectangularImageSelection &rhs) 0066 : kpAbstractImageSelection (), 0067 d (new kpRectangularImageSelectionPrivate ()) 0068 { 0069 *this = rhs; 0070 } 0071 0072 kpRectangularImageSelection &kpRectangularImageSelection::operator= ( 0073 const kpRectangularImageSelection &rhs) 0074 { 0075 kpAbstractImageSelection::operator= (rhs); 0076 0077 return *this; 0078 } 0079 0080 kpRectangularImageSelection *kpRectangularImageSelection::clone () const 0081 { 0082 kpRectangularImageSelection *sel = new kpRectangularImageSelection (); 0083 *sel = *this; 0084 return sel; 0085 } 0086 0087 kpRectangularImageSelection::~kpRectangularImageSelection () 0088 { 0089 delete d; 0090 } 0091 0092 0093 // public virtual [kpAbstractSelection] 0094 int kpRectangularImageSelection::serialID () const 0095 { 0096 return SerialID; 0097 } 0098 0099 0100 // public virtual [kpAbstractSelection] 0101 bool kpRectangularImageSelection::isRectangular () const 0102 { 0103 return true; 0104 } 0105 0106 0107 // public virtual [kpAbstractSelection] 0108 QPolygon kpRectangularImageSelection::calculatePoints () const 0109 { 0110 return kpAbstractImageSelection::CalculatePointsForRectangle (boundingRect ()); 0111 } 0112 0113 0114 // public virtual [base kpAbstractImageSelection] 0115 QBitmap kpRectangularImageSelection::shapeBitmap (bool nullForRectangular) const 0116 { 0117 Q_ASSERT (boundingRect ().isValid ()); 0118 0119 if (nullForRectangular) { 0120 return {}; 0121 } 0122 0123 QBitmap maskBitmap (width (), height ()); 0124 maskBitmap.fill (Qt::color1/*opaque*/); 0125 return maskBitmap; 0126 } 0127 0128 // public virtual [kpAbstractImageSelection] 0129 QRegion kpRectangularImageSelection::shapeRegion () const 0130 { 0131 return QRegion (boundingRect (), QRegion::Rectangle); 0132 } 0133 0134 0135 // public virtual [kpAbstractSelection] 0136 bool kpRectangularImageSelection::contains (const QPoint &point) const 0137 { 0138 return boundingRect ().contains (point); 0139 } 0140 0141 0142 // public virtual [kpAbstractSelection] 0143 void kpRectangularImageSelection::paintBorder (QImage *destPixmap, const QRect &docRect, 0144 bool selectionFinished) const 0145 { 0146 paintRectangularBorder (destPixmap, docRect, selectionFinished); 0147 } 0148 0149 #include "moc_kpRectangularImageSelection.cpp"