0001591: STL export in various units

This commit is contained in:
wmayer
2017-09-30 23:55:49 +02:00
parent 22bc50aa00
commit fc280ae1e8
2 changed files with 51 additions and 2 deletions

View File

@@ -1651,6 +1651,53 @@ bool CmdMeshMerge::isActive(void)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) >= 2;
}
//--------------------------------------------------------------------------------------
DEF_STD_CMD_A(CmdMeshScale)
CmdMeshScale::CmdMeshScale()
: Command("Mesh_Scale")
{
sAppModule = "Mesh";
sGroup = QT_TR_NOOP("Mesh");
sMenuText = QT_TR_NOOP("Scale...");
sToolTipText = QT_TR_NOOP("Scale selected meshes");
sWhatsThis = "Mesh_Scale";
sStatusTip = sToolTipText;
}
void CmdMeshScale::activated(int)
{
App::Document *pcDoc = App::GetApplication().getActiveDocument();
if (!pcDoc)
return;
bool ok;
double factor = QInputDialog::getDouble(Gui::getMainWindow(), QObject::tr("Scaling"),
QObject::tr("Enter scaling factor:"), 1, 0, DBL_MAX, 5, &ok);
if (!ok || factor == 0)
return;
openCommand("Mesh scale");
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
Base::Matrix4D mat;
mat.scale(factor,factor,factor);
for (std::vector<App::DocumentObject*>::const_iterator it = objs.begin(); it != objs.end(); ++it) {
MeshObject* mesh = static_cast<Mesh::Feature*>(*it)->Mesh.startEditing();
MeshCore::MeshKernel& kernel = mesh->getKernel();
kernel.Transform(mat);
static_cast<Mesh::Feature*>(*it)->Mesh.finishEditing();
}
updateActive();
commitCommand();
}
bool CmdMeshScale::isActive(void)
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
}
void CreateMeshCommands(void)
{
@@ -1689,4 +1736,5 @@ void CreateMeshCommands(void)
rcCmdMgr.addCommand(new CmdMeshFromPartShape());
rcCmdMgr.addCommand(new CmdMeshSegmentation());
rcCmdMgr.addCommand(new CmdMeshMerge());
rcCmdMgr.addCommand(new CmdMeshScale());
}

View File

@@ -188,8 +188,9 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*mesh << "Mesh_Import" << "Mesh_Export" << "Mesh_FromPartShape" << "Separator"
<< analyze << "Mesh_HarmonizeNormals" << "Mesh_FlipNormals" << "Separator"
<< "Mesh_FillupHoles" << "Mesh_FillInteractiveHole" << "Mesh_RemoveComponents"
<< "Mesh_RemoveCompByHand" << "Mesh_AddFacet" << "Mesh_Smoothing" << "Separator"
<< "Mesh_BuildRegularSolid" << boolean << "Separator" << "Mesh_Merge" << "Mesh_PolySelect" << "Mesh_PolyCut"
<< "Mesh_RemoveCompByHand" << "Mesh_AddFacet" << "Mesh_Smoothing" << "Mesh_Scale"
<< "Separator" << "Mesh_BuildRegularSolid" << boolean << "Separator"
<< "Mesh_Merge" << "Mesh_PolySelect" << "Mesh_PolyCut"
<< "Mesh_PolySplit" << "Mesh_PolySegm" << "Mesh_PolyTrim" << "Separator"
<< "Mesh_TrimByPlane" << "Mesh_SectionByPlane" << "Mesh_Segmentation"
<< "Mesh_VertexCurvature";