16#include <QApplication>
27#include <klocalizedstring.h>
28#include <ksharedconfig.h>
58 KisCursor::load(
"tool_contiguous_selection_cursor.png", 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();
128 const int currentTime = image()->animationInterface()->currentTime();
133 newReferenceNodeList,
135 newReferencePaintDevice,
177 existingSelection = kisCanvas->
imageView()->selection()->pixelSelection();
185 contiguousSelectionMode,
186 contiguousSelectionBoundaryColor,
194 useSelectionAsBoundary,
219 useSelectionAsBoundary &=
221 !existingSelection->
isEmpty() &&
267 "contiguousSelectionMode",
305 m_configGroup.writeEntry(
"useSelectionAsBoundary", useSelectionAsBoundary);
318 "sectionSelectionExtent"
320 const KoGroupButton *buttonContiguousSelectionModeBoundaryFill =
322 const bool visible =
button == buttonContiguousSelectionModeBoundaryFill;
324 "buttonContiguousSelectionBoundaryColor", visible
328 button == buttonContiguousSelectionModeBoundaryFill
336 const QString xmlColor =
337 m_configGroup.readEntry(
"contiguousSelectionBoundaryColor", QString());
339 if (doc.setContent(xmlColor)) {
340 QDomElement e = doc.documentElement().firstChild().toElement();
341 QString channelDepthID =
342 doc.documentElement().attribute(
"channeldepth",
345 if (e.hasAttribute(
"space") || e.tagName().toLower() ==
"srgb") {
347 }
else if (doc.documentElement().hasAttribute(
"space") ||
348 doc.documentElement().tagName().toLower() ==
"srgb") {
366 optionButtonStripContiguousSelectionMode->
addButton(
370 optionButtonStripContiguousSelectionMode->
addButton(
373 buttonContiguousSelectionModeFloodFill->setChecked(
true);
376 sliderThreshold->setPrefix(i18nc(
377 "The 'threshold' spinbox prefix in contiguous selection tool options",
385 "The 'spread' spinbox in contiguous selection tool options; {n} is the number value, % is the percent sign",
387 QCheckBox *checkBoxSelectionAsBoundary =
new QCheckBox(i18nc(
388 "The 'use selection as boundary' checkbox in contiguous selection tool "
389 "to use selection borders as boundary when filling",
390 "Use selection as boundary"));
391 checkBoxSelectionAsBoundary->setSizePolicy(QSizePolicy::Ignored,
392 QSizePolicy::Preferred);
395 buttonContiguousSelectionModeFloodFill->setToolTip(
396 i18n(
"Select regions similar in color to the clicked region"));
397 buttonContiguousSelectionModeBoundaryFill->setToolTip(
398 i18n(
"Select all regions until a specific boundary color"));
399 buttonContiguousSelectionBoundaryColor->setToolTip(i18n(
"Boundary color"));
400 sliderThreshold->setToolTip(
401 i18n(
"Set the color similarity tolerance of the selection. "
402 "Increasing threshold increases the range of similar colors to be selected."));
403 sliderSpread->setToolTip(i18n(
404 "Set the extent of the opaque portion of the selection. "
405 "Decreasing spread decreases opacity of selection areas depending on color similarity."));
406 checkBoxSelectionAsBoundary->setToolTip(
407 i18n(
"Set if the contour of the active selection should be treated as "
408 "a boundary when making a new selection"));
412 sliderCloseGap->setPrefix(i18nc(
"The 'close gap' spinbox prefix in contiguous selection tool options",
"Close Gap: "));
414 sliderCloseGap->setSuffix(i18n(
" px"));
419 i18nc(
"The 'selection extent' section label in contiguous "
420 "selection tool options",
421 "Selection extent"));
423 optionButtonStripContiguousSelectionMode
426 "buttonContiguousSelectionBoundaryColor",
427 buttonContiguousSelectionBoundaryColor
430 "buttonContiguousSelectionBoundaryColor",
433 sectionSelectionExtent->
appendWidget(
"sliderThreshold", sliderThreshold);
434 sectionSelectionExtent->
appendWidget(
"sliderSpread", sliderSpread);
435 sectionSelectionExtent->
appendWidget(
"sliderCloseGap", sliderCloseGap);
436 sectionSelectionExtent->
appendWidget(
"checkBoxSelectionAsBoundary",
437 checkBoxSelectionAsBoundary);
440 "sectionSelectionExtent",
441 sectionSelectionExtent);
444 const QString contiguousSelectionModeStr =
445 m_configGroup.readEntry<QString>(
"contiguousSelectionMode",
"");
447 contiguousSelectionModeStr ==
"boundaryFill"
463 buttonContiguousSelectionModeBoundaryFill->setChecked(
true);
465 "buttonContiguousSelectionBoundaryColor",
469 buttonContiguousSelectionBoundaryColor->
setColor(
478 connect(optionButtonStripContiguousSelectionMode,
482 connect(buttonContiguousSelectionBoundaryColor,
483 SIGNAL(changed(
const KoColor&)),
486 SIGNAL(valueChanged(
int)),
490 SIGNAL(valueChanged(
int)),
494 SIGNAL(valueChanged(
int)),
497 connect(checkBoxSelectionAsBoundary,
498 SIGNAL(toggled(
bool)),
502 return selectionWidget;
508 useCursor(
KisCursor::load(
"tool_contiguous_selection_cursor_add.png", 6, 6));
510 useCursor(
KisCursor::load(
"tool_contiguous_selection_cursor_sub.png", 6, 6));
512 useCursor(
KisCursor::load(
"tool_contiguous_selection_cursor_inter.png", 6, 6));
514 useCursor(
KisCursor::load(
"tool_contiguous_selection_cursor_symdiff.png", 6, 6));
516 KisToolSelect::resetCursorStyle();
QVector< KisImageSignalType > KisImageSignalVector
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const quint8 OPACITY_TRANSPARENT_U8
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QPointer< KisView > imageView() const
static QCursor load(const QString &cursorName, 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()