mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Advanced digitizing: floater settings and bearing
- visibility settings for floater - option for bearing/azimuth
This commit is contained in:
parent
367b8ba332
commit
4fab764af0
@ -739,6 +739,18 @@ Could be used by widgets that must reflect the current advanced digitizing state
|
||||
unstable API (will likely change)
|
||||
|
||||
.. versionadded:: 3.8
|
||||
%End
|
||||
|
||||
void valueBearingChanged( const QString &value );
|
||||
%Docstring
|
||||
Emitted whenever the bearing ``value`` changes.
|
||||
Could be used by widgets that must reflect the current advanced digitizing state.
|
||||
|
||||
.. note::
|
||||
|
||||
unstable API (will likely change)
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
void lockXChanged( bool locked );
|
||||
|
@ -30,6 +30,21 @@ feature. It proxies display and actions to :py:class:`QgsMapToolAdvancedDigitizi
|
||||
%End
|
||||
public:
|
||||
|
||||
enum FloaterItem
|
||||
{
|
||||
XCoordinate,
|
||||
YCoordinate,
|
||||
MCoordinate,
|
||||
ZCoordinate,
|
||||
Angle,
|
||||
CommonAngleSnapping,
|
||||
Distance,
|
||||
Bearing,
|
||||
};
|
||||
typedef QFlags<QgsAdvancedDigitizingFloater::FloaterItem> FloaterItems;
|
||||
|
||||
|
||||
|
||||
explicit QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget );
|
||||
%Docstring
|
||||
Create an advanced digitizing floater widget
|
||||
@ -46,6 +61,15 @@ Whether the floater is active or not.
|
||||
Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas).
|
||||
|
||||
.. versionadded:: 3.8
|
||||
%End
|
||||
|
||||
bool itemVisibility( const QgsAdvancedDigitizingFloater::FloaterItem &item ) const;
|
||||
%Docstring
|
||||
Returns ``True`` if the floater ``item`` visibility setting is enabled.
|
||||
|
||||
:param item: floater item
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
public slots:
|
||||
@ -58,6 +82,16 @@ Note that the floater may be active but not visible (e.g. if the mouse is not ov
|
||||
:param active:
|
||||
|
||||
.. versionadded:: 3.8
|
||||
%End
|
||||
|
||||
void setItemVisibility( const QgsAdvancedDigitizingFloater::FloaterItem &item, bool visible );
|
||||
%Docstring
|
||||
Set whether the floater ``item`` should be visible or not.
|
||||
|
||||
:param item: floater item
|
||||
:param visible:
|
||||
|
||||
.. versionadded:: 3.32
|
||||
%End
|
||||
|
||||
private:
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qgsadvanceddigitizingdockwidget.h"
|
||||
#include "qgsadvanceddigitizingfloater.h"
|
||||
#include "qgsadvanceddigitizingcanvasitem.h"
|
||||
#include "qgsbearingnumericformat.h"
|
||||
#include "qgscadutils.h"
|
||||
#include "qgsexpression.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
@ -35,6 +36,7 @@
|
||||
#include "qgsmapmouseevent.h"
|
||||
#include "qgsmeshlayer.h"
|
||||
#include "qgsunittypes.h"
|
||||
#include "qgslocaldefaultsettings.h"
|
||||
|
||||
#include <QActionGroup>
|
||||
|
||||
@ -129,16 +131,8 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *
|
||||
QgsFocusWatcher *mWatcher = new QgsFocusWatcher( mMLineEdit );
|
||||
connect( mWatcher, &QgsFocusWatcher::focusOut, this, &QgsAdvancedDigitizingDockWidget::constraintFocusOut );
|
||||
|
||||
// config menu
|
||||
// Common angle snapping menu
|
||||
mCommonAngleActionsMenu = new QMenu( this );
|
||||
|
||||
QAction *showCommonAngleSnappingInFloaterAction = new QAction( tr( "Show setting in the floater" ), mCommonAngleActionsMenu );
|
||||
showCommonAngleSnappingInFloaterAction->setCheckable( true );
|
||||
|
||||
mCommonAngleActionsMenu->addAction( showCommonAngleSnappingInFloaterAction );
|
||||
|
||||
// common angles
|
||||
|
||||
// Suppress warning: Potential leak of memory pointed to by 'angleButtonGroup' [clang-analyzer-cplusplus.NewDeleteLeaks]
|
||||
#ifndef __clang_analyzer__
|
||||
QActionGroup *angleButtonGroup = new QActionGroup( mCommonAngleActionsMenu ); // actions are exclusive for common angles NOLINT
|
||||
@ -233,18 +227,105 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *
|
||||
connect( mAngleLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueAngleChanged );
|
||||
|
||||
// Create the floater
|
||||
mFloaterActionsMenu = new QMenu( this );
|
||||
qobject_cast< QToolButton *>( mToolbar->widgetForAction( mFloaterAction ) )->setPopupMode( QToolButton::InstantPopup );
|
||||
mFloaterAction->setMenu( mFloaterActionsMenu );
|
||||
mFloaterAction->setCheckable( true );
|
||||
mFloater = new QgsAdvancedDigitizingFloater( canvas, this );
|
||||
connect( mToggleFloaterAction, &QAction::triggered, mFloater, &QgsAdvancedDigitizingFloater::setActive );
|
||||
mToggleFloaterAction->setChecked( mFloater->active() );
|
||||
mFloaterAction->setChecked( mFloater->active() );
|
||||
|
||||
mShowCommonAngleInFloater = QgsSettings().value( QStringLiteral( "/Cad/CommonAngleShowInFloater" ), false ).toBool();
|
||||
connect( showCommonAngleSnappingInFloaterAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::commonAngleSnappingShowInFloaterChanged );
|
||||
showCommonAngleSnappingInFloaterAction->setChecked( mShowCommonAngleInFloater );
|
||||
connect( showCommonAngleSnappingInFloaterAction, &QAction::triggered, this, [ = ]( bool checked )
|
||||
// Add floater config actions
|
||||
{
|
||||
mShowCommonAngleInFloater = checked;
|
||||
QgsSettings().setValue( QStringLiteral( "/Cad/CommonAngleShowInFloater" ), checked );
|
||||
} );
|
||||
QAction *action = new QAction( tr( "Show floater" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
action->setChecked( mFloater->active() );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setActive( checked );
|
||||
mFloaterAction->setChecked( checked );
|
||||
} );
|
||||
}
|
||||
|
||||
mFloaterActionsMenu->addSeparator();
|
||||
|
||||
{
|
||||
QAction *action = new QAction( tr( "Show XY coordinates" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::XCoordinate, checked );
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::YCoordinate, checked );
|
||||
} );
|
||||
action->setChecked( QgsSettings().value( QStringLiteral( "/Cad/XYShowInFloater" ), true ).toBool() );
|
||||
}
|
||||
|
||||
{
|
||||
QAction *action = new QAction( tr( "Show angle" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::Angle, checked );
|
||||
} );
|
||||
action->setChecked( QgsSettings().value( QStringLiteral( "/Cad/AngleShowInFloater" ), true ).toBool() );
|
||||
}
|
||||
|
||||
{
|
||||
QAction *action = new QAction( tr( "Show M value" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::MCoordinate, checked );
|
||||
} );
|
||||
action->setChecked( QgsSettings().value( QStringLiteral( "/Cad/MShowInFloater" ), true ).toBool() );
|
||||
}
|
||||
|
||||
{
|
||||
QAction *action = new QAction( tr( "Show Z value" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::ZCoordinate, checked );
|
||||
} );
|
||||
action->setChecked( QgsSettings().value( QStringLiteral( "/Cad/ZShowInFloater" ), true ).toBool() );
|
||||
}
|
||||
|
||||
{
|
||||
QAction *action = new QAction( tr( "Show common snapping angle" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::CommonAngleSnapping, checked );
|
||||
} );
|
||||
action->setChecked( QgsSettings().value( QStringLiteral( "/Cad/CommonAngleShowInFloater" ), false ).toBool() );
|
||||
}
|
||||
|
||||
{
|
||||
QAction *action = new QAction( tr( "Show distance" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::Distance, checked );
|
||||
} );
|
||||
action->setChecked( QgsSettings().value( QStringLiteral( "/Cad/DistanceShowInFloater" ), true ).toBool() );
|
||||
}
|
||||
|
||||
{
|
||||
QAction *action = new QAction( tr( "Show bearing/azimuth" ), mFloaterActionsMenu );
|
||||
action->setCheckable( true );
|
||||
mFloaterActionsMenu->addAction( action );
|
||||
connect( action, &QAction::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
mFloater->setItemVisibility( QgsAdvancedDigitizingFloater::FloaterItem::Bearing, checked );
|
||||
} );
|
||||
action->setChecked( QgsSettings().value( QStringLiteral( "/Cad/BearingShowInFloater" ), false ).toBool() );
|
||||
}
|
||||
|
||||
updateCapacity( true );
|
||||
connect( QgsProject::instance(), &QgsProject::snappingConfigChanged, this, [ = ] { updateCapacity( true ); } );
|
||||
@ -366,7 +447,7 @@ void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled )
|
||||
mConstructionModeAction->setEnabled( enabled );
|
||||
mSettingsAction->setEnabled( enabled );
|
||||
mInputWidgets->setEnabled( enabled );
|
||||
mToggleFloaterAction->setEnabled( enabled );
|
||||
mFloaterAction->setEnabled( enabled );
|
||||
mConstructionAction->setEnabled( enabled );
|
||||
|
||||
if ( !enabled )
|
||||
@ -389,7 +470,6 @@ void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled )
|
||||
|
||||
if ( enabled )
|
||||
{
|
||||
emit commonAngleSnappingShowInFloaterChanged( mShowCommonAngleInFloater );
|
||||
emit valueCommonAngleSnappingChanged( mCommonAngleConstraint );
|
||||
}
|
||||
|
||||
@ -1226,19 +1306,29 @@ void QgsAdvancedDigitizingDockWidget::updateUnlockedConstraintValues( const QgsP
|
||||
// --- angle
|
||||
if ( !mAngleConstraint->isLocked() && previousPointExist )
|
||||
{
|
||||
double angle = 0.0;
|
||||
double prevAngle = 0.0;
|
||||
|
||||
if ( penulPointExist && mAngleConstraint->relative() )
|
||||
{
|
||||
// previous angle
|
||||
angle = std::atan2( previousPt.y() - penultimatePt.y(),
|
||||
previousPt.x() - penultimatePt.x() );
|
||||
prevAngle = std::atan2( previousPt.y() - penultimatePt.y(),
|
||||
previousPt.x() - penultimatePt.x() ) * 180 / M_PI;
|
||||
}
|
||||
angle = ( std::atan2( point.y() - previousPt.y(),
|
||||
point.x() - previousPt.x()
|
||||
) - angle ) * 180 / M_PI;
|
||||
// modulus
|
||||
angle = std::fmod( angle, 360.0 );
|
||||
|
||||
const double xAngle { std::atan2( point.y() - previousPt.y(),
|
||||
point.x() - previousPt.x() ) * 180 / M_PI };
|
||||
|
||||
// Modulus
|
||||
const double angle = std::fmod( xAngle - prevAngle, 360.0 );
|
||||
mAngleConstraint->setValue( angle );
|
||||
|
||||
// Bearing (azimuth)
|
||||
double bearing { std::fmod( xAngle, 360.0 ) };
|
||||
bearing = bearing <= 90.0 ? 90.0 - bearing : ( bearing > 90 ? 270.0 + 180.0 - bearing : 270.0 - bearing );
|
||||
const QgsNumericFormatContext context;
|
||||
const QString bearingText { QgsProject::instance()->displaySettings()->bearingFormat()->formatDouble( bearing, context ) };
|
||||
emit valueBearingChanged( bearingText );
|
||||
|
||||
}
|
||||
// --- distance
|
||||
if ( !mDistanceConstraint->isLocked() && previousPointExist )
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ui_qgsadvanceddigitizingdockwidgetbase.h"
|
||||
#include "qgsadvanceddigitizingfloater.h"
|
||||
#include "qgis_gui.h"
|
||||
#include "qgis_sip.h"
|
||||
#include "qgsdockwidget.h"
|
||||
@ -667,6 +666,14 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
|
||||
*/
|
||||
void valueDistanceChanged( const QString &value );
|
||||
|
||||
/**
|
||||
* Emitted whenever the bearing \a value changes.
|
||||
* Could be used by widgets that must reflect the current advanced digitizing state.
|
||||
* \note unstable API (will likely change)
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
void valueBearingChanged( const QString &value );
|
||||
|
||||
/**
|
||||
* Emitted whenever the X parameter is \a locked.
|
||||
* Could be used by widgets that must reflect the current advanced digitizing state.
|
||||
@ -1076,7 +1083,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
|
||||
QgsPoint pointXYToPoint( const QgsPointXY &point ) const;
|
||||
|
||||
QMenu *mCommonAngleActionsMenu = nullptr;
|
||||
bool mShowCommonAngleInFloater = false;
|
||||
QMenu *mFloaterActionsMenu = nullptr;
|
||||
|
||||
friend class TestQgsAdvancedDigitizing;
|
||||
friend class TestQgsAdvancedDigitizingDockWidget;
|
||||
|
@ -59,6 +59,7 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueZChanged, this, &QgsAdvancedDigitizingFloater::changeZ );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueMChanged, this, &QgsAdvancedDigitizingFloater::changeM );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueBearingChanged, this, &QgsAdvancedDigitizingFloater::changeBearing );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueCommonAngleSnappingChanged, this, &QgsAdvancedDigitizingFloater::changeCommonAngleSnapping );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::commonAngleSnappingShowInFloaterChanged, this, &QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeDistance );
|
||||
@ -89,6 +90,10 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedZ, this, &QgsAdvancedDigitizingFloater::enabledChangedZ );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedM, this, &QgsAdvancedDigitizingFloater::enabledChangedM );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle );
|
||||
// Bearing capability is the same an angle, connect to the same signal:
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedBearing );
|
||||
// Common angle snapping capbility is also linked to angle, connect to the same signal:
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping );
|
||||
connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance );
|
||||
|
||||
// Connect our line edits signals to update cadDockWidget's state (implementation copied from QgsAdvancedDigitizingDockWidget)
|
||||
@ -120,6 +125,8 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas
|
||||
connect( distanceWatcher, &QgsFocusWatcher::focusOut, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text(), QgsAdvancedDigitizingDockWidget::WidgetSetMode::FocusOut ); } );
|
||||
changeCommonAngleSnapping( mCadDockWidget->commonAngleConstraint() );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool QgsAdvancedDigitizingFloater::eventFilter( QObject *obj, QEvent *event )
|
||||
@ -153,6 +160,11 @@ bool QgsAdvancedDigitizingFloater::active()
|
||||
return mActive;
|
||||
}
|
||||
|
||||
bool QgsAdvancedDigitizingFloater::itemVisibility( const FloaterItem &item ) const
|
||||
{
|
||||
return mItemsVisibility.testFlag( item );
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::setActive( bool active )
|
||||
{
|
||||
QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), active );
|
||||
@ -162,6 +174,39 @@ void QgsAdvancedDigitizingFloater::setActive( bool active )
|
||||
hideIfDisabled();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::setItemVisibility( const QgsAdvancedDigitizingFloater::FloaterItem &item, bool visible )
|
||||
{
|
||||
QgsSettings().setValue( QStringLiteral( "/Cad/%1ShowInFloater" ).arg( QMetaEnum::fromType<QgsAdvancedDigitizingFloater::FloaterItem>().valueToKey( item ) ), visible );
|
||||
mItemsVisibility.setFlag( item, visible );
|
||||
switch ( item )
|
||||
{
|
||||
case FloaterItem::XCoordinate:
|
||||
enabledChangedX( visible );
|
||||
break;
|
||||
case FloaterItem::YCoordinate:
|
||||
enabledChangedY( visible );
|
||||
break;
|
||||
case FloaterItem::MCoordinate:
|
||||
enabledChangedM( visible );
|
||||
break;
|
||||
case FloaterItem::ZCoordinate:
|
||||
enabledChangedZ( visible );
|
||||
break;
|
||||
case FloaterItem::Angle:
|
||||
enabledChangedAngle( visible );
|
||||
break;
|
||||
case FloaterItem::Distance:
|
||||
enabledChangedDistance( visible );
|
||||
break;
|
||||
case FloaterItem::CommonAngleSnapping:
|
||||
enabledCommonAngleSnapping( visible );
|
||||
break;
|
||||
case FloaterItem::Bearing:
|
||||
enabledChangedBearing( visible );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::updatePos( const QPoint &pos )
|
||||
{
|
||||
// We hardcode a small delta between the mouse position and the widget's position
|
||||
@ -211,6 +256,11 @@ void QgsAdvancedDigitizingFloater::changeAngle( const QString &text )
|
||||
mAngleLineEdit->setText( text );
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::changeBearing( const QString &text )
|
||||
{
|
||||
mBearingLineEdit->setText( text );
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::changeLockX( bool locked )
|
||||
{
|
||||
if ( !locked )
|
||||
@ -420,49 +470,56 @@ void QgsAdvancedDigitizingFloater::focusOnAngle()
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledChangedX( bool enabled )
|
||||
{
|
||||
mXLineEdit->setVisible( enabled );
|
||||
mXLabel->setVisible( enabled );
|
||||
mXLineEdit->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
|
||||
mXLabel->setVisible( enabled && itemVisibility( FloaterItem::XCoordinate ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledChangedY( bool enabled )
|
||||
{
|
||||
mYLineEdit->setVisible( enabled );
|
||||
mYLabel->setVisible( enabled );
|
||||
mYLineEdit->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
|
||||
mYLabel->setVisible( enabled && itemVisibility( FloaterItem::YCoordinate ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledChangedZ( bool enabled )
|
||||
{
|
||||
mZLineEdit->setVisible( enabled );
|
||||
mZLabel->setVisible( enabled );
|
||||
mZLineEdit->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
|
||||
mZLabel->setVisible( enabled && itemVisibility( FloaterItem::ZCoordinate ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledChangedM( bool enabled )
|
||||
{
|
||||
mMLineEdit->setVisible( enabled );
|
||||
mMLabel->setVisible( enabled );
|
||||
mMLineEdit->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
|
||||
mMLabel->setVisible( enabled && itemVisibility( FloaterItem::MCoordinate ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledChangedDistance( bool enabled )
|
||||
{
|
||||
mDistanceLineEdit->setVisible( enabled );
|
||||
mDistanceLabel->setVisible( enabled );
|
||||
mDistanceLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
|
||||
mDistanceLabel->setVisible( enabled && itemVisibility( FloaterItem::Distance ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledCommonAngleSnapping( bool enabled )
|
||||
{
|
||||
mCommonAngleSnappingLineEdit->setVisible( enabled );
|
||||
mCommonAngleSnappingLabel->setVisible( enabled );
|
||||
mCommonAngleSnappingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
|
||||
mCommonAngleSnappingLabel->setVisible( enabled && itemVisibility( FloaterItem::CommonAngleSnapping ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledChangedAngle( bool enabled )
|
||||
{
|
||||
mAngleLineEdit->setVisible( enabled );
|
||||
mAngleLabel->setVisible( enabled );
|
||||
mAngleLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
|
||||
mAngleLabel->setVisible( enabled && itemVisibility( FloaterItem::Angle ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void QgsAdvancedDigitizingFloater::enabledChangedBearing( bool enabled )
|
||||
{
|
||||
mBearingLineEdit->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
|
||||
mBearingLabel->setVisible( enabled && itemVisibility( FloaterItem::Bearing ) );
|
||||
adjustSize();
|
||||
}
|
||||
|
@ -43,6 +43,22 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
|
||||
|
||||
public:
|
||||
|
||||
//! Available floater items
|
||||
enum FloaterItem
|
||||
{
|
||||
XCoordinate,
|
||||
YCoordinate,
|
||||
MCoordinate,
|
||||
ZCoordinate,
|
||||
Angle,
|
||||
CommonAngleSnapping,
|
||||
Distance,
|
||||
Bearing,
|
||||
};
|
||||
Q_DECLARE_FLAGS( FloaterItems, FloaterItem )
|
||||
Q_FLAG( FloaterItem )
|
||||
|
||||
|
||||
/**
|
||||
* Create an advanced digitizing floater widget
|
||||
* \param canvas The map canvas on which the widget operates
|
||||
@ -58,6 +74,14 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
|
||||
*/
|
||||
bool active();
|
||||
|
||||
/**
|
||||
* Returns TRUE if the floater \a item visibility setting is enabled.
|
||||
*
|
||||
* \param item floater item
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
bool itemVisibility( const QgsAdvancedDigitizingFloater::FloaterItem &item ) const;
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@ -69,6 +93,15 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
|
||||
*/
|
||||
void setActive( bool active );
|
||||
|
||||
/**
|
||||
* Set whether the floater \a item should be visible or not.
|
||||
*
|
||||
* \param item floater item
|
||||
* \param visible
|
||||
* \since QGIS 3.32
|
||||
*/
|
||||
void setItemVisibility( const QgsAdvancedDigitizingFloater::FloaterItem &item, bool visible );
|
||||
|
||||
private slots:
|
||||
|
||||
void changeX( const QString &text );
|
||||
@ -78,6 +111,7 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
|
||||
void changeCommonAngleSnapping( double angle );
|
||||
void changeDistance( const QString &text );
|
||||
void changeAngle( const QString &text );
|
||||
void changeBearing( const QString &text );
|
||||
void changeLockX( bool locked );
|
||||
void changeLockY( bool locked );
|
||||
void changeLockZ( bool locked );
|
||||
@ -103,6 +137,7 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
|
||||
void enabledChangedAngle( bool enabled );
|
||||
void enabledChangedDistance( bool enabled );
|
||||
void enabledCommonAngleSnapping( bool enabled );
|
||||
void enabledChangedBearing( bool enabled );
|
||||
|
||||
private:
|
||||
|
||||
@ -131,6 +166,8 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA
|
||||
|
||||
//! Whether the floater is enabled.
|
||||
bool mActive = false;
|
||||
|
||||
FloaterItems mItemsVisibility;
|
||||
};
|
||||
|
||||
#endif // QGSADVANCEDDIGITIZINGFLOATER_H
|
||||
|
@ -49,7 +49,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="mSettingsAction"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="mToggleFloaterAction"/>
|
||||
<addaction name="mFloaterAction"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="mConstructionAction"/>
|
||||
</widget>
|
||||
@ -612,7 +612,7 @@
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<action name="mToggleFloaterAction">
|
||||
<action name="mFloaterAction">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -621,7 +621,7 @@
|
||||
<normaloff>:/images/themes/default/cadtools/floater.svg</normaloff>:/images/themes/default/cadtools/floater.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Toggle Floater</string>
|
||||
<string>Floater settings</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mConstructionAction">
|
||||
|
@ -72,19 +72,23 @@
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="6" column="3">
|
||||
<widget class="QLineEdit" name="mZLineEdit">
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="mZLabel">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
<string>z</string>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="mMLabel">
|
||||
<property name="text">
|
||||
<string>m</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -98,39 +102,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="mAngleLabel">
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="mXLabel">
|
||||
<property name="text">
|
||||
<string>a</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLineEdit" name="mXLineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="mDistanceLabel">
|
||||
<property name="text">
|
||||
<string>d</string>
|
||||
<string>x</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -156,6 +131,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="mAngleLabel">
|
||||
<property name="text">
|
||||
<string>a</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLineEdit" name="mDistanceLineEdit">
|
||||
<property name="toolTip">
|
||||
@ -172,8 +157,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="3">
|
||||
<widget class="QLineEdit" name="mMLineEdit">
|
||||
<item row="6" column="3">
|
||||
<widget class="QLineEdit" name="mZLineEdit">
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>40</width>
|
||||
@ -188,26 +173,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="mMLabel">
|
||||
<property name="text">
|
||||
<string>m</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="mZLabel">
|
||||
<property name="text">
|
||||
<string>z</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLineEdit" name="mAngleLineEdit">
|
||||
<property name="minimumSize">
|
||||
@ -227,24 +192,59 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="mXLabel">
|
||||
<property name="text">
|
||||
<string>x</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QLabel" name="mCommonAngleSnappingLabel">
|
||||
<property name="text">
|
||||
<string>∠</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="3">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="mDistanceLabel">
|
||||
<property name="text">
|
||||
<string>d</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="3">
|
||||
<widget class="QLineEdit" name="mMLineEdit">
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLineEdit" name="mXLineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="3">
|
||||
<widget class="QLineEdit" name="mCommonAngleSnappingLineEdit">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
@ -254,6 +254,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="mBearingLabel">
|
||||
<property name="text">
|
||||
<string>🧭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="3">
|
||||
<widget class="QLineEdit" name="mBearingLineEdit">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
Loading…
x
Reference in New Issue
Block a user