All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent eafd18dac0
commit 25c3ba7338
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -21,33 +21,31 @@
***************************************************************************/
# include <string>
# include <QApplication>
# include <QKeyEvent>
# include <QEvent>
# include <QDropEvent>
# include <QDragEnterEvent>
# include <QLayout>
# include <QMdiSubWindow>
# include <QMessageBox>
# include <QMimeData>
# include <QPainter>
# include <QPrinter>
# include <QPrintDialog>
# include <QPrintPreviewDialog>
# include <QStackedWidget>
# include <QSurfaceFormat>
# include <QTimer>
# include <QUrl>
# include <QWindow>
# include <Inventor/actions/SoGetPrimitiveCountAction.h>
# include <Inventor/fields/SoSFString.h>
# include <Inventor/nodes/SoOrthographicCamera.h>
# include <Inventor/nodes/SoPerspectiveCamera.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/SoPickedPoint.h>
#include <string>
#include <QApplication>
#include <QKeyEvent>
#include <QEvent>
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QLayout>
#include <QMdiSubWindow>
#include <QMessageBox>
#include <QMimeData>
#include <QPainter>
#include <QPrinter>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QStackedWidget>
#include <QSurfaceFormat>
#include <QTimer>
#include <QUrl>
#include <QWindow>
#include <Inventor/actions/SoGetPrimitiveCountAction.h>
#include <Inventor/fields/SoSFString.h>
#include <Inventor/nodes/SoOrthographicCamera.h>
#include <Inventor/nodes/SoPerspectiveCamera.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/SoPickedPoint.h>
#include <App/Application.h>
@@ -85,18 +83,20 @@ using namespace Gui;
void GLOverlayWidget::paintEvent(QPaintEvent*)
{
QPainter paint(this);
paint.drawImage(0,0,image);
paint.drawImage(0, 0, image);
paint.end();
}
/* TRANSLATOR Gui::View3DInventor */
TYPESYSTEM_SOURCE_ABSTRACT(Gui::View3DInventor,Gui::MDIView)
TYPESYSTEM_SOURCE_ABSTRACT(Gui::View3DInventor, Gui::MDIView)
View3DInventor::View3DInventor(Gui::Document* pcDocument,
QWidget* parent,
const QOpenGLWidget* sharewidget,
Qt::WindowFlags wflags)
View3DInventor::View3DInventor(
Gui::Document* pcDocument,
QWidget* parent,
const QOpenGLWidget* sharewidget,
Qt::WindowFlags wflags
)
: MDIView(pcDocument, parent, wflags)
, _viewerPy(nullptr)
{
@@ -106,7 +106,7 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument,
// accept drops on the window, get handled in dropEvent, dragEnterEvent
setAcceptDrops(true);
//anti-aliasing settings
// anti-aliasing settings
bool smoothing = false;
bool glformat = false;
int samples = View3DInventorViewer::getNumSamples();
@@ -120,13 +120,16 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument,
smoothing = true;
}
if (glformat)
if (glformat) {
_viewer = new View3DInventorViewer(f, this, sharewidget);
else
}
else {
_viewer = new View3DInventorViewer(this, sharewidget);
}
if (smoothing)
if (smoothing) {
_viewer->getSoRenderManager()->getGLRenderAction()->setSmoothing(true);
}
// create the inventor widget and set the defaults
_viewer->setDocument(this->_pcDocument);
@@ -150,18 +153,19 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument,
View3DInventor::~View3DInventor()
{
if(_pcDocument) {
SoCamera * Cam = _viewer->getSoRenderManager()->getCamera();
if (Cam)
if (_pcDocument) {
SoCamera* Cam = _viewer->getSoRenderManager()->getCamera();
if (Cam) {
_pcDocument->saveCameraSettings(SoFCDB::writeNodesToString(Cam).c_str());
}
}
viewSettings.reset();
//If we destroy this viewer by calling 'delete' directly the focus proxy widget which is defined
//by a widget in SoQtViewer isn't reset. This widget becomes a dangling pointer and makes
//the application crash. (Probably it's better to destroy this viewer by calling close().)
//See also Gui::Document::~Document().
// If we destroy this viewer by calling 'delete' directly the focus proxy widget which is
// defined by a widget in SoQtViewer isn't reset. This widget becomes a dangling pointer and
// makes the application crash. (Probably it's better to destroy this viewer by calling
// close().) See also Gui::Document::~Document().
QWidget* foc = qApp->focusWidget();
if (foc) {
QWidget* par = foc->parentWidget();
@@ -212,10 +216,11 @@ View3DInventor* View3DInventor::clone()
return view3D;
}
PyObject *View3DInventor::getPyObject()
PyObject* View3DInventor::getPyObject()
{
if (!_viewerPy)
if (!_viewerPy) {
_viewerPy = new View3DInventorPy(this);
}
Py_INCREF(_viewerPy);
return _viewerPy;
@@ -223,15 +228,19 @@ PyObject *View3DInventor::getPyObject()
void View3DInventor::applySettings()
{
viewSettings = std::make_unique<View3DSettings>(App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View"), _viewer);
naviSettings = std::make_unique<NaviCubeSettings>(App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/NaviCube"), _viewer);
viewSettings = std::make_unique<View3DSettings>(
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"),
_viewer
);
naviSettings = std::make_unique<NaviCubeSettings>(
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube"),
_viewer
);
viewSettings->applySettings();
naviSettings->applySettings();
}
void View3DInventor::onRename(Gui::Document *pDoc)
void View3DInventor::onRename(Gui::Document* pDoc)
{
SoSFString name;
name.setValue(pDoc->getDocument()->getName());
@@ -253,7 +262,7 @@ void View3DInventor::viewAll()
_viewer->viewAll();
}
const char *View3DInventor::getName() const
const char* View3DInventor::getName() const
{
return "View3DInventor";
}
@@ -274,13 +283,18 @@ void View3DInventor::print()
void View3DInventor::printPdf()
{
QString filename = FileDialog::getSaveFileName(this, tr("Export PDF"), QString(),
QStringLiteral("%1 (*.pdf)").arg(tr("PDF file")));
QString filename = FileDialog::getSaveFileName(
this,
tr("Export PDF"),
QString(),
QStringLiteral("%1 (*.pdf)").arg(tr("PDF file"))
);
if (!filename.isEmpty()) {
Gui::WaitCursor wc;
QPrinter printer(QPrinter::ScreenResolution);
// setPdfVersion sets the printed PDF Version to what is chosen in Preferences/Import-Export/PDF
// more details under: https://www.kdab.com/creating-pdfa-documents-qt/
// setPdfVersion sets the printed PDF Version to what is chosen in
// Preferences/Import-Export/PDF more details under:
// https://www.kdab.com/creating-pdfa-documents-qt/
printer.setPdfVersion(Gui::Dialog::DlgSettingsPDF::evaluatePDFVersion());
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPageOrientation(QPageLayout::Landscape);
@@ -297,8 +311,12 @@ void View3DInventor::printPreview()
restorePrinterSettings(&printer);
QPrintPreviewDialog dlg(&printer, this);
connect(&dlg, &QPrintPreviewDialog::paintRequested,
this, qOverload<QPrinter*>(&View3DInventor::print));
connect(
&dlg,
&QPrintPreviewDialog::paintRequested,
this,
qOverload<QPrinter*>(&View3DInventor::print)
);
dlg.exec();
savePrinterSettings(&printer);
}
@@ -309,16 +327,19 @@ void View3DInventor::print(QPrinter* printer)
p.setRenderHints(QPainter::Antialiasing);
if (!p.isActive() && !printer->outputFileName().isEmpty()) {
qApp->setOverrideCursor(Qt::ArrowCursor);
QMessageBox::critical(this, tr("Opening file failed"),
tr("Can't open file '%1' for writing.").arg(printer->outputFileName()));
QMessageBox::critical(
this,
tr("Opening file failed"),
tr("Can't open file '%1' for writing.").arg(printer->outputFileName())
);
qApp->restoreOverrideCursor();
return;
}
QRect rect = printer->pageLayout().paintRectPixels(printer->resolution());
QImage img;
_viewer->imageFromFramebuffer(rect.width(), rect.height(), 8, QColor(255,255,255), img);
p.drawImage(0,0,img);
_viewer->imageFromFramebuffer(rect.width(), rect.height(), 8, QColor(255, 255, 255), img);
p.drawImage(0, 0, img);
p.end();
}
@@ -331,113 +352,114 @@ bool View3DInventor::containsViewProvider(const ViewProvider* vp) const
bool View3DInventor::onMsg(const char* pMsg, const char** ppReturn)
{
if (strcmp("ViewFit",pMsg) == 0) {
if (strcmp("ViewFit", pMsg) == 0) {
_viewer->viewAll();
return true;
}
else if (strcmp("ViewVR",pMsg) == 0) {
else if (strcmp("ViewVR", pMsg) == 0) {
// call the VR portion of the viewer
_viewer->viewVR();
return true;
}
else if(strcmp("ViewSelection",pMsg) == 0) {
else if (strcmp("ViewSelection", pMsg) == 0) {
_viewer->viewSelection();
return true;
}
else if(strcmp("SetStereoRedGreen",pMsg) == 0 ) {
else if (strcmp("SetStereoRedGreen", pMsg) == 0) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::ANAGLYPH);
return true;
}
else if(strcmp("SetStereoQuadBuff",pMsg) == 0 ) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::QUAD_BUFFER );
else if (strcmp("SetStereoQuadBuff", pMsg) == 0) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::QUAD_BUFFER);
return true;
}
else if(strcmp("SetStereoInterleavedRows",pMsg) == 0 ) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::INTERLEAVED_ROWS );
else if (strcmp("SetStereoInterleavedRows", pMsg) == 0) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::INTERLEAVED_ROWS);
return true;
}
else if(strcmp("SetStereoInterleavedColumns",pMsg) == 0 ) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::INTERLEAVED_COLUMNS );
else if (strcmp("SetStereoInterleavedColumns", pMsg) == 0) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::INTERLEAVED_COLUMNS);
return true;
}
else if(strcmp("SetStereoOff",pMsg) == 0 ) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::MONO );
else if (strcmp("SetStereoOff", pMsg) == 0) {
_viewer->setStereoMode(Quarter::SoQTQuarterAdaptor::MONO);
return true;
}
else if(strcmp("GetCamera",pMsg) == 0 ) {
SoCamera * Cam = _viewer->getSoRenderManager()->getCamera();
if (!Cam)
else if (strcmp("GetCamera", pMsg) == 0) {
SoCamera* Cam = _viewer->getSoRenderManager()->getCamera();
if (!Cam) {
return false;
}
*ppReturn = SoFCDB::writeNodesToString(Cam).c_str();
return true;
}
else if(strncmp("SetCamera",pMsg,9) == 0 ) {
return setCamera(pMsg+10);
else if (strncmp("SetCamera", pMsg, 9) == 0) {
return setCamera(pMsg + 10);
}
else if(strncmp("Dump",pMsg,4) == 0 ) {
dump(pMsg+5);
else if (strncmp("Dump", pMsg, 4) == 0) {
dump(pMsg + 5);
return true;
}
else if(strcmp("ViewBottom",pMsg) == 0 ) {
else if (strcmp("ViewBottom", pMsg) == 0) {
_viewer->setCameraOrientation(Camera::rotation(Camera::Bottom));
_viewer->viewAll();
return true;
}
else if(strcmp("ViewFront",pMsg) == 0 ) {
else if (strcmp("ViewFront", pMsg) == 0) {
_viewer->setCameraOrientation(Camera::rotation(Camera::Front));
_viewer->viewAll();
return true;
}
else if(strcmp("ViewLeft",pMsg) == 0 ) {
else if (strcmp("ViewLeft", pMsg) == 0) {
_viewer->setCameraOrientation(Camera::rotation(Camera::Left));
_viewer->viewAll();
return true;
}
else if(strcmp("ViewRear",pMsg) == 0 ) {
else if (strcmp("ViewRear", pMsg) == 0) {
_viewer->setCameraOrientation(Camera::rotation(Camera::Rear));
_viewer->viewAll();
return true;
}
else if(strcmp("ViewRight",pMsg) == 0 ) {
else if (strcmp("ViewRight", pMsg) == 0) {
_viewer->setCameraOrientation(Camera::rotation(Camera::Right));
_viewer->viewAll();
return true;
}
else if(strcmp("ViewTop",pMsg) == 0 ) {
else if (strcmp("ViewTop", pMsg) == 0) {
_viewer->setCameraOrientation(Camera::rotation(Camera::Top));
_viewer->viewAll();
return true;
}
else if(strcmp("ViewAxo",pMsg) == 0 ) {
else if (strcmp("ViewAxo", pMsg) == 0) {
_viewer->setCameraOrientation(Camera::rotation(Camera::Isometric));
_viewer->viewAll();
return true;
}
else if(strcmp("OrthographicCamera",pMsg) == 0 ) {
else if (strcmp("OrthographicCamera", pMsg) == 0) {
_viewer->setCameraType(SoOrthographicCamera::getClassTypeId());
return true;
}
else if(strcmp("PerspectiveCamera",pMsg) == 0 ) {
else if (strcmp("PerspectiveCamera", pMsg) == 0) {
_viewer->setCameraType(SoPerspectiveCamera::getClassTypeId());
return true;
}
else if(strcmp("Undo",pMsg) == 0 ) {
else if (strcmp("Undo", pMsg) == 0) {
getGuiDocument()->undo(1);
return true;
}
else if(strcmp("Redo",pMsg) == 0 ) {
else if (strcmp("Redo", pMsg) == 0) {
getGuiDocument()->redo(1);
return true;
}
else if (strcmp("Save",pMsg) == 0) {
else if (strcmp("Save", pMsg) == 0) {
getGuiDocument()->save();
return true;
}
else if (strcmp("SaveAs",pMsg) == 0) {
else if (strcmp("SaveAs", pMsg) == 0) {
getGuiDocument()->saveAs();
return true;
}
else if (strcmp("SaveCopy",pMsg) == 0) {
else if (strcmp("SaveCopy", pMsg) == 0) {
getGuiDocument()->saveCopy();
return true;
}
@@ -464,88 +486,88 @@ bool View3DInventor::onHasMsg(const char* pMsg) const
if (strcmp("CanPan", pMsg) == 0) {
return true;
}
else if (strcmp("Save",pMsg) == 0) {
else if (strcmp("Save", pMsg) == 0) {
return true;
}
else if (strcmp("SaveAs",pMsg) == 0) {
else if (strcmp("SaveAs", pMsg) == 0) {
return true;
}
else if (strcmp("SaveCopy",pMsg) == 0) {
else if (strcmp("SaveCopy", pMsg) == 0) {
return true;
}
else if (strcmp("Undo",pMsg) == 0) {
else if (strcmp("Undo", pMsg) == 0) {
App::Document* doc = getAppDocument();
return doc && doc->getAvailableUndos() > 0;
}
else if (strcmp("Redo",pMsg) == 0) {
else if (strcmp("Redo", pMsg) == 0) {
App::Document* doc = getAppDocument();
return doc && doc->getAvailableRedos() > 0;
}
else if (strcmp("Print",pMsg) == 0) {
else if (strcmp("Print", pMsg) == 0) {
return true;
}
else if (strcmp("PrintPreview",pMsg) == 0) {
else if (strcmp("PrintPreview", pMsg) == 0) {
return true;
}
else if (strcmp("PrintPdf",pMsg) == 0) {
else if (strcmp("PrintPdf", pMsg) == 0) {
return true;
}
else if(strcmp("SetStereoRedGreen",pMsg) == 0) {
else if (strcmp("SetStereoRedGreen", pMsg) == 0) {
return true;
}
else if(strcmp("SetStereoQuadBuff",pMsg) == 0) {
else if (strcmp("SetStereoQuadBuff", pMsg) == 0) {
return true;
}
else if(strcmp("SetStereoInterleavedRows",pMsg) == 0) {
else if (strcmp("SetStereoInterleavedRows", pMsg) == 0) {
return true;
}
else if(strcmp("SetStereoInterleavedColumns",pMsg) == 0) {
else if (strcmp("SetStereoInterleavedColumns", pMsg) == 0) {
return true;
}
else if(strcmp("SetStereoOff",pMsg) == 0) {
else if (strcmp("SetStereoOff", pMsg) == 0) {
return true;
}
else if(strcmp("ViewFit",pMsg) == 0) {
else if (strcmp("ViewFit", pMsg) == 0) {
return true;
}
else if(strcmp("ViewVR",pMsg) == 0) {
else if (strcmp("ViewVR", pMsg) == 0) {
#ifdef BUILD_VR
return true;
#else
return false;
#endif
}
else if(strcmp("ViewSelection",pMsg) == 0) {
else if (strcmp("ViewSelection", pMsg) == 0) {
return true;
}
else if(strcmp("ViewBottom",pMsg) == 0) {
else if (strcmp("ViewBottom", pMsg) == 0) {
return true;
}
else if(strcmp("ViewFront",pMsg) == 0) {
else if (strcmp("ViewFront", pMsg) == 0) {
return true;
}
else if(strcmp("ViewLeft",pMsg) == 0) {
else if (strcmp("ViewLeft", pMsg) == 0) {
return true;
}
else if(strcmp("ViewRear",pMsg) == 0) {
else if (strcmp("ViewRear", pMsg) == 0) {
return true;
}
else if(strcmp("ViewRight",pMsg) == 0) {
else if (strcmp("ViewRight", pMsg) == 0) {
return true;
}
else if(strcmp("ViewTop",pMsg) == 0) {
else if (strcmp("ViewTop", pMsg) == 0) {
return true;
}
else if(strcmp("ViewAxo",pMsg) == 0) {
else if (strcmp("ViewAxo", pMsg) == 0) {
return true;
}
else if(strcmp("GetCamera",pMsg) == 0) {
else if (strcmp("GetCamera", pMsg) == 0) {
return true;
}
else if(strncmp("SetCamera",pMsg,9) == 0) {
else if (strncmp("SetCamera", pMsg, 9) == 0) {
return true;
}
else if(strncmp("Dump",pMsg,4) == 0) {
else if (strncmp("Dump", pMsg, 4) == 0) {
return true;
}
else if (strcmp("AlignToSelection", pMsg) == 0) {
@@ -566,16 +588,16 @@ bool View3DInventor::onHasMsg(const char* pMsg) const
bool View3DInventor::setCamera(const char* pCamera)
{
SoCamera * CamViewer = _viewer->getSoRenderManager()->getCamera();
SoCamera* CamViewer = _viewer->getSoRenderManager()->getCamera();
if (!CamViewer) {
throw Base::RuntimeError("No camera set so far…");
}
SoInput in;
in.setBuffer((void*)pCamera,std::strlen(pCamera));
in.setBuffer((void*)pCamera, std::strlen(pCamera));
SoNode * Cam;
SoDB::read(&in,Cam);
SoNode* Cam;
SoDB::read(&in, Cam);
if (!Cam || !Cam->isOfType(SoCamera::getClassTypeId())) {
throw Base::RuntimeError("Camera settings failed to read");
@@ -590,38 +612,39 @@ bool View3DInventor::setCamera(const char* pCamera)
CamViewer = _viewer->getSoRenderManager()->getCamera();
}
SoPerspectiveCamera * CamViewerP = nullptr;
SoOrthographicCamera * CamViewerO = nullptr;
SoPerspectiveCamera* CamViewerP = nullptr;
SoOrthographicCamera* CamViewerO = nullptr;
if (CamViewer->getTypeId() == SoPerspectiveCamera::getClassTypeId()) {
CamViewerP = static_cast<SoPerspectiveCamera *>(CamViewer); // safe downward cast, knows the type
CamViewerP = static_cast<SoPerspectiveCamera*>(CamViewer); // safe downward cast, knows the type
}
else if (CamViewer->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
CamViewerO = static_cast<SoOrthographicCamera *>(CamViewer); // safe downward cast, knows the type
CamViewerO = static_cast<SoOrthographicCamera*>(CamViewer); // safe downward cast, knows
// the type
}
if (Cam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) {
if (CamViewerP){
CamViewerP->position = static_cast<SoPerspectiveCamera *>(Cam)->position;
CamViewerP->orientation = static_cast<SoPerspectiveCamera *>(Cam)->orientation;
CamViewerP->nearDistance = static_cast<SoPerspectiveCamera *>(Cam)->nearDistance;
CamViewerP->farDistance = static_cast<SoPerspectiveCamera *>(Cam)->farDistance;
CamViewerP->focalDistance = static_cast<SoPerspectiveCamera *>(Cam)->focalDistance;
if (CamViewerP) {
CamViewerP->position = static_cast<SoPerspectiveCamera*>(Cam)->position;
CamViewerP->orientation = static_cast<SoPerspectiveCamera*>(Cam)->orientation;
CamViewerP->nearDistance = static_cast<SoPerspectiveCamera*>(Cam)->nearDistance;
CamViewerP->farDistance = static_cast<SoPerspectiveCamera*>(Cam)->farDistance;
CamViewerP->focalDistance = static_cast<SoPerspectiveCamera*>(Cam)->focalDistance;
}
else {
throw Base::TypeError("Camera type mismatch");
}
}
else if (Cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
if (CamViewerO){
CamViewerO->viewportMapping = static_cast<SoOrthographicCamera *>(Cam)->viewportMapping;
CamViewerO->position = static_cast<SoOrthographicCamera *>(Cam)->position;
CamViewerO->orientation = static_cast<SoOrthographicCamera *>(Cam)->orientation;
CamViewerO->nearDistance = static_cast<SoOrthographicCamera *>(Cam)->nearDistance;
CamViewerO->farDistance = static_cast<SoOrthographicCamera *>(Cam)->farDistance;
CamViewerO->focalDistance = static_cast<SoOrthographicCamera *>(Cam)->focalDistance;
CamViewerO->aspectRatio = static_cast<SoOrthographicCamera *>(Cam)->aspectRatio ;
CamViewerO->height = static_cast<SoOrthographicCamera *>(Cam)->height;
if (CamViewerO) {
CamViewerO->viewportMapping = static_cast<SoOrthographicCamera*>(Cam)->viewportMapping;
CamViewerO->position = static_cast<SoOrthographicCamera*>(Cam)->position;
CamViewerO->orientation = static_cast<SoOrthographicCamera*>(Cam)->orientation;
CamViewerO->nearDistance = static_cast<SoOrthographicCamera*>(Cam)->nearDistance;
CamViewerO->farDistance = static_cast<SoOrthographicCamera*>(Cam)->farDistance;
CamViewerO->focalDistance = static_cast<SoOrthographicCamera*>(Cam)->focalDistance;
CamViewerO->aspectRatio = static_cast<SoOrthographicCamera*>(Cam)->aspectRatio;
CamViewerO->height = static_cast<SoOrthographicCamera*>(Cam)->height;
}
else {
throw Base::TypeError("Camera type mismatch");
@@ -652,7 +675,9 @@ void View3DInventor::removeOverlayWidget()
{
stack->setCurrentIndex(0);
QWidget* overlay = stack->widget(1);
if (overlay) stack->removeWidget(overlay);
if (overlay) {
stack->removeWidget(overlay);
}
}
void View3DInventor::setOverrideCursor(const QCursor& aCursor)
@@ -680,10 +705,13 @@ void View3DInventor::dump(const char* filename, bool onlyVisible)
node->ref();
}
if ( action.getTriangleCount() > 100000 || action.getPointCount() > 30000 || action.getLineCount() > 10000 )
if (action.getTriangleCount() > 100000 || action.getPointCount() > 30000
|| action.getLineCount() > 10000) {
_viewer->dumpToFile(node, filename, true);
else
}
else {
_viewer->dumpToFile(node, filename, false);
}
if (onlyVisible) {
node->unref();
@@ -699,18 +727,20 @@ void View3DInventor::windowStateChanged(QWidget* view)
// Note: If view is top-level or fullscreen it doesn't necessarily hide the other view
// e.g. if it is on a second monitor.
canStartTimer = (!this->isWindow() && !view->isWindow() && view->isMaximized());
} else if (isMinimized()) {
}
else if (isMinimized()) {
// I am the active view but minimized
canStartTimer = true;
}
if (canStartTimer) {
int msecs = viewSettings->stopAnimatingIfDeactivated();
if (!stopSpinTimer->isActive() && msecs >= 0) { // if < 0 do not stop rotation
if (!stopSpinTimer->isActive() && msecs >= 0) { // if < 0 do not stop rotation
stopSpinTimer->setSingleShot(true);
stopSpinTimer->start(msecs);
}
} else if (stopSpinTimer->isActive()) {
}
else if (stopSpinTimer->isActive()) {
// If this view may be visible again we can stop the timer
stopSpinTimer->stop();
}
@@ -724,7 +754,7 @@ void View3DInventor::stopAnimating()
/**
* Drops the event \a e and writes the right Python command.
*/
void View3DInventor::dropEvent (QDropEvent * e)
void View3DInventor::dropEvent(QDropEvent* e)
{
const QMimeData* data = e->mimeData();
if (data->hasUrls()) {
@@ -735,14 +765,16 @@ void View3DInventor::dropEvent (QDropEvent * e)
}
}
void View3DInventor::dragEnterEvent (QDragEnterEvent * e)
void View3DInventor::dragEnterEvent(QDragEnterEvent* e)
{
// Here we must allow uri drags and check them in dropEvent
const QMimeData* data = e->mimeData();
if (data->hasUrls())
if (data->hasUrls()) {
e->accept();
else
}
else {
e->ignore();
}
}
void View3DInventor::setCurrentViewMode(ViewMode mode)
@@ -805,13 +837,7 @@ RayPickInfo View3DInventor::getObjInfoRay(Base::Vector3d* startvec, Base::Vector
// near plane clipping is required to avoid false intersections
float nearClippingPlane = 0.1F;
RayPickInfo ret = {false,
Base::Vector3d(),
"",
"",
std::nullopt,
std::nullopt,
std::nullopt};
RayPickInfo ret = {false, Base::Vector3d(), "", "", std::nullopt, std::nullopt, std::nullopt};
SoRayPickAction action(getViewer()->getSoRenderManager()->getViewportRegion());
action.setRay(SbVec3f(vsx, vsy, vsz), SbVec3f(vdx, vdy, vdz), nearClippingPlane);
action.apply(getViewer()->getSoRenderManager()->getSceneGraph());
@@ -883,7 +909,7 @@ RayPickInfo View3DInventor::getObjInfoRay(Base::Vector3d* startvec, Base::Vector
return ret;
}
void View3DInventor::keyPressEvent (QKeyEvent* e)
void View3DInventor::keyPressEvent(QKeyEvent* e)
{
// See StdViewDockUndockFullscreen::activated()
// With Qt5 one cannot directly use 'setCurrentViewMode'
@@ -894,31 +920,34 @@ void View3DInventor::keyPressEvent (QKeyEvent* e)
QMainWindow::keyPressEvent(e);
}
void View3DInventor::keyReleaseEvent (QKeyEvent* e)
void View3DInventor::keyReleaseEvent(QKeyEvent* e)
{
QMainWindow::keyReleaseEvent(e);
}
void View3DInventor::focusInEvent (QFocusEvent *)
void View3DInventor::focusInEvent(QFocusEvent*)
{
_viewer->getGLWidget()->setFocus();
}
void View3DInventor::contextMenuEvent (QContextMenuEvent*e)
void View3DInventor::contextMenuEvent(QContextMenuEvent* e)
{
MDIView::contextMenuEvent(e);
}
void View3DInventor::customEvent(QEvent * e)
void View3DInventor::customEvent(QEvent* e)
{
if (e->type() == QEvent::User) {
auto se = static_cast<NavigationStyleEvent*>(e);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View");
if (hGrp->GetBool("SameStyleForAllViews", true))
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/View"
);
if (hGrp->GetBool("SameStyleForAllViews", true)) {
hGrp->SetASCII("NavigationStyle", se->style().getName());
else
}
else {
_viewer->setNavigationType(se->style());
}
}
}