[Part] feature to make persistent section cut views (#4118)
* [Part] feature to make persistent section cut views * one aim is to have a feature to make real cuts, not hollow ones like with clipping * the second one is to have a persistent view, so an object in the tree that can be further exported, meshed etc. For a detailed description with examples see https://forum.freecadweb.org/viewtopic.php?f=17&t=52441
This commit is contained in:
@@ -651,7 +651,7 @@ MenuItem* StdWorkbench::setupMenuBar() const
|
||||
*view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Std_MainFullscreen" << "Separator"
|
||||
<< stdviews << "Std_FreezeViews" << "Std_DrawStyle" << "Std_SelBoundingBox"
|
||||
<< "Separator" << view3d << zoom
|
||||
<< "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane"
|
||||
<< "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane" << "Part_SectionCut"
|
||||
<< "Std_TextureMapping"
|
||||
#ifdef BUILD_VR
|
||||
<< "Std_ViewVR"
|
||||
|
||||
@@ -63,6 +63,7 @@ set(PartGui_UIC_SRCS
|
||||
DlgSettingsGeneral.ui
|
||||
DlgSettingsObjectColor.ui
|
||||
DlgProjectionOnSurface.ui
|
||||
SectionCutting.ui
|
||||
ShapeFromMesh.ui
|
||||
TaskFaceColors.ui
|
||||
TaskShapeBuilder.ui
|
||||
@@ -210,6 +211,9 @@ SET(PartGui_SRCS
|
||||
Workbench.h
|
||||
ReferenceHighlighter.cpp
|
||||
ReferenceHighlighter.h
|
||||
SectionCutting.cpp
|
||||
SectionCutting.h
|
||||
SectionCutting.ui
|
||||
ShapeFromMesh.cpp
|
||||
ShapeFromMesh.h
|
||||
TaskFaceColors.cpp
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
#include "DlgProjectionOnSurface.h"
|
||||
#include "DlgRevolution.h"
|
||||
#include "Mirroring.h"
|
||||
#include "SectionCutting.h"
|
||||
#include "TaskCheckGeometry.h"
|
||||
#include "TaskDimension.h"
|
||||
#include "TaskLoft.h"
|
||||
@@ -2468,6 +2469,69 @@ bool CmdPartProjectionOnSurface::isActive(void)
|
||||
return (hasActiveDocument() && !Gui::Control().activeDialog());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Part_SectionCut
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_AC(CmdPartSectionCut)
|
||||
|
||||
CmdPartSectionCut::CmdPartSectionCut()
|
||||
: Command("Part_SectionCut")
|
||||
{
|
||||
sAppModule = "Part";
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Persistent section cut");
|
||||
sToolTipText = QT_TR_NOOP("Creates a persistent section cut of visible part objects");
|
||||
sWhatsThis = "Part_SectionCut";
|
||||
sStatusTip = sToolTipText;
|
||||
eType = Alter3DView;
|
||||
}
|
||||
|
||||
Gui::Action* CmdPartSectionCut::createAction(void)
|
||||
{
|
||||
Gui::Action* pcAction = (Gui::Action*)Gui::Command::createAction();
|
||||
#if 0
|
||||
pcAction->setCheckable(true);
|
||||
#endif
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
void CmdPartSectionCut::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
static QPointer<PartGui::SectionCut> sectionCut = nullptr;
|
||||
if (!sectionCut) {
|
||||
Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>(Gui::getMainWindow()->activeWindow());
|
||||
if (view) {
|
||||
sectionCut = PartGui::SectionCut::makeDockWidget(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdPartSectionCut::isActive(void)
|
||||
{
|
||||
#if 0
|
||||
Gui::View3DInventor* view = qobject_cast<View3DInventor*>(Gui::getMainWindow()->activeWindow());
|
||||
if (view) {
|
||||
Gui::Action* action = qobject_cast<Action*>(_pcAction);
|
||||
if (action->isChecked() != view->hasClippingPlane())
|
||||
action->setChecked(view->hasClippingPlane());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Gui::Action* action = qobject_cast<Action*>(_pcAction);
|
||||
if (action->isChecked())
|
||||
action->setChecked(false);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>(Gui::getMainWindow()->activeWindow());
|
||||
return view ? true : false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void CreatePartCommands(void)
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
@@ -2518,4 +2582,5 @@ void CreatePartCommands(void)
|
||||
rcCmdMgr.addCommand(new CmdMeasureToggleDelta());
|
||||
rcCmdMgr.addCommand(new CmdBoxSelection());
|
||||
rcCmdMgr.addCommand(new CmdPartProjectionOnSurface());
|
||||
rcCmdMgr.addCommand(new CmdPartSectionCut());
|
||||
}
|
||||
|
||||
1475
src/Mod/Part/Gui/SectionCutting.cpp
Normal file
1475
src/Mod/Part/Gui/SectionCutting.cpp
Normal file
File diff suppressed because it is too large
Load Diff
86
src/Mod/Part/Gui/SectionCutting.h
Normal file
86
src/Mod/Part/Gui/SectionCutting.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2022 Uwe Stöhr <uwestoehr@lyx.org> *
|
||||
* *
|
||||
* 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 PARTGUI_SECTIONCUTTING_H
|
||||
#define PARTGUI_SECTIONCUTTING_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
namespace Gui { class View3DInventor; }
|
||||
|
||||
namespace PartGui {
|
||||
|
||||
class Ui_SectionCut;
|
||||
|
||||
class SectionCut : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static SectionCut* makeDockWidget(Gui::View3DInventor*);
|
||||
SectionCut(Gui::View3DInventor* view, QWidget* parent = nullptr);
|
||||
~SectionCut();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onGroupBoxXtoggled();
|
||||
void onGroupBoxYtoggled();
|
||||
void onGroupBoxZtoggled();
|
||||
void onCutXvalueChanged(double);
|
||||
void onCutYvalueChanged(double);
|
||||
void onCutZvalueChanged(double);
|
||||
void onCutXHSsliderMoved(int);
|
||||
void onCutYHSsliderMoved(int);
|
||||
void onCutZHSsliderMoved(int);
|
||||
void onFlipXclicked();
|
||||
void onFlipYclicked();
|
||||
void onFlipZclicked();
|
||||
void onRefreshCutPBclicked();
|
||||
|
||||
public:
|
||||
void reject();
|
||||
|
||||
private:
|
||||
Ui_SectionCut* ui;
|
||||
std::vector<App::DocumentObject*> ObjectsListVisible;
|
||||
App::Document* doc; //pointer to active document
|
||||
bool hasBoxX = false;
|
||||
bool hasBoxY = false;
|
||||
bool hasBoxZ = false;
|
||||
bool hasBoxCustom = false;
|
||||
void noDocumentActions();
|
||||
void startCutting(bool isInitial = false);
|
||||
SbBox3f getViewBoundingBox();
|
||||
void refreshCutRanges(SbBox3f, bool forXValue = true, bool forYValue = true, bool forZValue = true,
|
||||
bool forXRange = true, bool forYRange = true, bool forZRange = true);
|
||||
const char* CompoundName = "SectionCutCompound";
|
||||
const char* BoxXName = "SectionCutBoxX";
|
||||
const char* BoxYName = "SectionCutBoxY";
|
||||
const char* BoxZName = "SectionCutBoxZ";
|
||||
const char* CutXName = "SectionCutX";
|
||||
const char* CutYName = "SectionCutY";
|
||||
const char* CutZName = "SectionCutZ";
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
#endif // PARTGUI_SECTIONCUTTING_H
|
||||
331
src/Mod/Part/Gui/SectionCutting.ui
Normal file
331
src/Mod/Part/Gui/SectionCutting.ui
Normal file
@@ -0,0 +1,331 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PartGui::SectionCut</class>
|
||||
<widget class="QDialog" name="PartGui::SectionCut">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>233</width>
|
||||
<height>340</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>450</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Permanent Section Cutting</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBoxX">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Cutting X</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="cutX">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="flipX">
|
||||
<property name="text">
|
||||
<string>Flip</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QSlider" name="cutXHS">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="sliderPosition">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="RefreshCutPB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refreshes the list of visible objects</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh view</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBoxY">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Cutting Y</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="cutY">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="flipY">
|
||||
<property name="text">
|
||||
<string>Flip</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QSlider" name="cutYHS">
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="4">
|
||||
<widget class="QCheckBox" name="keepOnlyCutCB">
|
||||
<property name="toolTip">
|
||||
<string>When the dialog is closed,
|
||||
only created cuts will be visible</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Keep only cuts visible when closing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBoxZ">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Cutting Z</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="cutZ">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="flipZ">
|
||||
<property name="text">
|
||||
<string>Flip</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QSlider" name="cutZHS">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>groupBoxX</tabstop>
|
||||
<tabstop>cutX</tabstop>
|
||||
<tabstop>flipX</tabstop>
|
||||
<tabstop>groupBoxY</tabstop>
|
||||
<tabstop>cutY</tabstop>
|
||||
<tabstop>flipY</tabstop>
|
||||
<tabstop>groupBoxZ</tabstop>
|
||||
<tabstop>cutZ</tabstop>
|
||||
<tabstop>flipZ</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PartGui::SectionCut</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user