Improve mask preview and avoid reprocessing when switching spot

Changes:
- Mask preview has been improved. It only applies on detailed image now
("dcrop" pipeline) which corrects unexpected behavior on navigator
image. Mask preview now only applies on selected spot: when switching
between spots, mask preview is deactivated on newly selected spot.
- Image reprocessing is now avoided when switching between spots (except
if mask preview was previously activated). Mask background update
remains functionnal.

Bugfixe:
- AStyle runned on several modified files
This commit is contained in:
Pandagrapher
2019-08-21 13:40:28 +02:00
parent 53eeffbebf
commit 2080f65197
13 changed files with 273 additions and 147 deletions

View File

@@ -56,7 +56,7 @@ ControlSpotPanel::ControlSpotPanel():
sensiexclu_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_SENSIEXCLU"), 0, 100, 1, 12))),
structexclu_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRUCCOL"), 0, 100, 1, 0))),
struc_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_THRES"), 1.0, 12.0, 0.1, 4.0))),
locX_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH"), 2, 3000, 1, 150))),
locXL_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH_L"), 2, 3000, 1, 150))),
@@ -80,9 +80,10 @@ ControlSpotPanel::ControlSpotPanel():
nameChanged_(false),
visibilityChanged_(false),
eventType(None),
excluFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_EXCLUF"))))
excluFrame(Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_EXCLUF")))),
maskPrevActive(false)
{
bool showtooltip = options.showtooltip;
const bool showtooltip = options.showtooltip;
Gtk::HBox* const hbox1_ = Gtk::manage(new Gtk::HBox(true, 4));
buttonaddconn_ = button_add_->signal_clicked().connect(
@@ -90,7 +91,7 @@ ControlSpotPanel::ControlSpotPanel():
buttondeleteconn_ = button_delete_->signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_delete));
buttonduplicateconn_ = button_duplicate_->signal_clicked().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_duplicate));
sigc::mem_fun(*this, &ControlSpotPanel::on_button_duplicate));
hbox1_->pack_start(*button_add_);
hbox1_->pack_start(*button_delete_);
hbox1_->pack_start(*button_duplicate_);
@@ -101,7 +102,11 @@ ControlSpotPanel::ControlSpotPanel():
sigc::mem_fun(*this, &ControlSpotPanel::on_button_rename));
buttonvisibilityconn_ = button_visibility_->signal_button_release_event().connect(
sigc::mem_fun(*this, &ControlSpotPanel::on_button_visibility));
if(showtooltip) button_visibility_->set_tooltip_markup(M("TP_LOCALLAB_VIS_TOOLTIP"));
if (showtooltip) {
button_visibility_->set_tooltip_markup(M("TP_LOCALLAB_VIS_TOOLTIP"));
}
hbox2_->pack_start(*button_rename_);
hbox2_->pack_start(*button_visibility_);
pack_start(*hbox2_);
@@ -116,8 +121,8 @@ ControlSpotPanel::ControlSpotPanel():
// Disable search to prevent hijacking keyboard shortcuts #5265
treeview_->set_enable_search(false);
treeview_->signal_key_press_event().connect(
sigc::mem_fun(
*this, &ControlSpotPanel::blockTreeviewSearch), false);
sigc::mem_fun(
*this, &ControlSpotPanel::blockTreeviewSearch), false);
auto cell = Gtk::manage(new Gtk::CellRendererText());
int cols_count = treeview_->append_column("ID", *cell);
@@ -169,7 +174,11 @@ ControlSpotPanel::ControlSpotPanel():
Gtk::HBox* const ctboxspotmethod = Gtk::manage(new Gtk::HBox());
Gtk::Label* const labelspotmethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_EXCLUTYPE") + ":"));
ctboxspotmethod->pack_start(*labelspotmethod, Gtk::PACK_SHRINK, 4);
if(showtooltip) ctboxspotmethod->set_tooltip_markup(M("TP_LOCALLAB_EXCLUTYPE_TOOLTIP"));
if (showtooltip) {
ctboxspotmethod->set_tooltip_markup(M("TP_LOCALLAB_EXCLUTYPE_TOOLTIP"));
}
spotMethod_->append(M("TP_LOCALLAB_EXNORM"));
spotMethod_->append(M("TP_LOCALLAB_EXECLU"));
spotMethod_->set_active(0);
@@ -180,9 +189,17 @@ ControlSpotPanel::ControlSpotPanel():
pack_start(*ctboxspotmethod);
excluFrame->set_label_align(0.025, 0.5);
if(showtooltip) excluFrame->set_tooltip_text(M("TP_LOCALLAB_EXCLUF_TOOLTIP"));
if (showtooltip) {
excluFrame->set_tooltip_text(M("TP_LOCALLAB_EXCLUF_TOOLTIP"));
}
ToolParamBlock* const excluBox = Gtk::manage(new ToolParamBlock());
if(showtooltip) sensiexclu_->set_tooltip_text(M("TP_LOCALLAB_SENSIEXCLU_TOOLTIP"));
if (showtooltip) {
sensiexclu_->set_tooltip_text(M("TP_LOCALLAB_SENSIEXCLU_TOOLTIP"));
}
sensiexclu_->setAdjusterListener(this);
structexclu_->setAdjusterListener(this);
excluBox->pack_start(*sensiexclu_);
@@ -193,7 +210,11 @@ ControlSpotPanel::ControlSpotPanel():
Gtk::HBox* const ctboxshapemethod = Gtk::manage(new Gtk::HBox());
Gtk::Label* const labelshapemethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_STYPE") + ":"));
ctboxshapemethod->pack_start(*labelshapemethod, Gtk::PACK_SHRINK, 4);
if(showtooltip) ctboxshapemethod->set_tooltip_markup(M("TP_LOCALLAB_STYPE_TOOLTIP"));
if (showtooltip) {
ctboxshapemethod->set_tooltip_markup(M("TP_LOCALLAB_STYPE_TOOLTIP"));
}
shapeMethod_->append(M("TP_LOCALLAB_IND"));
shapeMethod_->append(M("TP_LOCALLAB_SYM"));
shapeMethod_->append(M("TP_LOCALLAB_INDSL"));
@@ -229,7 +250,11 @@ ControlSpotPanel::ControlSpotPanel():
Gtk::HBox* const ctboxqualitymethod = Gtk::manage(new Gtk::HBox());
Gtk::Label* const labelqualitymethod = Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_QUAL_METHOD") + ":"));
ctboxqualitymethod->pack_start(*labelqualitymethod, Gtk::PACK_SHRINK, 4);
if(showtooltip) ctboxqualitymethod->set_tooltip_markup(M("TP_LOCALLAB_METHOD_TOOLTIP"));
if (showtooltip) {
ctboxqualitymethod->set_tooltip_markup(M("TP_LOCALLAB_METHOD_TOOLTIP"));
}
qualityMethod_->append(M("TP_LOCALLAB_ENH"));
qualityMethod_->append(M("TP_LOCALLAB_ENHDEN"));
qualityMethod_->set_active(1);
@@ -241,11 +266,25 @@ ControlSpotPanel::ControlSpotPanel():
Gtk::Frame* const transitFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_TRANSIT")));
transitFrame->set_label_align(0.025, 0.5);
if(showtooltip) transitFrame->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
if (showtooltip) {
transitFrame->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
}
ToolParamBlock* const transitBox = Gtk::manage(new ToolParamBlock());
if(showtooltip) transit_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
if(showtooltip) transitweak_->set_tooltip_text(M("TP_LOCALLAB_TRANSITWEAK_TOOLTIP"));
if(showtooltip) transitgrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSITGRAD_TOOLTIP"));
if (showtooltip) {
transit_->set_tooltip_text(M("TP_LOCALLAB_TRANSIT_TOOLTIP"));
}
if (showtooltip) {
transitweak_->set_tooltip_text(M("TP_LOCALLAB_TRANSITWEAK_TOOLTIP"));
}
if (showtooltip) {
transitgrad_->set_tooltip_text(M("TP_LOCALLAB_TRANSITGRAD_TOOLTIP"));
}
transit_->setAdjusterListener(this);
transitweak_->setAdjusterListener(this);
transitgrad_->setAdjusterListener(this);
@@ -255,10 +294,14 @@ ControlSpotPanel::ControlSpotPanel():
transitBox->pack_start(*transitgrad_);
transitFrame->add(*transitBox);
pack_start(*transitFrame);
Gtk::Frame* const artifFrame = Gtk::manage(new Gtk::Frame(M("TP_LOCALLAB_ARTIF")));
artifFrame->set_label_align(0.025, 0.5);
if(showtooltip) artifFrame->set_tooltip_text(M("TP_LOCALLAB_ARTIF_TOOLTIP"));
if (showtooltip) {
artifFrame->set_tooltip_text(M("TP_LOCALLAB_ARTIF_TOOLTIP"));
}
ToolParamBlock* const artifBox = Gtk::manage(new ToolParamBlock());
thresh_->setAdjusterListener(this);
struc_->setAdjusterListener(this);
@@ -272,7 +315,7 @@ ControlSpotPanel::ControlSpotPanel():
pack_start(*artifFrame);
avoidConn_ = avoid_->signal_toggled().connect(
sigc::mem_fun(*this, &ControlSpotPanel::avoidChanged));
sigc::mem_fun(*this, &ControlSpotPanel::avoidChanged));
pack_start(*avoid_);
show_all();
@@ -288,7 +331,7 @@ ControlSpotPanel::ControlSpotPanel():
colorMouseovertext.set_green(100. / 255.);
colorMouseovertext.set_blue(0.);
colorMouseovertext.set_alpha(0.5);
// Nominal spot (transparent black)
colorNominal.set_red(0.);
colorNominal.set_green(0.);
@@ -412,16 +455,18 @@ void ControlSpotPanel::on_button_duplicate()
// Raise event
const int selId = getSelectedSpot();
if (selId == 0) { // No selected spot to duplicate
return;
}
nbSpotChanged_ = true;
selSpotChanged_ = true;
eventType = SpotDuplication;
const int newId = getNewId();
listener->panelChanged(EvLocallabSpotCreated, "ID#" + std::to_string(newId)
+ " (" + M("TP_LOCALLAB_EV_DUPL") + " ID#"
+ std::to_string(selId) + ")");
+ " (" + M("TP_LOCALLAB_EV_DUPL") + " ID#"
+ std::to_string(selId) + ")");
}
void ControlSpotPanel::on_button_rename()
@@ -451,6 +496,7 @@ void ControlSpotPanel::on_button_rename()
// Update actual name and raise event
if (status == RenameDialog::OkButton) {
const Glib::ustring newname = d.get_new_name();
if (newname != actualname) { // Event is only raised if name is updated
nameChanged_ = true;
row[spots_.name] = newname;
@@ -592,7 +638,13 @@ void ControlSpotPanel::controlspotChanged()
selSpotChanged_ = true;
eventType = SpotSelection;
const int selId = getSelectedSpot();
listener->panelChanged(EvLocallabSpotSelected, "ID#" + std::to_string(selId));
// Image area shall be regenerated if mask preview was active when switching spot
if (maskPrevActive) {
listener->panelChanged(EvLocallabSpotSelectedWithMask, "ID#" + std::to_string(selId));
} else {
listener->panelChanged(EvLocallabSpotSelected, "ID#" + std::to_string(selId));
}
}
void ControlSpotPanel::shapeChanged()
@@ -757,6 +809,7 @@ void ControlSpotPanel::updateParamVisibility()
// Update Control Spot GUI according to shapeMethod_ combobox state (to be compliant with shapeMethodChanged function)
const int method = shapeMethod_->get_active_row_number();
if (!batchMode) {
if (method == 1 || method == 3) { // Symmetrical cases
locXL_->hide();
@@ -840,7 +893,7 @@ void ControlSpotPanel::adjusterChanged(Adjuster* a, double newval)
listener->panelChanged(Evlocallabstructexlu, structexclu_->getTextValue());
}
}
if (a == struc_) {
row[spots_.struc] = struc_->getValue();
@@ -1361,9 +1414,10 @@ CursorShape ControlSpotPanel::getCursor(int objectID) const
// When there is no control spot (i.e. no selected row), objectID can unexpectedly be different from -1 and produced not desired behavior
const auto s = treeview_->get_selection();
if (!s->count_selected_rows()) {
return CSHandOpen;
}
return CSHandOpen;
}
const int rem_ = objectID % 7;
@@ -1437,6 +1491,7 @@ bool ControlSpotPanel::mouseOver(int modifierKey)
for (auto iter = children.begin(); iter != children.end(); iter++) {
Gtk::TreeModel::Row row = *iter;
if (row[spots_.curveid] == curveId_ && *row != *selRow) {
row[spots_.mouseover] = true;
} else {
@@ -1539,7 +1594,7 @@ bool ControlSpotPanel::button1Pressed(int modifierKey)
}
lastCoord_.set(provider->posImage.x + provider->deltaImage.x, provider->posImage.y + provider->deltaImage.y);
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
return true;
}