MeshPart: apply clang format
This commit is contained in:
@@ -22,9 +22,9 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QApplication>
|
||||
# include <QMessageBox>
|
||||
# include <QPushButton>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -52,14 +52,14 @@ using namespace std;
|
||||
DEF_STD_CMD_A(CmdMeshPartMesher)
|
||||
|
||||
CmdMeshPartMesher::CmdMeshPartMesher()
|
||||
: Command("MeshPart_Mesher")
|
||||
: Command("MeshPart_Mesher")
|
||||
{
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Create mesh from shape...");
|
||||
sToolTipText = QT_TR_NOOP("Tessellate shape");
|
||||
sWhatsThis = "MeshPart_Mesher";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Create mesh from shape...");
|
||||
sToolTipText = QT_TR_NOOP("Tessellate shape");
|
||||
sWhatsThis = "MeshPart_Mesher";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdMeshPartMesher::activated(int)
|
||||
@@ -77,13 +77,13 @@ bool CmdMeshPartMesher::isActive()
|
||||
DEF_STD_CMD_A(CmdMeshPartTrimByPlane)
|
||||
|
||||
CmdMeshPartTrimByPlane::CmdMeshPartTrimByPlane()
|
||||
: Command("MeshPart_TrimByPlane")
|
||||
: Command("MeshPart_TrimByPlane")
|
||||
{
|
||||
sAppModule = "Mesh";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Trim mesh with a plane");
|
||||
sToolTipText = QT_TR_NOOP("Trims a mesh with a plane");
|
||||
sStatusTip = QT_TR_NOOP("Trims a mesh with a plane");
|
||||
sAppModule = "Mesh";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Trim mesh with a plane");
|
||||
sToolTipText = QT_TR_NOOP("Trims a mesh with a plane");
|
||||
sStatusTip = QT_TR_NOOP("Trims a mesh with a plane");
|
||||
}
|
||||
|
||||
void CmdMeshPartTrimByPlane::activated(int)
|
||||
@@ -92,18 +92,22 @@ void CmdMeshPartTrimByPlane::activated(int)
|
||||
std::vector<App::DocumentObject*> plane = getSelection().getObjectsOfType(partType);
|
||||
if (plane.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("MeshPart_TrimByPlane", "Select plane"),
|
||||
qApp->translate("MeshPart_TrimByPlane", "Please select a plane at which you trim the mesh."));
|
||||
qApp->translate("MeshPart_TrimByPlane", "Select plane"),
|
||||
qApp->translate("MeshPart_TrimByPlane",
|
||||
"Please select a plane at which you trim the mesh."));
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox msgBox(Gui::getMainWindow());
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
msgBox.setWindowTitle(qApp->translate("MeshPart_TrimByPlane","Trim by plane"));
|
||||
msgBox.setText(qApp->translate("MeshPart_TrimByPlane","Select the side you want to keep."));
|
||||
QPushButton* inner = msgBox.addButton(qApp->translate("MeshPart_TrimByPlane","Below"), QMessageBox::ActionRole);
|
||||
QPushButton* outer = msgBox.addButton(qApp->translate("MeshPart_TrimByPlane","Above"), QMessageBox::ActionRole);
|
||||
QPushButton* split = msgBox.addButton(qApp->translate("MeshPart_TrimByPlane","Split"), QMessageBox::ActionRole);
|
||||
msgBox.setWindowTitle(qApp->translate("MeshPart_TrimByPlane", "Trim by plane"));
|
||||
msgBox.setText(qApp->translate("MeshPart_TrimByPlane", "Select the side you want to keep."));
|
||||
QPushButton* inner =
|
||||
msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Below"), QMessageBox::ActionRole);
|
||||
QPushButton* outer =
|
||||
msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Above"), QMessageBox::ActionRole);
|
||||
QPushButton* split =
|
||||
msgBox.addButton(qApp->translate("MeshPart_TrimByPlane", "Split"), QMessageBox::ActionRole);
|
||||
msgBox.addButton(QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(inner);
|
||||
msgBox.exec();
|
||||
@@ -124,12 +128,14 @@ void CmdMeshPartTrimByPlane::activated(int)
|
||||
return;
|
||||
}
|
||||
|
||||
Base::Placement plnPlacement = static_cast<App::GeoFeature*>(plane.front())->Placement.getValue();
|
||||
Base::Placement plnPlacement =
|
||||
static_cast<App::GeoFeature*>(plane.front())->Placement.getValue();
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Trim with plane"));
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> docObj =
|
||||
Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
for (auto it : docObj) {
|
||||
Base::Vector3d normal(0,0,1);
|
||||
Base::Vector3d normal(0, 0, 1);
|
||||
plnPlacement.getRotation().multVec(normal, normal);
|
||||
Base::Vector3d base = plnPlacement.getPosition();
|
||||
|
||||
@@ -167,8 +173,9 @@ void CmdMeshPartTrimByPlane::activated(int)
|
||||
bool CmdMeshPartTrimByPlane::isActive()
|
||||
{
|
||||
// Check for the selected mesh feature (all Mesh types)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -179,14 +186,14 @@ bool CmdMeshPartTrimByPlane::isActive()
|
||||
DEF_STD_CMD_A(CmdMeshPartSection)
|
||||
|
||||
CmdMeshPartSection::CmdMeshPartSection()
|
||||
: Command("MeshPart_SectionByPlane")
|
||||
: Command("MeshPart_SectionByPlane")
|
||||
{
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Create section from mesh and plane");
|
||||
sToolTipText = QT_TR_NOOP("Section");
|
||||
sWhatsThis = "MeshPart_Section";
|
||||
sStatusTip = sToolTipText;
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Create section from mesh and plane");
|
||||
sToolTipText = QT_TR_NOOP("Section");
|
||||
sWhatsThis = "MeshPart_Section";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdMeshPartSection::activated(int)
|
||||
@@ -194,19 +201,22 @@ void CmdMeshPartSection::activated(int)
|
||||
Base::Type partType = Base::Type::fromName("Part::Plane");
|
||||
std::vector<App::DocumentObject*> plane = getSelection().getObjectsOfType(partType);
|
||||
if (plane.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QMessageBox::warning(
|
||||
Gui::getMainWindow(),
|
||||
qApp->translate("MeshPart_Section", "Select plane"),
|
||||
qApp->translate("MeshPart_Section", "Please select a plane at which you section the mesh."));
|
||||
qApp->translate("MeshPart_Section",
|
||||
"Please select a plane at which you section the mesh."));
|
||||
return;
|
||||
}
|
||||
|
||||
Base::Placement plm = static_cast<App::GeoFeature*>(plane.front())->Placement.getValue();
|
||||
Base::Vector3d normal(0,0,1);
|
||||
Base::Vector3d normal(0, 0, 1);
|
||||
plm.getRotation().multVec(normal, normal);
|
||||
Base::Vector3d base = plm.getPosition();
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Section with plane"));
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> docObj =
|
||||
Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
Mesh::MeshObject::TPlane tplane;
|
||||
tplane.first = Base::convertTo<Base::Vector3f>(base);
|
||||
tplane.second = Base::convertTo<Base::Vector3f>(normal);
|
||||
@@ -251,8 +261,9 @@ void CmdMeshPartSection::activated(int)
|
||||
bool CmdMeshPartSection::isActive()
|
||||
{
|
||||
// Check for the selected mesh feature (all Mesh types)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1)
|
||||
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -263,15 +274,15 @@ bool CmdMeshPartSection::isActive()
|
||||
DEF_STD_CMD_A(CmdMeshPartCrossSections)
|
||||
|
||||
CmdMeshPartCrossSections::CmdMeshPartCrossSections()
|
||||
:Command("MeshPart_CrossSections")
|
||||
: Command("MeshPart_CrossSections")
|
||||
{
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("MeshPart");
|
||||
sMenuText = QT_TR_NOOP("Cross-sections...");
|
||||
sToolTipText = QT_TR_NOOP("Cross-sections");
|
||||
sWhatsThis = "MeshPart_CrossSections";
|
||||
sStatusTip = sToolTipText;
|
||||
//sPixmap = "MeshPart_CrossSections";
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("MeshPart");
|
||||
sMenuText = QT_TR_NOOP("Cross-sections...");
|
||||
sToolTipText = QT_TR_NOOP("Cross-sections");
|
||||
sWhatsThis = "MeshPart_CrossSections";
|
||||
sStatusTip = sToolTipText;
|
||||
// sPixmap = "MeshPart_CrossSections";
|
||||
}
|
||||
|
||||
void CmdMeshPartCrossSections::activated(int iMsg)
|
||||
@@ -279,8 +290,8 @@ void CmdMeshPartCrossSections::activated(int iMsg)
|
||||
Q_UNUSED(iMsg);
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
if (!dlg) {
|
||||
std::vector<App::DocumentObject*> obj = Gui::Selection().getObjectsOfType
|
||||
(Mesh::Feature::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> obj =
|
||||
Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
|
||||
Base::BoundBox3d bbox;
|
||||
for (auto it : obj) {
|
||||
bbox.Add(static_cast<Mesh::Feature*>(it)->Mesh.getBoundingBox());
|
||||
@@ -292,23 +303,23 @@ void CmdMeshPartCrossSections::activated(int iMsg)
|
||||
|
||||
bool CmdMeshPartCrossSections::isActive()
|
||||
{
|
||||
return (Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0 &&
|
||||
!Gui::Control().activeDialog());
|
||||
return (Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0
|
||||
&& !Gui::Control().activeDialog());
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdMeshPartCurveOnMesh)
|
||||
|
||||
CmdMeshPartCurveOnMesh::CmdMeshPartCurveOnMesh()
|
||||
: Command("MeshPart_CurveOnMesh")
|
||||
: Command("MeshPart_CurveOnMesh")
|
||||
{
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Curve on mesh...");
|
||||
sToolTipText = QT_TR_NOOP("Creates an approximated curve on top of a mesh.\n"
|
||||
"This command only works with a 'mesh' object.");
|
||||
sWhatsThis = "MeshPart_CurveOnMesh";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "MeshPart_CurveOnMesh";
|
||||
sAppModule = "MeshPart";
|
||||
sGroup = QT_TR_NOOP("Mesh");
|
||||
sMenuText = QT_TR_NOOP("Curve on mesh...");
|
||||
sToolTipText = QT_TR_NOOP("Creates an approximated curve on top of a mesh.\n"
|
||||
"This command only works with a 'mesh' object.");
|
||||
sWhatsThis = "MeshPart_CurveOnMesh";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "MeshPart_CurveOnMesh";
|
||||
}
|
||||
|
||||
void CmdMeshPartCurveOnMesh::activated(int)
|
||||
@@ -319,18 +330,21 @@ void CmdMeshPartCurveOnMesh::activated(int)
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Control().showDialog(new MeshPartGui::TaskCurveOnMesh(static_cast<Gui::View3DInventor*>(mdis.front())));
|
||||
Gui::Control().showDialog(
|
||||
new MeshPartGui::TaskCurveOnMesh(static_cast<Gui::View3DInventor*>(mdis.front())));
|
||||
}
|
||||
|
||||
bool CmdMeshPartCurveOnMesh::isActive()
|
||||
{
|
||||
if (Gui::Control().activeDialog())
|
||||
if (Gui::Control().activeDialog()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for the selected mesh feature (all Mesh types)
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
if (doc && doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0)
|
||||
if (doc && doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -338,7 +352,7 @@ bool CmdMeshPartCurveOnMesh::isActive()
|
||||
|
||||
void CreateMeshPartCommands()
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
rcCmdMgr.addCommand(new CmdMeshPartMesher());
|
||||
rcCmdMgr.addCommand(new CmdMeshPartTrimByPlane());
|
||||
rcCmdMgr.addCommand(new CmdMeshPartSection());
|
||||
|
||||
Reference in New Issue
Block a user