fill type radio buttons - incomplete
I tried to implement a dialog with fill type radio buttons, but no success yet.
This commit is contained in:
@@ -19,6 +19,7 @@ set(Surface_LIBS
|
||||
)
|
||||
|
||||
SET(Surface_SRCS
|
||||
../FillType.h
|
||||
AppSurface.cpp
|
||||
AppSurfacePy.cpp
|
||||
PreCompiled.cpp
|
||||
|
||||
@@ -30,14 +30,12 @@
|
||||
#include <GeomFill_BezierCurves.hxx>
|
||||
#include <Geom_BoundedSurface.hxx>
|
||||
#include "Mod/Part/App/PartFeature.h"
|
||||
#include "../FillType.h"
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
|
||||
enum filltype_t
|
||||
{
|
||||
StretchStyle = 1, CoonsStyle, CurvedStyle
|
||||
};
|
||||
|
||||
|
||||
class BSurf : public Part::Feature
|
||||
{
|
||||
|
||||
9
src/Mod/Surface/FillType.h
Normal file
9
src/Mod/Surface/FillType.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef SURFACE_FILLTYPE_H
|
||||
#define SURFACE_FILLTYPE_H
|
||||
|
||||
enum filltype_t
|
||||
{
|
||||
StretchStyle = 1, CoonsStyle, CurvedStyle
|
||||
};
|
||||
|
||||
#endif // SURAFCE_FILLTYPE_H
|
||||
187
src/Mod/Surface/Gui/BSurf.cpp
Normal file
187
src/Mod/Surface/Gui/BSurf.cpp
Normal file
@@ -0,0 +1,187 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Balázs Bámer *
|
||||
* *
|
||||
* 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 <Standard_math.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <cfloat>
|
||||
# include <QFuture>
|
||||
# include <QFutureWatcher>
|
||||
# include <QtConcurrentMap>
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include "BSurf.h"
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Base/Sequencer.h>
|
||||
|
||||
using namespace SurfaceGui;
|
||||
//#undef CS_FUTURE // multi-threading causes some problems
|
||||
|
||||
namespace SurfaceGui {
|
||||
|
||||
class ViewProviderBSurf : public Gui::ViewProvider
|
||||
{
|
||||
public:
|
||||
ViewProviderBSurf()
|
||||
{
|
||||
/* coords = new SoCoordinate3();
|
||||
coords->ref();
|
||||
planes = new SoLineSet();
|
||||
planes->ref();
|
||||
SoBaseColor* color = new SoBaseColor();
|
||||
color->rgb.setValue(1.0f, 0.447059f, 0.337255f);
|
||||
SoDrawStyle* style = new SoDrawStyle();
|
||||
style->lineWidth.setValue(2.0f);
|
||||
this->pcRoot->addChild(color);
|
||||
this->pcRoot->addChild(style);
|
||||
this->pcRoot->addChild(coords);
|
||||
this->pcRoot->addChild(planes);*/
|
||||
}
|
||||
|
||||
~ViewProviderBSurf()
|
||||
{
|
||||
}
|
||||
|
||||
void updateData(const App::Property*)
|
||||
{
|
||||
}
|
||||
|
||||
const char* getDefaultDisplayMode() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> getDisplayModes(void) const
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
/* void setCoords(const std::vector<Base::Vector3f>& v)
|
||||
{
|
||||
}*/
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
BSurf::BSurf(const Base::BoundBox3d& bb, QWidget* parent, Qt::WFlags fl)
|
||||
: QDialog(parent, fl), bbox(bb)
|
||||
{
|
||||
ui = new Ui_DlgBSurf();
|
||||
ui->setupUi(this);
|
||||
vp = new ViewProviderBSurf();
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
BSurf::~BSurf()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
delete ui;
|
||||
delete vp;
|
||||
}
|
||||
|
||||
filltype_t BSurf::getFillType() const
|
||||
{
|
||||
if (ui->fillType_stretch->isChecked())
|
||||
return StretchStyle;
|
||||
else if (ui->fillType_coons->isChecked())
|
||||
return CoonsStyle;
|
||||
else
|
||||
return CurvedStyle;
|
||||
}
|
||||
|
||||
void BSurf::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QDialog::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void BSurf::accept()
|
||||
{
|
||||
apply();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void BSurf::apply()
|
||||
{
|
||||
printf("apply\n");
|
||||
// std::vector<App::DocumentObject*> obj = Gui::Selection().
|
||||
// getObjectsOfType(Part::Feature::getClassTypeId());
|
||||
////////////////
|
||||
}
|
||||
|
||||
void BSurf::on_fillType_stretch_clicked()
|
||||
{
|
||||
}
|
||||
|
||||
void BSurf::on_fillType_coons_clicked()
|
||||
{
|
||||
}
|
||||
|
||||
void BSurf::on_fillType_curved_clicked()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
TaskBSurf::TaskBSurf(const Base::BoundBox3d& bb)
|
||||
{
|
||||
widget = new BSurf(bb);
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
NULL,
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskBSurf::~TaskBSurf()
|
||||
{
|
||||
// automatically deleted in the sub-class
|
||||
}
|
||||
|
||||
bool TaskBSurf::accept()
|
||||
{
|
||||
widget->accept();
|
||||
return (widget->result() == QDialog::Accepted);
|
||||
}
|
||||
|
||||
void TaskBSurf::clicked(int id)
|
||||
{
|
||||
if (id == QDialogButtonBox::Apply) {
|
||||
widget->apply();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#include "moc_BSurf.cpp"
|
||||
97
src/Mod/Surface/Gui/BSurf.h
Normal file
97
src/Mod/Surface/Gui/BSurf.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Balázs Bámer *
|
||||
* *
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
// Part::CrossSections.*
|
||||
|
||||
#ifndef SURFACE_GUI_BSURF_H
|
||||
#define SURFACE_GUI_BSURF_H
|
||||
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Base/BoundBox.h>
|
||||
#include <QDialog>
|
||||
#include <QPointer>
|
||||
#include "../FillType.h"
|
||||
#include "ui_BSurf.h"
|
||||
|
||||
namespace SurfaceGui
|
||||
{
|
||||
class ViewProviderBSurf;
|
||||
|
||||
class BSurf : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
filltype_t fillType;
|
||||
|
||||
public:
|
||||
BSurf(const Base::BoundBox3d& bb, QWidget* parent = 0, Qt::WFlags fl = 0);
|
||||
~BSurf();
|
||||
void accept();
|
||||
void apply();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_fillType_stretch_clicked();
|
||||
void on_fillType_coons_clicked();
|
||||
void on_fillType_curved_clicked();
|
||||
filltype_t getFillType() const;
|
||||
|
||||
/* private:
|
||||
std::vector<double> getPlanes() const;
|
||||
void calcPlane(Plane, double);
|
||||
void calcPlanes(Plane);
|
||||
void makePlanes(Plane, const std::vector<double>&, double[4]);
|
||||
Plane plane() const;*/
|
||||
|
||||
private:
|
||||
Ui_DlgBSurf* ui;
|
||||
Base::BoundBox3d bbox;
|
||||
ViewProviderBSurf* vp;
|
||||
// QPointer<Gui::View3DInventor> view;
|
||||
};
|
||||
|
||||
class TaskBSurf : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskBSurf(const Base::BoundBox3d& bb);
|
||||
~TaskBSurf();
|
||||
|
||||
public:
|
||||
bool accept();
|
||||
void clicked(int id);
|
||||
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons() const
|
||||
{ return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel; }
|
||||
|
||||
private:
|
||||
BSurf* widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace Surface
|
||||
|
||||
#endif // SURFACE_GUI_BSURF_H
|
||||
64
src/Mod/Surface/Gui/BSurf.ui
Normal file
64
src/Mod/Surface/Gui/BSurf.ui
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SurfaceGui::DlgBSurf</class>
|
||||
<widget class="QDialog" name="SurfaceGui::DlgBSurf">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>277</width>
|
||||
<height>144</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Placement</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="fillTypes">
|
||||
<property name="title">
|
||||
<string>Fill type:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="fillType_coons">
|
||||
<property name="text">
|
||||
<string>Coons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="fillType_stretch">
|
||||
<property name="text">
|
||||
<string>Stretch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="fillType_curved">
|
||||
<property name="text">
|
||||
<string>Curved</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -24,10 +24,25 @@ set(SurfaceGui_LIBS
|
||||
FreeCADGui
|
||||
)
|
||||
|
||||
qt4_add_resources(Surface_QRC_SRCS Resources/Surface.qrc)
|
||||
set(SurfaceGui_MOC_HDRS
|
||||
BSurf.h
|
||||
)
|
||||
fc_wrap_cpp(SurfaceGui_MOC_SRCS ${SurfaceGui_MOC_HDRS})
|
||||
SOURCE_GROUP("Moc" FILES ${SurfaceGui_MOC_SRCS})
|
||||
|
||||
qt4_add_resources(SurfaceGui_QRC_SRCS Resources/Surface.qrc)
|
||||
|
||||
SET(SurfaceGui_UIC_SRCS
|
||||
BSurf.ui
|
||||
)
|
||||
qt4_wrap_ui(SurfaceGui_UIC_HDRS ${SurfaceGui_UIC_SRCS})
|
||||
|
||||
SET(SurfaceGui_SRCS
|
||||
${Surface_QRC_SRCS}
|
||||
${SurfaceGui_QRC_SRCS}
|
||||
${SurfaceGui_UIC_HDRS}
|
||||
BSurf.cpp
|
||||
BSurf.h
|
||||
../FillType.h
|
||||
AppSurfaceGui.cpp
|
||||
AppSurfaceGuiPy.cpp
|
||||
Command.cpp
|
||||
|
||||
@@ -240,6 +240,8 @@ CmdSurfaceBSpline::CmdSurfaceBSpline()
|
||||
|
||||
void CmdSurfaceBSpline::activated(int iMsg)
|
||||
{
|
||||
/* Gui::Dialog::TaskPlacement* plm = new Gui::Dialog::TaskPlacement();
|
||||
Gui::Control().showDialog(plm);*/
|
||||
/*if (!isActive()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select 2, 3 or 4 curves, please."));
|
||||
@@ -259,6 +261,7 @@ void CmdSurfaceBSpline::activated(int iMsg)
|
||||
openCommand("Create BSpline surface");
|
||||
doCommand(Doc,"FreeCAD.ActiveDocument.addObject(\"Surface::BSplineSurf\",\"%s\")", FeatName.c_str());
|
||||
doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.filltype=1"); // TODO ask filltype from user and check it
|
||||
doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str());
|
||||
runCommand(Doc, bspListCmd.str().c_str());
|
||||
updateActive();
|
||||
commitCommand();
|
||||
|
||||
Reference in New Issue
Block a user