Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3638da1
commit 122892d
Showing
4 changed files
with
259 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/*************************************************************************** | ||
qgs3dmapcanvasdockwidget.cpp | ||
-------------------------------------- | ||
Date : July 2017 | ||
Copyright : (C) 2017 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgs3dmapcanvasdockwidget.h" | ||
|
||
#include "qgisapp.h" | ||
#include "qgs3dmapcanvaswidget.h" | ||
#include "qgsdockwidget.h" | ||
|
||
#include <QWidget> | ||
|
||
Qgs3DMapCanvasDockWidget::Qgs3DMapCanvasDockWidget( QWidget *parent ) | ||
: QWidget( parent ) | ||
{ | ||
mCanvasWidget = new Qgs3DMapCanvasWidget; | ||
|
||
mDock = new QgsDockWidget( QgisApp::instance() ); | ||
mDock->setWidget( nullptr ); | ||
mDock->setAllowedAreas( Qt::AllDockWidgetAreas ); | ||
|
||
mDock->setVisible( false ); | ||
|
||
mDialog = new QDialog( QgisApp::instance(), Qt::Window ); | ||
QVBoxLayout *vl = new QVBoxLayout(); | ||
vl->setContentsMargins( 0, 0, 0, 0 ); | ||
mDialog->setLayout( vl ); | ||
mDialog->hide(); | ||
|
||
connect( mDock, &QgsDockWidget::closed, this, &Qgs3DMapCanvasDockWidget::closed ); | ||
connect( mDialog, &QDialog::finished, [=]() { | ||
emit this->closed(); | ||
} ); | ||
|
||
connect( mCanvasWidget, &Qgs3DMapCanvasWidget::toggleDockMode, this, &Qgs3DMapCanvasDockWidget::toggleDockMode ); | ||
|
||
mIsDocked = false; | ||
switchToDockMode(); | ||
} | ||
|
||
Qgs3DMapCanvasDockWidget::~Qgs3DMapCanvasDockWidget() | ||
{ | ||
delete mCanvasWidget; | ||
delete mDock; | ||
delete mDialog; | ||
} | ||
|
||
void Qgs3DMapCanvasDockWidget::setMapSettings( Qgs3DMapSettings *map ) | ||
{ | ||
mCanvasWidget->setMapSettings( map ); | ||
} | ||
|
||
void Qgs3DMapCanvasDockWidget::setMainCanvas( QgsMapCanvas *canvas ) | ||
{ | ||
mCanvasWidget->setMainCanvas( canvas ); | ||
} | ||
|
||
Qgs3DMapCanvas *Qgs3DMapCanvasDockWidget::mapCanvas3D() | ||
{ | ||
return mCanvasWidget->mapCanvas3D(); | ||
} | ||
|
||
Qgs3DAnimationWidget *Qgs3DMapCanvasDockWidget::animationWidget() | ||
{ | ||
return mCanvasWidget->animationWidget(); | ||
} | ||
|
||
Qgs3DMapToolMeasureLine *Qgs3DMapCanvasDockWidget::measurementLineTool() | ||
{ | ||
return mCanvasWidget->measurementLineTool(); | ||
} | ||
|
||
void Qgs3DMapCanvasDockWidget::toggleDockMode( bool docked ) | ||
{ | ||
// TODO: handle window/dock widget sizes and window titles | ||
if ( docked ) | ||
{ | ||
// going from window -> dock | ||
switchToDockMode(); | ||
} | ||
else | ||
{ | ||
// going from dock -> window | ||
switchToWindowMode(); | ||
} | ||
} | ||
|
||
|
||
void Qgs3DMapCanvasDockWidget::switchToWindowMode() | ||
{ | ||
if ( !mIsDocked ) | ||
return; | ||
|
||
mIsDocked = false; | ||
|
||
mDialog->layout()->addWidget( mCanvasWidget ); | ||
mDock->setWidget( nullptr ); | ||
|
||
mDialog->show(); | ||
mDock->setVisible( false ); | ||
} | ||
|
||
void Qgs3DMapCanvasDockWidget::switchToDockMode() | ||
{ | ||
if ( mIsDocked ) | ||
return; | ||
|
||
mIsDocked = true; | ||
|
||
mDialog->layout()->removeWidget( mCanvasWidget ); | ||
mDock->setWidget( mCanvasWidget ); | ||
|
||
mDialog->hide(); | ||
mDock->setVisible( true ); | ||
|
||
// TODO: apply resizing in a better way | ||
mDock->resize( mDock->size() + QSize(1, 1) ); | ||
mDock->resize( mDock->size() - QSize(1, 1) ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.