Skip to content

Commit

Permalink
+ allow to set u/v dirs for B-Spline fit
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 6, 2015
1 parent 9bb0e7f commit 94a62e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/App/Placement.cpp
Expand Up @@ -33,7 +33,7 @@
using namespace App;


PROPERTY_SOURCE(App::Placement, App::DocumentObject)
PROPERTY_SOURCE(App::Placement, App::GeoFeature)


//===========================================================================
Expand Down
22 changes: 18 additions & 4 deletions src/Mod/ReverseEngineering/Gui/FitBSplineSurface.cpp
Expand Up @@ -35,13 +35,14 @@
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/Selection.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>

#include <Base/Interpreter.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/Placement.h>


using namespace ReenGui;
Expand All @@ -65,7 +66,6 @@ FitBSplineSurfaceWidget::FitBSplineSurfaceWidget(const App::DocumentObjectT& obj
: d(new Private())
{
d->ui.setupUi(this);
d->ui.uvdir->setDisabled(true);
d->obj = obj;
restoreSettings();
}
Expand Down Expand Up @@ -139,8 +139,22 @@ bool FitBSplineSurfaceWidget::accept()
.arg(d->ui.sizeFactor->value())
;
if (d->ui.uvdir->isChecked()) {
// todo
argument += QString::fromLatin1(", UVDirs=(FreeCAD.Vector(1,0,0), FreeCAD.Vector(0,1,0))");
std::vector<App::Placement*> selection = Gui::Selection().getObjectsOfType<App::Placement>();
if (selection.size() != 1) {
QMessageBox::warning(this,
tr("Wrong selection"),
tr("Please select a single placement object to get local orientation.")
);
return false;
}

Base::Rotation rot = selection.front()->GeoFeature::Placement.getValue().getRotation();
Base::Vector3d u(1,0,0);
Base::Vector3d v(0,1,0);
rot.multVec(u, u);
rot.multVec(v, v);
argument += QString::fromLatin1(", UVDirs=(FreeCAD.Vector(%1,%2,%3), FreeCAD.Vector(%4,%5,%6))")
.arg(u.x).arg(u.y).arg(u.z).arg(v.x).arg(v.y).arg(v.z);
}
QString command = QString::fromLatin1("%1.addObject(\"Part::Spline\", \"Spline\").Shape = "
"ReverseEngineering.approxSurface(%2).toShape()")
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/ReverseEngineering/Gui/FitBSplineSurface.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<width>360</width>
<height>342</height>
</rect>
</property>
Expand Down Expand Up @@ -52,7 +52,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Number of control points</string>
<string>Control points</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
Expand Down Expand Up @@ -119,7 +119,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Number of control points</string>
<string>Control points</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
Expand Down Expand Up @@ -157,7 +157,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Maximum number of iterations</string>
<string>Iterations</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/ReverseEngineering/Gui/PreCompiled.h
Expand Up @@ -33,12 +33,14 @@
# define PartExport __declspec(dllimport)
# define MeshExport __declspec(dllimport)
# define PointsExport __declspec(dllimport)
# define AppExport __declspec(dllimport)
#else // for Linux
# define ReenExport
# define ReenGuiExport
# define PartExport
# define MeshExport
# define PointsExport
# define AppExport
#endif

#ifdef _MSC_VER
Expand Down

0 comments on commit 94a62e0

Please sign in to comment.