mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
[FEATURE][composer] Add view menu option to hide bounding boxes
This allows users to hide the bounding boxes for selected items within a composition. It's a handy feature for allowing interaction with items while previewing exactly how they will look when the composition is exported, without large boxes blocking the view.
This commit is contained in:
parent
a57080cc71
commit
7b537f640f
@ -222,6 +222,20 @@ class QgsComposition : QGraphicsScene
|
||||
* @note Added in QGIS 2.5
|
||||
*/
|
||||
int snapTolerance() const;
|
||||
|
||||
/**Sets whether selection bounding boxes should be shown in the composition
|
||||
* @param boundsVisible set to true to show selection bounding box
|
||||
* @see boundingBoxesVisible
|
||||
* @note added in QGIS 2.7
|
||||
*/
|
||||
void setBoundingBoxesVisible( const bool boundsVisible );
|
||||
|
||||
/**Returns whether selection bounding boxes should be shown in the composition
|
||||
* @returns true if selection bounding boxes should be shown
|
||||
* @see setBoundingBoxesVisible
|
||||
* @note added in QGIS 2.7
|
||||
*/
|
||||
bool boundingBoxesVisible() const;
|
||||
|
||||
/**Returns pointer to undo/redo command storage*/
|
||||
QUndoStack* undoStack();
|
||||
|
@ -190,6 +190,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
|
||||
mActionSnapGuides->setCheckable( true );
|
||||
mActionSmartGuides->setCheckable( true );
|
||||
mActionShowRulers->setCheckable( true );
|
||||
mActionShowBoxes->setCheckable( true );
|
||||
|
||||
mActionAtlasPreview->setCheckable( true );
|
||||
|
||||
@ -332,6 +333,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
|
||||
viewMenu->addAction( mActionSmartGuides );
|
||||
viewMenu->addAction( mActionClearGuides );
|
||||
viewMenu->addSeparator();
|
||||
viewMenu->addAction( mActionShowBoxes );
|
||||
viewMenu->addAction( mActionShowRulers );
|
||||
|
||||
// Panel and toolbar submenus
|
||||
@ -1192,6 +1194,15 @@ void QgsComposer::on_mActionSmartGuides_triggered( bool checked )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposer::on_mActionShowBoxes_triggered( bool checked )
|
||||
{
|
||||
//show or hide bounding boxes
|
||||
if ( mComposition )
|
||||
{
|
||||
mComposition->setBoundingBoxesVisible( checked );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposer::on_mActionClearGuides_triggered()
|
||||
{
|
||||
//clear guide lines
|
||||
@ -3155,6 +3166,8 @@ void QgsComposer::restoreGridSettings()
|
||||
mActionShowGuides->setChecked( mComposition->snapLinesVisible() );
|
||||
mActionSnapGuides->setChecked( mComposition->alignmentSnap() );
|
||||
mActionSmartGuides->setChecked( mComposition->smartGuidesEnabled() );
|
||||
//general view settings
|
||||
mActionShowBoxes->setChecked( mComposition->boundingBoxesVisible() );
|
||||
}
|
||||
|
||||
void QgsComposer::deleteItemWidgets()
|
||||
|
3
src/app/composer/qgscomposer.h
Normal file → Executable file
3
src/app/composer/qgscomposer.h
Normal file → Executable file
@ -317,6 +317,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
|
||||
//!Enable or disable smart guides
|
||||
void on_mActionSmartGuides_triggered( bool checked );
|
||||
|
||||
//!Show/hide bounding boxes
|
||||
void on_mActionShowBoxes_triggered( bool checked );
|
||||
|
||||
//!Show/hide rulers
|
||||
void toggleRulers( bool checked );
|
||||
|
||||
|
@ -89,12 +89,18 @@ void QgsComposerMouseHandles::paint( QPainter* painter, const QStyleOptionGraphi
|
||||
return;
|
||||
}
|
||||
|
||||
//draw resize handles around bounds of entire selection
|
||||
double rectHandlerSize = rectHandlerBorderTolerance();
|
||||
drawHandles( painter, rectHandlerSize );
|
||||
if ( mComposition->boundingBoxesVisible() )
|
||||
{
|
||||
//draw resize handles around bounds of entire selection
|
||||
double rectHandlerSize = rectHandlerBorderTolerance();
|
||||
drawHandles( painter, rectHandlerSize );
|
||||
}
|
||||
|
||||
//draw dotted boxes around selected items
|
||||
drawSelectedItemBounds( painter );
|
||||
if ( mIsResizing || mIsDragging || mComposition->boundingBoxesVisible() )
|
||||
{
|
||||
//draw dotted boxes around selected items
|
||||
drawSelectedItemBounds( painter );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposerMouseHandles::drawHandles( QPainter* painter, double rectHandlerSize )
|
||||
@ -589,6 +595,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event
|
||||
{
|
||||
mIsDragging = false;
|
||||
mIsResizing = false;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,7 @@ void QgsComposition::init()
|
||||
mGuidesVisible = true;
|
||||
mSmartGuides = true;
|
||||
mSnapTolerance = 0;
|
||||
mBoundingBoxesVisible = true;
|
||||
mSelectionHandles = 0;
|
||||
mActiveItemCommand = 0;
|
||||
mActiveMultiFrameCommand = 0;
|
||||
@ -215,6 +216,7 @@ void QgsComposition::loadDefaults()
|
||||
mSnapGridOffsetX = settings.value( "/Composer/defaultSnapGridOffsetX", 0 ).toDouble();
|
||||
mSnapGridOffsetY = settings.value( "/Composer/defaultSnapGridOffsetY", 0 ).toDouble();
|
||||
mSnapTolerance = settings.value( "/Composer/defaultSnapTolerancePixels", 5 ).toInt();
|
||||
mBoundingBoxesVisible = settings.value( "/Composer/showBoundingBoxes", true ).toBool();
|
||||
}
|
||||
|
||||
void QgsComposition::updateBounds()
|
||||
@ -2142,6 +2144,20 @@ void QgsComposition::setGridStyle( const GridStyle s )
|
||||
updatePaperItems();
|
||||
}
|
||||
|
||||
void QgsComposition::setBoundingBoxesVisible( const bool boundsVisible )
|
||||
{
|
||||
mBoundingBoxesVisible = boundsVisible;
|
||||
|
||||
//save to settings
|
||||
QSettings settings;
|
||||
settings.setValue( "/Composer/showBoundingBoxes", mBoundingBoxesVisible );
|
||||
|
||||
if ( mSelectionHandles )
|
||||
{
|
||||
mSelectionHandles->update();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposition::updateSettings()
|
||||
{
|
||||
//load new composer setting values
|
||||
|
15
src/core/composer/qgscomposition.h
Normal file → Executable file
15
src/core/composer/qgscomposition.h
Normal file → Executable file
@ -284,6 +284,20 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
|
||||
*/
|
||||
int snapTolerance() const { return mSnapTolerance; }
|
||||
|
||||
/**Sets whether selection bounding boxes should be shown in the composition
|
||||
* @param boundsVisible set to true to show selection bounding box
|
||||
* @see boundingBoxesVisible
|
||||
* @note added in QGIS 2.7
|
||||
*/
|
||||
void setBoundingBoxesVisible( const bool boundsVisible );
|
||||
|
||||
/**Returns whether selection bounding boxes should be shown in the composition
|
||||
* @returns true if selection bounding boxes should be shown
|
||||
* @see setBoundingBoxesVisible
|
||||
* @note added in QGIS 2.7
|
||||
*/
|
||||
bool boundingBoxesVisible() const { return mBoundingBoxesVisible; }
|
||||
|
||||
/**Returns pointer to undo/redo command storage*/
|
||||
QUndoStack* undoStack() { return mUndoStack; }
|
||||
|
||||
@ -742,6 +756,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
|
||||
/**Arbitraty snap lines (horizontal and vertical)*/
|
||||
QList< QGraphicsLineItem* > mSnapLines;
|
||||
|
||||
bool mBoundingBoxesVisible;
|
||||
QgsComposerMouseHandles* mSelectionHandles;
|
||||
|
||||
QUndoStack* mUndoStack;
|
||||
|
@ -1012,6 +1012,17 @@
|
||||
<string>Atlas &Settings</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionShowBoxes">
|
||||
<property name="text">
|
||||
<string>Show Bounding Boxes</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show bounding boxes</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+B</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../python/plugins/fTools/resources.qrc"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user