16#include <QApplication>
27#include <klocalizedstring.h>
28#include <ksharedconfig.h>
58 KisCursor::loadWithSize(
"tool_contiguous_selection_cursor.svg", 32, 32, 6, 6),
59 i18n(
"Contiguous Area Selection"))
61 , m_opacitySpread(100)
62 , m_useSelectionAsBoundary(false)
65 setObjectName(
"tool_select_contiguous");
95 !(dev = currentNode()->projection()) ||
96 !selectionEditable()) {
112 QPoint pos = convertToImagePixelCoordFloored(event);
113 QRect rc = currentImage()->bounds();
130 const int currentTime = image()->animationInterface()->currentTime();
135 newReferenceNodeList,
137 newReferencePaintDevice,
179 existingSelection = kisCanvas->
imageView()->selection()->pixelSelection();
187 contiguousSelectionMode,
188 contiguousSelectionBoundaryColor,
196 useSelectionAsBoundary,
221 useSelectionAsBoundary &=
223 !existingSelection->
isEmpty() &&
269 "contiguousSelectionMode",
307 m_configGroup.writeEntry(
"useSelectionAsBoundary", useSelectionAsBoundary);
320 "sectionSelectionExtent"
322 const KoGroupButton *buttonContiguousSelectionModeBoundaryFill =
324 const bool visible =
button == buttonContiguousSelectionModeBoundaryFill;
326 "buttonContiguousSelectionBoundaryColor", visible
330 button == buttonContiguousSelectionModeBoundaryFill
338 const QString xmlColor =
339 m_configGroup.readEntry(
"contiguousSelectionBoundaryColor", QString());
341 if (doc.setContent(xmlColor)) {
342 QDomElement e = doc.documentElement().firstChild().toElement();
343 QString channelDepthID =
344 doc.documentElement().attribute(
"channeldepth",
347 if (e.hasAttribute(
"space") || e.tagName().toLower() ==
"srgb") {
349 }
else if (doc.documentElement().hasAttribute(
"space") ||
350 doc.documentElement().tagName().toLower() ==
"srgb") {
368 optionButtonStripContiguousSelectionMode->
addButton(
372 optionButtonStripContiguousSelectionMode->
addButton(
375 buttonContiguousSelectionModeFloodFill->setChecked(
true);
378 sliderThreshold->setPrefix(i18nc(
379 "The 'threshold' spinbox prefix in contiguous selection tool options",
387 "The 'spread' spinbox in contiguous selection tool options; {n} is the number value, % is the percent sign",
389 QCheckBox *checkBoxSelectionAsBoundary =
new QCheckBox(i18nc(
390 "The 'use selection as boundary' checkbox in contiguous selection tool "
391 "to use selection borders as boundary when filling",
392 "Use selection as boundary"));
393 checkBoxSelectionAsBoundary->setSizePolicy(QSizePolicy::Ignored,
394 QSizePolicy::Preferred);
397 buttonContiguousSelectionModeFloodFill->setToolTip(
398 i18n(
"Select regions similar in color to the clicked region"));
399 buttonContiguousSelectionModeBoundaryFill->setToolTip(
400 i18n(
"Select all regions until a specific boundary color"));
401 buttonContiguousSelectionBoundaryColor->setToolTip(i18n(
"Boundary color"));
402 sliderThreshold->setToolTip(
403 i18n(
"Set the color similarity tolerance of the selection. "
404 "Increasing threshold increases the range of similar colors to be selected."));
405 sliderSpread->setToolTip(i18n(
406 "Set the extent of the opaque portion of the selection. "
407 "Decreasing spread decreases opacity of selection areas depending on color similarity."));
408 checkBoxSelectionAsBoundary->setToolTip(
409 i18n(
"Set if the contour of the active selection should be treated as "
410 "a boundary when making a new selection"));
414 sliderCloseGap->setPrefix(i18nc(
"The 'close gap' spinbox prefix in contiguous selection tool options",
"Close Gap: "));
416 sliderCloseGap->setSuffix(i18n(
" px"));
421 i18nc(
"The 'selection extent' section label in contiguous "
422 "selection tool options",
423 "Selection extent"));
425 optionButtonStripContiguousSelectionMode
428 "buttonContiguousSelectionBoundaryColor",
429 buttonContiguousSelectionBoundaryColor
432 "buttonContiguousSelectionBoundaryColor",
435 sectionSelectionExtent->
appendWidget(
"sliderThreshold", sliderThreshold);
436 sectionSelectionExtent->
appendWidget(
"sliderSpread", sliderSpread);
437 sectionSelectionExtent->
appendWidget(
"sliderCloseGap", sliderCloseGap);
438 sectionSelectionExtent->
appendWidget(
"checkBoxSelectionAsBoundary",
439 checkBoxSelectionAsBoundary);
442 "sectionSelectionExtent",
443 sectionSelectionExtent);
446 const QString contiguousSelectionModeStr =
447 m_configGroup.readEntry<QString>(
"contiguousSelectionMode",
"");
449 contiguousSelectionModeStr ==
"boundaryFill"
465 buttonContiguousSelectionModeBoundaryFill->setChecked(
true);
467 "buttonContiguousSelectionBoundaryColor",
471 buttonContiguousSelectionBoundaryColor->
setColor(
480 connect(optionButtonStripContiguousSelectionMode,
484 connect(buttonContiguousSelectionBoundaryColor,
485 SIGNAL(changed(
const KoColor&)),
487 connect(sliderThreshold,
488 SIGNAL(valueChanged(
int)),
491 connect(sliderSpread,
492 SIGNAL(valueChanged(
int)),
495 connect(sliderCloseGap,
496 SIGNAL(valueChanged(
int)),
499 connect(checkBoxSelectionAsBoundary,
500 SIGNAL(toggled(
bool)),
504 return selectionWidget;
518 KisToolSelect::resetCursorStyle();
QVector< KisImageSignalType > KisImageSignalVector
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const quint8 OPACITY_TRANSPARENT_U8
QPointer< KisView > imageView() const
static QCursor loadWithSize(const QString &cursorName, int width, int height, int hotspotX=-1, int hotspotY=-1)
static QCursor waitCursor()
void setSizemod(int sizemod)
void setFillThreshold(int threshold)
void setFeather(int feather)
void setCloseGap(int gap)
void setRegionFillingMode(RegionFillingMode regionFillingMode)
KisPixelSelectionSP createFloodSelection(int startX, int startY, KisPaintDeviceSP sourceDevice, KisPaintDeviceSP existingSelection)
void setUseSelectionAsBoundary(bool useSelectionAsBoundary)
void setRegionFillingBoundaryColor(const KoColor ®ionFillingBoundaryColor)
void setUseCompositing(bool useCompositing)
void setAntiAlias(bool antiAlias)
@ RegionFillingMode_BoundaryFill
@ RegionFillingMode_FloodFill
void setStopGrowingAtDarkestPixel(bool stopGrowingAtDarkestPixel)
void setOpacitySpread(int opacitySpread)
static KisPaintDeviceSP createRefPaintDevice(KisImageSP originalImage, QString name="Merge Labeled Layers Reference Paint Device")
@ GroupSelectionPolicy_SelectIfColorLabeled
Groups will be taken into account only if they have set an explicit color label. This ignores groups ...
bool pixel(qint32 x, qint32 y, QColor *c) const
void applyCommand(KUndo2Command *command, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
void setStopGrowingAtDarkestPixelButtonVisible(bool visible)
This class is a spinbox in which you can click and drag to set the value. A slider like bar is displa...
void setValue(int newValue)
void setRange(int newMinimum, int newMaximum, bool computeNewFastSliderStep=true)
Set the minimum and the maximum values of the range, computing a new "fast slider step" based on the ...
static KoColor fromXML(const QDomElement &elt, const QString &channelDepthId)
void toXML(QDomDocument &doc, QDomElement &colorElt) const
#define KIS_SAFE_ASSERT_RECOVER(cond)
QString button(const QWheelEvent &ev)
KUndo2MagicString kundo2_i18n(const char *text)
QIcon loadIcon(const QString &name)
void setText(QSpinBox *spinBox, const QStringView textTemplate)
The LambdaCommand struct is a shorthand for creation of AggregateCommand commands using C++ lambda fe...
bool isEmpty() const override
void invalidateOutlineCache()