Clean up rtgui perspective.* and controllines.*
Change size_t to std::size_t, remove void from function parameters, use constants to represent the minimum required number of control lines, and change const auto & to const auto.
This commit is contained in:
@@ -80,17 +80,17 @@ void ControlLineManager::setDrawMode(bool draw)
|
|||||||
draw_mode = draw;
|
draw_mode = draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ControlLineManager::size(void) const
|
std::size_t ControlLineManager::size() const
|
||||||
{
|
{
|
||||||
return control_lines.size();
|
return control_lines.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ControlLineManager::getHorizontalCount(void) const
|
std::size_t ControlLineManager::getHorizontalCount() const
|
||||||
{
|
{
|
||||||
return horizontalCount;
|
return horizontalCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ControlLineManager::getVerticalCount(void) const
|
std::size_t ControlLineManager::getVerticalCount() const
|
||||||
{
|
{
|
||||||
return verticalCount;
|
return verticalCount;
|
||||||
}
|
}
|
||||||
@@ -482,7 +482,7 @@ void ControlLineManager::removeAll(void)
|
|||||||
callbacks->lineChanged();
|
callbacks->lineChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlLineManager::removeLine(size_t line_id)
|
void ControlLineManager::removeLine(std::size_t line_id)
|
||||||
{
|
{
|
||||||
if (line_id >= control_lines.size()) {
|
if (line_id >= control_lines.size()) {
|
||||||
return;
|
return;
|
||||||
|
@@ -52,7 +52,7 @@ protected:
|
|||||||
bool draw_mode;
|
bool draw_mode;
|
||||||
bool drawing_line;
|
bool drawing_line;
|
||||||
bool edited;
|
bool edited;
|
||||||
size_t horizontalCount, verticalCount;
|
std::size_t horizontalCount, verticalCount;
|
||||||
Cairo::RefPtr<RTSurface> line_icon_h, line_icon_v;
|
Cairo::RefPtr<RTSurface> line_icon_h, line_icon_v;
|
||||||
Cairo::RefPtr<RTSurface> line_icon_h_prelight, line_icon_v_prelight;
|
Cairo::RefPtr<RTSurface> line_icon_h_prelight, line_icon_v_prelight;
|
||||||
int prev_obj;
|
int prev_obj;
|
||||||
@@ -68,7 +68,7 @@ protected:
|
|||||||
* line, inclusive, the line type is set to vertical. Otherwise, horizontal.
|
* line, inclusive, the line type is set to vertical. Otherwise, horizontal.
|
||||||
*/
|
*/
|
||||||
void autoSetLineType(int object_id);
|
void autoSetLineType(int object_id);
|
||||||
void removeLine(size_t line_id);
|
void removeLine(std::size_t line_id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Callbacks
|
class Callbacks
|
||||||
@@ -89,9 +89,9 @@ public:
|
|||||||
|
|
||||||
bool getEdited(void) const;
|
bool getEdited(void) const;
|
||||||
/** Returns the number of horizontal control lines. */
|
/** Returns the number of horizontal control lines. */
|
||||||
size_t getHorizontalCount(void) const;
|
std::size_t getHorizontalCount() const;
|
||||||
/** Returns the number of vertical control lines. */
|
/** Returns the number of vertical control lines. */
|
||||||
size_t getVerticalCount(void) const;
|
std::size_t getVerticalCount() const;
|
||||||
void removeAll(void);
|
void removeAll(void);
|
||||||
/** Sets whether or not the lines are visible and interact-able. */
|
/** Sets whether or not the lines are visible and interact-able. */
|
||||||
void setActive(bool active);
|
void setActive(bool active);
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
void setEditProvider(EditDataProvider* provider);
|
void setEditProvider(EditDataProvider* provider);
|
||||||
void setLines(const std::vector<rtengine::ControlLine>& lines);
|
void setLines(const std::vector<rtengine::ControlLine>& lines);
|
||||||
/** Returns the number of lines. */
|
/** Returns the number of lines. */
|
||||||
size_t size(void) const;
|
std::size_t size() const;
|
||||||
/**
|
/**
|
||||||
* Allocates a new array and populates it with copies of the control lines.
|
* Allocates a new array and populates it with copies of the control lines.
|
||||||
*/
|
*/
|
||||||
|
@@ -519,22 +519,16 @@ void PerspCorrection::applyControlLines(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<rtengine::ControlLine> control_lines;
|
std::vector<rtengine::ControlLine> control_lines;
|
||||||
int h_count = 0, v_count = 0;
|
|
||||||
double rot = camera_roll->getValue();
|
double rot = camera_roll->getValue();
|
||||||
double pitch = camera_pitch->getValue();
|
double pitch = camera_pitch->getValue();
|
||||||
double yaw = camera_yaw->getValue();
|
double yaw = camera_yaw->getValue();
|
||||||
|
|
||||||
lines->toControlLines(control_lines);
|
lines->toControlLines(control_lines);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < lines->size(); i++) {
|
lens_geom_listener->autoPerspRequested(
|
||||||
if (control_lines[i].type == rtengine::ControlLine::HORIZONTAL) {
|
lines->getVerticalCount() >= MIN_VERT_LINES,
|
||||||
h_count++;
|
lines->getHorizontalCount() >= MIN_HORIZ_LINES,
|
||||||
} else if (control_lines[i].type == rtengine::ControlLine::VERTICAL) {
|
rot, pitch, yaw, &control_lines);
|
||||||
v_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lens_geom_listener->autoPerspRequested(v_count > 1, h_count > 1, rot, pitch,
|
|
||||||
yaw, &control_lines);
|
|
||||||
|
|
||||||
disableListener();
|
disableListener();
|
||||||
camera_pitch->setValue(pitch);
|
camera_pitch->setValue(pitch);
|
||||||
@@ -748,15 +742,15 @@ void PerspCorrection::lineChanged(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerspCorrection::updateApplyDeleteButtons(void)
|
void PerspCorrection::updateApplyDeleteButtons()
|
||||||
{
|
{
|
||||||
if (batchMode) {
|
if (batchMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool edit_mode = lines_button_edit->get_active();
|
bool edit_mode = lines_button_edit->get_active();
|
||||||
bool enough_lines = lines->getHorizontalCount() >= 2 || lines->getVerticalCount() >= 2;
|
bool enough_lines = lines->getHorizontalCount() >= MIN_HORIZ_LINES || lines->getVerticalCount() >= MIN_VERT_LINES;
|
||||||
const auto &tooltip = M("GENERAL_APPLY")
|
const auto tooltip = M("GENERAL_APPLY")
|
||||||
+ ((edit_mode && !enough_lines) ? "\n\n" + M("TP_PERSPECTIVE_CONTROL_LINE_APPLY_INVALID_TOOLTIP") : "");
|
+ ((edit_mode && !enough_lines) ? "\n\n" + M("TP_PERSPECTIVE_CONTROL_LINE_APPLY_INVALID_TOOLTIP") : "");
|
||||||
|
|
||||||
lines_button_apply->set_sensitive(edit_mode && enough_lines);
|
lines_button_apply->set_sensitive(edit_mode && enough_lines);
|
||||||
|
@@ -96,10 +96,15 @@ protected:
|
|||||||
void tweakParams(rtengine::procparams::ProcParams &pparams) override;
|
void tweakParams(rtengine::procparams::ProcParams &pparams) override;
|
||||||
void setCamBasedEventsActive (bool active = true);
|
void setCamBasedEventsActive (bool active = true);
|
||||||
void setFocalLengthValue (const rtengine::procparams::ProcParams* pparams, const rtengine::FramesMetaData* metadata);
|
void setFocalLengthValue (const rtengine::procparams::ProcParams* pparams, const rtengine::FramesMetaData* metadata);
|
||||||
void updateApplyDeleteButtons(void);
|
void updateApplyDeleteButtons();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/** Minimum number of horizontal lines for horizontal/full correction. */
|
||||||
|
static constexpr std::size_t MIN_HORIZ_LINES = 2;
|
||||||
|
/** Minimum number of vertical lines for vertical/full correction. */
|
||||||
|
static constexpr std::size_t MIN_VERT_LINES = 2;
|
||||||
|
|
||||||
PerspCorrection ();
|
PerspCorrection ();
|
||||||
|
|
||||||
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override;
|
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override;
|
||||||
|
Reference in New Issue
Block a user