Extend task panel for filling function

This commit is contained in:
wmayer
2017-04-22 14:46:26 +02:00
parent a76ebbcec9
commit 0335e2a21c
6 changed files with 136 additions and 149 deletions

View File

@@ -14,7 +14,7 @@
height="16px"
id="svg2985"
version="1.1"
inkscape:version="0.48.5 r10040"
inkscape:version="0.48.4 r9939"
sodipodi:docname="edit-cleartext.svg">
<defs
id="defs2987">
@@ -1221,10 +1221,10 @@
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:object-nodes="false"
inkscape:window-width="1920"
inkscape:window-height="1053"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-width="2560"
inkscape:window-height="1378"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1" />
<metadata
id="metadata2990">
@@ -1244,7 +1244,7 @@
inkscape:groupmode="layer">
<g
id="g4386"
transform="translate(0,-1.1749765)">
transform="translate(0.06370962,0.2266352)">
<path
inkscape:connector-curvature="0"
id="rect4266-0"

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -478,7 +478,7 @@ ClearLineEdit::ClearLineEdit (QWidget * parent)
.arg(clearButton->sizeHint().width() + frameWidth + 1));
QSize msz = minimumSizeHint();
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2),
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
msz.height());
}
void ClearLineEdit::resizeEvent(QResizeEvent *)

View File

@@ -110,6 +110,12 @@ void Filling::addConstraints(BRepFill_Filling& builder,
auto face_sub = faces.getSubValues();
auto contvals = orders.getValues();
// tmp. workaround
if (edge_obj.size() != contvals.size()) {
contvals.resize(edge_obj.size());
std::fill(contvals.begin(), contvals.end(), static_cast<long>(GeomAbs_C0));
}
if (edge_obj.size() == edge_sub.size() &&
edge_obj.size() == contvals.size()) {
for (std::size_t index = 0; index < edge_obj.size(); index++) {

View File

@@ -103,9 +103,8 @@ QIcon ViewProviderFilling::getIcon(void) const
void ViewProviderFilling::highlightReferences(bool on)
{
#if 0
Surface::Filling* surface = static_cast<Surface::Filling*>(getObject());
auto bounds = surface->BoundaryList.getSubListValues();
auto bounds = surface->Border.getSubListValues();
for (auto it : bounds) {
Part::Feature* base = dynamic_cast<Part::Feature*>(it.first);
if (base) {
@@ -132,7 +131,6 @@ void ViewProviderFilling::highlightReferences(bool on)
}
}
}
#endif
}
// ----------------------------------------------------------------------------
@@ -140,49 +138,69 @@ void ViewProviderFilling::highlightReferences(bool on)
class FillingPanel::ShapeSelection : public Gui::SelectionFilterGate
{
public:
ShapeSelection(bool appendEdges, Surface::Filling* editedObject)
ShapeSelection(FillingPanel::SelectionMode mode, Surface::Filling* editedObject)
: Gui::SelectionFilterGate(static_cast<Gui::SelectionFilter*>(nullptr))
, appendEdges(appendEdges)
, mode(mode)
, editedObject(editedObject)
{
}
/**
* Allow the user to pick only edges.
*/
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName);
bool allow(App::Document*, App::DocumentObject* pObj, const char* sSubName)
{
// don't allow references to itself
if (pObj == editedObject)
return false;
if (!pObj->isDerivedFrom(Part::Feature::getClassTypeId()))
return false;
private:
bool appendEdges;
Surface::Filling* editedObject;
};
if (!sSubName || sSubName[0] == '\0')
return false;
bool FillingPanel::ShapeSelection::allow(App::Document* , App::DocumentObject* pObj, const char* sSubName)
{
// don't allow references to itself
if (pObj == editedObject)
return false;
if (!pObj->isDerivedFrom(Part::Feature::getClassTypeId()))
return false;
if (!sSubName || sSubName[0] == '\0')
return false;
std::string element(sSubName);
if (element.substr(0,4) != "Edge")
return false;
#if 0
auto links = editedObject->BoundaryList.getSubListValues();
for (auto it : links) {
if (it.first == pObj) {
for (auto jt : it.second) {
if (jt == sSubName)
return !appendEdges;
}
switch (mode) {
case FillingPanel::InitFace:
return allowFace(pObj, sSubName);
case FillingPanel::AppendEdge:
return allowEdge(true, pObj, sSubName);
case FillingPanel::RemoveEdge:
return allowEdge(false, pObj, sSubName);
default:
return false;
}
}
#endif
return appendEdges;
}
private:
bool allowFace(App::DocumentObject* pObj, const char* sSubName)
{
std::string element(sSubName);
if (element.substr(0,4) != "Face")
return false;
return true;
}
bool allowEdge(bool appendEdges, App::DocumentObject* pObj, const char* sSubName)
{
std::string element(sSubName);
if (element.substr(0,4) != "Edge")
return false;
auto links = editedObject->Border.getSubListValues();
for (auto it : links) {
if (it.first == pObj) {
for (auto jt : it.second) {
if (jt == sSubName)
return !appendEdges;
}
}
}
return appendEdges;
}
private:
FillingPanel::SelectionMode mode;
Surface::Filling* editedObject;
};
// ----------------------------------------------------------------------------
@@ -216,25 +234,9 @@ FillingPanel::~FillingPanel()
void FillingPanel::setEditedObject(Surface::Filling* obj)
{
editedObject = obj;
#if 0
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
switch(curtype)
{
case GeomFill_StretchStyle:
ui->fillType_stretch->setChecked(true);
break;
case GeomFill_CoonsStyle:
ui->fillType_coons->setChecked(true);
break;
case GeomFill_CurvedStyle:
ui->fillType_curved->setChecked(true);
break;
default:
break;
}
auto objects = editedObject->BoundaryList.getValues();
auto element = editedObject->BoundaryList.getSubValues();
auto objects = editedObject->Border.getValues();
auto element = editedObject->Border.getSubValues();
auto it = objects.begin();
auto jt = element.begin();
@@ -255,7 +257,6 @@ void FillingPanel::setEditedObject(Surface::Filling* obj)
item->setData(Qt::UserRole, data);
}
attachDocument(Gui::Application::Instance->getDocument(doc));
#endif
}
void FillingPanel::changeEvent(QEvent *e)
@@ -346,56 +347,56 @@ bool FillingPanel::reject()
return true;
}
void FillingPanel::on_fillType_stretch_clicked()
void FillingPanel::on_lineInitFaceName_textChanged(const QString& text)
{
changeFillType(GeomFill_StretchStyle);
}
void FillingPanel::on_fillType_coons_clicked()
{
changeFillType(GeomFill_CoonsStyle);
}
void FillingPanel::on_fillType_curved_clicked()
{
changeFillType(GeomFill_CurvedStyle);
}
void FillingPanel::changeFillType(GeomFill_FillingStyle fillType)
{
#if 0
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
if (curtype != fillType) {
if (text.isEmpty()) {
checkOpenCommand();
editedObject->FillType.setValue(static_cast<long>(fillType));
editedObject->InitialFace.setValue(nullptr);
editedObject->recomputeFeature();
if (!editedObject->isValid()) {
Base::Console().Error("Surface filling: %s", editedObject->getStatusString());
}
}
#endif
}
void FillingPanel::on_buttonInitFace_clicked()
{
selectionMode = InitFace;
Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject));
}
void FillingPanel::on_buttonEdgeAdd_clicked()
{
selectionMode = Append;
Gui::Selection().addSelectionGate(new ShapeSelection(true, editedObject));
selectionMode = AppendEdge;
Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject));
}
void FillingPanel::on_buttonEdgeRemove_clicked()
{
selectionMode = Remove;
Gui::Selection().addSelectionGate(new ShapeSelection(false, editedObject));
selectionMode = RemoveEdge;
Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject));
}
void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (selectionMode == None)
return;
#if 0
if (msg.Type == Gui::SelectionChanges::AddSelection) {
checkOpenCommand();
if (selectionMode == Append) {
if (selectionMode == InitFace) {
Gui::SelectionObject sel(msg);
QString text = QString::fromLatin1("%1.%2")
.arg(QString::fromUtf8(sel.getObject()->Label.getValue()))
.arg(QString::fromLatin1(msg.pSubName));
ui->lineInitFaceName->setText(text);
std::vector<std::string> subList;
subList.push_back(msg.pSubName);
editedObject->InitialFace.setValue(sel.getObject(), subList);
//this->vp->highlightReferences(true);
Gui::Selection().rmvSelectionGate();
selectionMode = None;
}
else if (selectionMode == AppendEdge) {
QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
ui->listWidget->addItem(item);
@@ -411,14 +412,14 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
data << QByteArray(msg.pSubName);
item->setData(Qt::UserRole, data);
auto objects = editedObject->BoundaryList.getValues();
auto objects = editedObject->Border.getValues();
objects.push_back(sel.getObject());
auto element = editedObject->BoundaryList.getSubValues();
auto element = editedObject->Border.getSubValues();
element.push_back(msg.pSubName);
editedObject->BoundaryList.setValues(objects, element);
editedObject->Border.setValues(objects, element);
this->vp->highlightReferences(true);
}
else {
else if (selectionMode == RemoveEdge) {
Gui::SelectionObject sel(msg);
QList<QVariant> data;
data << QByteArray(msg.pDocName);
@@ -435,15 +436,15 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
this->vp->highlightReferences(false);
App::DocumentObject* obj = sel.getObject();
std::string sub = msg.pSubName;
auto objects = editedObject->BoundaryList.getValues();
auto element = editedObject->BoundaryList.getSubValues();
auto objects = editedObject->Border.getValues();
auto element = editedObject->Border.getSubValues();
auto it = objects.begin();
auto jt = element.begin();
for (; it != objects.end() && jt != element.end(); ++it, ++jt) {
if (*it == obj && *jt == sub) {
objects.erase(it);
element.erase(jt);
editedObject->BoundaryList.setValues(objects, element);
editedObject->Border.setValues(objects, element);
break;
}
}
@@ -453,12 +454,10 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
editedObject->recomputeFeature();
QTimer::singleShot(50, this, SLOT(clearSelection()));
}
#endif
}
void FillingPanel::onDeleteEdge()
{
#if 0
int row = ui->listWidget->currentRow();
QListWidgetItem* item = ui->listWidget->item(row);
if (item) {
@@ -471,8 +470,8 @@ void FillingPanel::onDeleteEdge()
App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray());
App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr;
std::string sub = data[2].toByteArray().constData();
auto objects = editedObject->BoundaryList.getValues();
auto element = editedObject->BoundaryList.getSubValues();
auto objects = editedObject->Border.getValues();
auto element = editedObject->Border.getSubValues();
auto it = objects.begin();
auto jt = element.begin();
this->vp->highlightReferences(false);
@@ -480,13 +479,12 @@ void FillingPanel::onDeleteEdge()
if (*it == obj && *jt == sub) {
objects.erase(it);
element.erase(jt);
editedObject->BoundaryList.setValues(objects, element);
editedObject->Border.setValues(objects, element);
break;
}
}
this->vp->highlightReferences(true);
}
#endif
}
// ----------------------------------------------------------------------------

View File

@@ -30,7 +30,6 @@
#include <Base/BoundBox.h>
#include <Mod/Part/Gui/ViewProviderSpline.h>
#include <Mod/Surface/App/FeatureFilling.h>
#include <GeomFill_FillingStyle.hxx>
namespace SurfaceGui
{
@@ -56,7 +55,7 @@ class FillingPanel : public QWidget,
protected:
class ShapeSelection;
enum SelectionMode { None, Append, Remove };
enum SelectionMode { None, InitFace, AppendEdge, RemoveEdge };
SelectionMode selectionMode;
Surface::Filling* editedObject;
bool checkCommand;
@@ -82,14 +81,12 @@ protected:
virtual void slotUndoDocument(const Gui::Document& Doc);
/** Notifies on redo */
virtual void slotRedoDocument(const Gui::Document& Doc);
void changeFillType(GeomFill_FillingStyle);
private Q_SLOTS:
void on_fillType_stretch_clicked();
void on_fillType_coons_clicked();
void on_fillType_curved_clicked();
void on_buttonInitFace_clicked();
void on_buttonEdgeAdd_clicked();
void on_buttonEdgeRemove_clicked();
void on_lineInitFaceName_textChanged(const QString&);
void onDeleteEdge(void);
void clearSelection();
};

View File

@@ -20,6 +20,24 @@
<string>Filling</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="buttonInitFace">
<property name="text">
<string>Initial Face</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::ClearLineEdit" name="lineInitFaceName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -59,48 +77,16 @@
<item row="2" column="0">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="0" column="0">
<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>
<property name="checked">
<bool>true</bool>
</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"/>
<customwidgets>
<customwidget>
<class>Gui::ClearLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">Gui/Widgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>