TaskImage: Remove 'outside picture' mode.

This commit is contained in:
Paddle
2023-04-17 15:10:13 +02:00
parent 7b3069868d
commit ba1ed19643
3 changed files with 10 additions and 49 deletions

View File

@@ -78,11 +78,6 @@ TaskImage::TaskImage(Image::ImagePlane* obj, QWidget* parent)
aspectRatio = obj->XSize.getValue() / obj->YSize.getValue();
QAction* action = new QAction(tr("Allow points outside the image"), this);
action->setCheckable(true);
action->setChecked(false);
ui->pushButtonScale->addAction(action);
connectSignals();
}
@@ -213,7 +208,7 @@ void TaskImage::scaleImage(double factor)
void TaskImage::startScale()
{
scale->activate(qAsConst(ui->pushButtonScale)->actions()[0]->isChecked());
scale->activate();
ui->pushButtonScale->hide();
ui->groupBoxCalibration->show();
ui->pushButtonApply->setEnabled(false);
@@ -401,7 +396,6 @@ struct NodeData {
InteractiveScale::InteractiveScale(View3DInventorViewer* view, ViewProvider* vp, Base::Placement plc)
: active(false)
, allowOutsideImage(false)
, placement(plc)
, viewer(view)
, viewProv(vp)
@@ -452,7 +446,7 @@ InteractiveScale::~InteractiveScale()
cameraSensor->detach();
}
void InteractiveScale::activate(bool allowOutside)
void InteractiveScale::activate()
{
if (viewer) {
static_cast<SoSeparator*>(viewer->getSceneGraph())->addChild(root);
@@ -462,7 +456,6 @@ void InteractiveScale::activate(bool allowOutside)
viewer->setSelectionEnabled(false);
viewer->getWidget()->setCursor(QCursor(Qt::CrossCursor));
active = true;
allowOutsideImage = allowOutside;
}
}
@@ -498,16 +491,6 @@ double InteractiveScale::getDistance(const SbVec3f& pt) const
return (points[0] - pt).length();
}
void InteractiveScale::findPointOnPlane(SoEventCallback * ecb)
{
if (allowOutsideImage) {
findPointOnFocalPlane(ecb);
}
else {
findPointOnImagePlane(ecb);
}
}
void InteractiveScale::findPointOnImagePlane(SoEventCallback * ecb)
{
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ecb->getEvent());
@@ -520,17 +503,6 @@ void InteractiveScale::findPointOnImagePlane(SoEventCallback * ecb)
}
}
void InteractiveScale::findPointOnFocalPlane(SoEventCallback * ecb)
{
const SoMouseButtonEvent * mbe = static_cast<const SoMouseButtonEvent *>(ecb->getEvent());
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(ecb->getUserData());
auto pos2d = mbe->getPosition();
auto pos3d = view->getPointOnFocalPlane(pos2d);
collectPoint(pos3d);
}
void InteractiveScale::collectPoint(const SbVec3f& pos3d)
{
if (points.empty()) {
@@ -581,18 +553,13 @@ void InteractiveScale::getMousePosition(void * ud, SoEventCallback * ecb)
if (scale->points.size() == 1) {
ecb->setHandled();
SbVec3f pos3d;
if (scale->allowOutsideImage) {
auto pos2d = l2e->getPosition();
pos3d = view->getPointOnFocalPlane(pos2d);
std::unique_ptr<SoPickedPoint> pp(view->getPointOnRay(l2e->getPosition(), scale->viewProv));
if (pp.get()) {
pos3d = pp->getPoint();
}
else {
std::unique_ptr<SoPickedPoint> pp(view->getPointOnRay(l2e->getPosition(), scale->viewProv));
if (pp.get()) {
pos3d = pp->getPoint();
}
else {
return;
}
return;
}
Base::Quantity quantity;
@@ -630,7 +597,7 @@ void InteractiveScale::soEventFilter(void* ud, SoEventCallback* ecb)
if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN)
{
ecb->setHandled();
scale->findPointOnPlane(ecb);
scale->findPointOnImagePlane(ecb);
}
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::DOWN)
{

View File

@@ -52,7 +52,7 @@ public:
~InteractiveScale();
bool eventFilter(QObject* object, QEvent* event);
void activate(bool allowOutside);
void activate();
void deactivate();
bool isActive() const {
return active;
@@ -64,9 +64,7 @@ public:
private:
static void soEventFilter(void * ud, SoEventCallback * ecb);
static void getMousePosition(void * ud, SoEventCallback * ecb);
void findPointOnPlane(SoEventCallback * ecb);
void findPointOnImagePlane(SoEventCallback * ecb);
void findPointOnFocalPlane(SoEventCallback * ecb);
void collectPoint(const SbVec3f&);
void positionWidget();
@@ -80,7 +78,6 @@ Q_SIGNALS:
private:
bool active;
bool allowOutsideImage;
Base::Placement placement;
SoSeparator* root;
SoDatumLabel* measureLabel;

View File

@@ -242,16 +242,13 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QToolButton" name="pushButtonScale">
<widget class="QPushButton" name="pushButtonScale">
<property name="toolTip">
<string>Interactively scale the image by setting a length between two points of the image.</string>
</property>
<property name="text">
<string>Calibrate</string>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">