Add SolidWorks navigation style (#19568)

This commit is contained in:
theepicviolin
2025-02-24 08:57:00 -08:00
committed by GitHub
parent 8ea4046685
commit 38797d1fa4
12 changed files with 709 additions and 0 deletions

View File

@@ -366,6 +366,8 @@ SET(TechDrawGuiNav_SRCS
QGVNavStyleOpenSCAD.h
QGVNavStyleRevit.cpp
QGVNavStyleRevit.h
QGVNavStyleSolidWorks.cpp
QGVNavStyleSolidWorks.h
QGVNavStyleTinkerCAD.cpp
QGVNavStyleTinkerCAD.h
QGVNavStyleTouchpad.cpp

View File

@@ -0,0 +1,127 @@
/***************************************************************************
* Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QGuiApplication>
# include <QMouseEvent>
#endif
#include "QGVNavStyleSolidWorks.h"
#include "QGVPage.h"
using namespace TechDrawGui;
namespace TechDrawGui {
QGVNavStyleSolidWorks::QGVNavStyleSolidWorks(QGVPage* qgvp) :
QGVNavStyle(qgvp)
{
}
QGVNavStyleSolidWorks::~QGVNavStyleSolidWorks()
{
}
void QGVNavStyleSolidWorks::handleKeyReleaseEvent(QKeyEvent *event)
{
// zoom mode 2
if ((event->key() == Qt::Key_Shift) && zoomingActive) {
stopZoom();
event->accept();
}
}
void QGVNavStyleSolidWorks::handleMousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event)
// Base::Console().Message("QGVNSSolidWorks::handleMousePressEvent() - button: %d buttons: %d\n", event->button(), event->buttons());
}
void QGVNavStyleSolidWorks::handleMouseMoveEvent(QMouseEvent *event)
{
if (getViewer()->isBalloonPlacing()) {
balloonCursorMovement(event);
return;
}
if ((QGuiApplication::mouseButtons() & Qt::MiddleButton) &&
QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier) ) {
//zoom mode 2 Shift + MMB
if (zoomingActive) {
zoom(mouseZoomFactor(event->pos()));
} else {
startZoom(event->pos());
}
event->accept();
} else if ((QGuiApplication::mouseButtons() & Qt::MiddleButton) &&
QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier) ) {
// pan mode 1 - Ctrl + MMB
// I think this block may be unnecessary since pan mode 2 MMB also captures pan mode 1
// Ctrl + MMB, but I'll leave it in to make it clear that this is what's intended
// also nav style OCC has a similar block
if (panningActive) {
pan(event->pos());
} else {
startPan(event->pos());
}
event->accept();
} else if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
// pan mode 2 - MMB
if (panningActive) {
pan(event->pos());
} else {
startPan(event->pos());
}
event->accept();
}
}
void QGVNavStyleSolidWorks::handleMouseReleaseEvent(QMouseEvent *event)
{
// Base::Console().Message("QGVNSSolidWorks::handleMouseReleaseEvent() - button: %d buttons: %d\n", event->button(), event->buttons());
if (getViewer()->isBalloonPlacing()) {
placeBalloon(event->pos());
}
if (panningActive) {
if (event->button() == Qt::MiddleButton) {
//pan mode 1 or 2 - [Control] + MMB
//stop panning if MMB released
if (panningActive) {
stopPan();
event->accept();
}
//zoom mode 2 Shift + MMB
//stop zooming if MMB released
if (zoomingActive) {
stopZoom();
event->accept();
}
}
}
}
} // namespace TechDrawGui

View File

@@ -0,0 +1,52 @@
/***************************************************************************
* Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef TECHDRAW_SOLIDWORKSNAVSTYLE_H
#define TECHDRAW_SOLIDWORKSNAVSTYLE_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include "QGVNavStyle.h"
namespace TechDrawGui {
class QGVPage;
class TechDrawGuiExport QGVNavStyleSolidWorks : public QGVNavStyle
{
public:
explicit QGVNavStyleSolidWorks(QGVPage* qgvp);
~QGVNavStyleSolidWorks() override;
void handleKeyReleaseEvent(QKeyEvent *event) override;
void handleMousePressEvent(QMouseEvent *event) override;
void handleMouseMoveEvent(QMouseEvent *event) override;
void handleMouseReleaseEvent(QMouseEvent *event) override;
protected:
private:
};
}
#endif // TECHDRAW_SOLIDWORKSNAVSTYLE_H

View File

@@ -59,6 +59,7 @@
#include "QGVNavStyleOCC.h"
#include "QGVNavStyleOpenSCAD.h"
#include "QGVNavStyleRevit.h"
#include "QGVNavStyleSolidWorks.h"
#include "QGVNavStyleTinkerCAD.h"
#include "QGVNavStyleTouchpad.h"
#include "QGVPage.h"
@@ -246,6 +247,7 @@ void QGVPage::setNavigationStyle(std::string navParm)
std::size_t foundOCC = navParm.find("OpenCascade");
std::size_t foundOpenSCAD = navParm.find("OpenSCAD");
std::size_t foundRevit = navParm.find("Revit");
std::size_t foundSolidWorks = navParm.find("SolidWorks");
if (foundBlender != std::string::npos) {
m_navStyle = static_cast<QGVNavStyle*>(new QGVNavStyleBlender(this));
@@ -277,6 +279,9 @@ void QGVPage::setNavigationStyle(std::string navParm)
else if (foundRevit != std::string::npos) {
m_navStyle = static_cast<QGVNavStyle*>(new QGVNavStyleRevit(this));
}
else if (foundSolidWorks != std::string::npos) {
m_navStyle = static_cast<QGVNavStyle*>(new QGVNavStyleSolidWorks(this));
}
else {
m_navStyle = new QGVNavStyle(this);
}

View File

@@ -76,6 +76,7 @@ def RePopulateIcons():
a8.setIcon(QtGui.QIcon(":/icons/NavigationRevit_" + StyleSheetType + ".svg"))
a9.setIcon(QtGui.QIcon(":/icons/NavigationTinkerCAD_" + StyleSheetType + ".svg"))
a10.setIcon(QtGui.QIcon(":/icons/NavigationTouchpad_" + StyleSheetType + ".svg"))
a11.setIcon(QtGui.QIcon(":/icons/NavigationSolidWorks_" + StyleSheetType + ".svg"))
def retranslateUi():
@@ -566,6 +567,44 @@ def retranslateUi():
+ "</p>"
)
global t11
t11 = (
"<p align='center'><b>SolidWorks</b> "
+ text06
+ """</p>
<table>
<tr>
<th><small>"""
+ text01
+ """</small></th>
<th><small>"""
+ text02
+ """</small></th>
<th><small>"""
+ text02
+ """</small></th>
<th><small>"""
+ text03
+ """</small></th>
<th><small>"""
+ text04
+ """</small></th>
</tr>
<tr>
<td align='center'><img src=':/icons/Navigation_Mouse_Left.svg'></td>
<td align='center'><img src=':/icons/Navigation_Mouse_Scroll.svg'></td>
<td align='center'><img src=':/icons/Navigation_Mouse_ShiftMiddle.svg'></td>
<td align='center'><img src=':/icons/Navigation_Mouse_Middle.svg'></td>
<td align='center'><img src=':/icons/Navigation_Mouse_CtrlMiddle.svg'></td>
</tr>
</table>
<b>"""
+ text08
+ ":</b> "
+ text10
+ "</small></p>"
)
menuSettings.setTitle(translate("NavigationIndicator", "Settings"))
menuOrbit.setTitle(translate("NavigationIndicator", "Orbit style"))
aCompact.setText(translate("NavigationIndicator", "Compact"))
@@ -670,6 +709,11 @@ a10.setText("Touchpad ")
a10.setData("Gui::TouchpadNavigationStyle")
a10.setObjectName("Indicator_NavigationTouchpad")
a11 = QtGui.QAction(gStyle)
a11.setText("SolidWorks ")
a11.setData("Gui::SolidWorksNavigationStyle")
a11.setObjectName("Indicator_NavigationSolidWorks")
RePopulateIcons()
menu.addMenu(menuSettings)
@@ -685,6 +729,7 @@ menu.addAction(a7)
menu.addAction(a8)
menu.addAction(a9)
menu.addAction(a10)
menu.addAction(a11)
pView.Attach(indicator)
@@ -725,6 +770,7 @@ def onTooltip():
a8.setToolTip(t8)
a9.setToolTip(t9)
a10.setToolTip(t10)
a11.setToolTip(t11)
p.SetBool("Tooltip", 1)
else:
for i in gStyle.actions():

View File

@@ -47,6 +47,8 @@
<file>icons/NavigationOpenSCAD_dark.svg</file>
<file>icons/NavigationRevit_light.svg</file>
<file>icons/NavigationRevit_dark.svg</file>
<file>icons/NavigationSolidWorks_light.svg</file>
<file>icons/NavigationSolidWorks_dark.svg</file>
<file>icons/NavigationTinkerCAD_light.svg</file>
<file>icons/NavigationTinkerCAD_dark.svg</file>
<file>icons/NavigationTouchpad_light.svg</file>

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
id="svg2"
height="64"
width="64"
version="1.1"
viewBox="0 0 63.999999 63.999999"
sodipodi:docname="NavigationSW_dark.svg"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#999999"
borderopacity="1"
inkscape:showpageshadow="2"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="12.546875"
inkscape:cx="31.960149"
inkscape:cy="32.039851"
inkscape:window-width="1290"
inkscape:window-height="991"
inkscape:window-x="26"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<defs
id="defs1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(0 -988.36)"
stroke="#d1cbc9"
stroke-width="6"
fill="none"
style="stroke:#2e3436;stroke-opacity:1">
<path
id="path4144"
d="m16 1028.4v-20c0-8 4-12 16-12s16 4 16 12v20c0 8-4 17-16 17s-16-9-16-17z"
style="stroke:#2e3436;stroke-opacity:1" />
<path
id="path4209"
d="m32 1004.4v12"
style="stroke:#2e3436;stroke-opacity:1" />
</g>
<text
xml:space="preserve"
style="fill:#d1cbc9;stroke:#2e3436;stroke-width:1.249;stroke-dasharray:none;stroke-opacity:1"
x="22.540596"
y="42.368313"
id="text1"><tspan
x="22.540596"
y="42.368313"
id="tspan2"
style="stroke:#2e3436;stroke-opacity:1">SW</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
id="svg2"
height="64"
width="64"
version="1.1"
viewBox="0 0 63.999999 63.999999"
sodipodi:docname="NavigationSW_light.svg"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#999999"
borderopacity="1"
inkscape:showpageshadow="2"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="12.546875"
inkscape:cx="31.960149"
inkscape:cy="32"
inkscape:window-width="1920"
inkscape:window-height="1014"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<defs
id="defs1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(0 -988.36)"
stroke="#d1cbc9"
stroke-width="6"
fill="none">
<path
id="path4144"
d="m16 1028.4v-20c0-8 4-12 16-12s16 4 16 12v20c0 8-4 17-16 17s-16-9-16-17z" />
<path
id="path4209"
d="m32 1004.4v12" />
</g>
<text
xml:space="preserve"
style="fill:#d1cbc9;stroke:#d1cbc9;stroke-width:1.249;stroke-dasharray:none"
x="22.540596"
y="42.368313"
id="text1"><tspan
x="22.540596"
y="42.368313"
id="tspan2">SW</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB