Surface: apply clang format
This commit is contained in:
@@ -23,13 +23,12 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
# include <QTimer>
|
||||
|
||||
# include <TopExp.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
@@ -51,9 +50,12 @@ using namespace SurfaceGui;
|
||||
|
||||
PROPERTY_SOURCE(SurfaceGui::ViewProviderGeomFillSurface, PartGui::ViewProviderSpline)
|
||||
|
||||
namespace SurfaceGui {
|
||||
namespace SurfaceGui
|
||||
{
|
||||
|
||||
void ViewProviderGeomFillSurface::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
void ViewProviderGeomFillSurface::setupContextMenu(QMenu* menu,
|
||||
QObject* receiver,
|
||||
const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit filling"), receiver, member);
|
||||
@@ -63,20 +65,21 @@ void ViewProviderGeomFillSurface::setupContextMenu(QMenu* menu, QObject* receive
|
||||
|
||||
bool ViewProviderGeomFillSurface::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
// When double-clicking on the item for this sketch the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
|
||||
Surface::GeomFillSurface* obj = static_cast<Surface::GeomFillSurface*>(this->getObject());
|
||||
Surface::GeomFillSurface* obj = static_cast<Surface::GeomFillSurface*>(this->getObject());
|
||||
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
|
||||
// start the edit dialog
|
||||
if (dlg) {
|
||||
TaskGeomFillSurface* tDlg = qobject_cast<TaskGeomFillSurface*>(dlg);
|
||||
if (tDlg)
|
||||
if (tDlg) {
|
||||
tDlg->setEditedObject(obj);
|
||||
}
|
||||
Gui::Control().showDialog(dlg);
|
||||
}
|
||||
else {
|
||||
@@ -113,7 +116,7 @@ void ViewProviderGeomFillSurface::highlightReferences(bool on)
|
||||
Part::Feature* base = dynamic_cast<Part::Feature*>(it.first);
|
||||
if (base) {
|
||||
PartGui::ViewProviderPartExt* svp = dynamic_cast<PartGui::ViewProviderPartExt*>(
|
||||
Gui::Application::Instance->getViewProvider(base));
|
||||
Gui::Application::Instance->getViewProvider(base));
|
||||
if (svp) {
|
||||
if (on) {
|
||||
std::vector<App::Color> colors;
|
||||
@@ -123,8 +126,8 @@ void ViewProviderGeomFillSurface::highlightReferences(bool on)
|
||||
|
||||
for (const auto& jt : it.second) {
|
||||
std::size_t idx = static_cast<std::size_t>(std::stoi(jt.substr(4)) - 1);
|
||||
assert (idx < colors.size());
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
assert(idx < colors.size());
|
||||
colors[idx] = App::Color(1.0, 0.0, 1.0);// magenta
|
||||
}
|
||||
|
||||
svp->setHighlightedEdges(colors);
|
||||
@@ -139,18 +142,17 @@ void ViewProviderGeomFillSurface::highlightReferences(bool on)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class GeomFillSurface::EdgeSelection : public Gui::SelectionFilterGate
|
||||
class GeomFillSurface::EdgeSelection: public Gui::SelectionFilterGate
|
||||
{
|
||||
public:
|
||||
EdgeSelection(bool appendEdges, Surface::GeomFillSurface* editedObject)
|
||||
: Gui::SelectionFilterGate(nullPointer())
|
||||
, appendEdges(appendEdges)
|
||||
, editedObject(editedObject)
|
||||
{
|
||||
}
|
||||
{}
|
||||
/**
|
||||
* Allow the user to pick only edges.
|
||||
*/
|
||||
* Allow the user to pick only edges.
|
||||
*/
|
||||
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName) override;
|
||||
|
||||
private:
|
||||
@@ -158,27 +160,34 @@ private:
|
||||
Surface::GeomFillSurface* editedObject;
|
||||
};
|
||||
|
||||
bool GeomFillSurface::EdgeSelection::allow(App::Document* , App::DocumentObject* pObj, const char* sSubName)
|
||||
bool GeomFillSurface::EdgeSelection::allow(App::Document*,
|
||||
App::DocumentObject* pObj,
|
||||
const char* sSubName)
|
||||
{
|
||||
// don't allow references to itself
|
||||
if (pObj == editedObject)
|
||||
if (pObj == editedObject) {
|
||||
return false;
|
||||
if (!pObj->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
}
|
||||
if (!pObj->isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
if (!sSubName || sSubName[0] == '\0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string element(sSubName);
|
||||
if (element.substr(0,4) != "Edge")
|
||||
if (element.substr(0, 4) != "Edge") {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto links = editedObject->BoundaryList.getSubListValues();
|
||||
for (const auto& it : links) {
|
||||
if (it.first == pObj) {
|
||||
for (const auto& jt : it.second) {
|
||||
if (jt == sSubName)
|
||||
if (jt == sSubName) {
|
||||
return !appendEdges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,38 +238,50 @@ GeomFillSurface::~GeomFillSurface()
|
||||
|
||||
void GeomFillSurface::setupConnections()
|
||||
{
|
||||
connect(ui->fillType_stretch, &QRadioButton::clicked,
|
||||
this, &GeomFillSurface::onFillTypeStretchClicked);
|
||||
connect(ui->fillType_coons, &QRadioButton::clicked,
|
||||
this, &GeomFillSurface::onFillTypeCoonsClicked);
|
||||
connect(ui->fillType_curved, &QRadioButton::clicked,
|
||||
this, &GeomFillSurface::onFillTypeCurvedClicked);
|
||||
connect(ui->buttonEdgeAdd, &QToolButton::toggled,
|
||||
this, &GeomFillSurface::onButtonEdgeAddToggled);
|
||||
connect(ui->buttonEdgeRemove, &QToolButton::toggled,
|
||||
this, &GeomFillSurface::onButtonEdgeRemoveToggled);
|
||||
connect(ui->listWidget, &QListWidget::itemDoubleClicked,
|
||||
this, &GeomFillSurface::onListWidgetItemDoubleClicked);
|
||||
connect(ui->fillType_stretch,
|
||||
&QRadioButton::clicked,
|
||||
this,
|
||||
&GeomFillSurface::onFillTypeStretchClicked);
|
||||
connect(ui->fillType_coons,
|
||||
&QRadioButton::clicked,
|
||||
this,
|
||||
&GeomFillSurface::onFillTypeCoonsClicked);
|
||||
connect(ui->fillType_curved,
|
||||
&QRadioButton::clicked,
|
||||
this,
|
||||
&GeomFillSurface::onFillTypeCurvedClicked);
|
||||
connect(ui->buttonEdgeAdd,
|
||||
&QToolButton::toggled,
|
||||
this,
|
||||
&GeomFillSurface::onButtonEdgeAddToggled);
|
||||
connect(ui->buttonEdgeRemove,
|
||||
&QToolButton::toggled,
|
||||
this,
|
||||
&GeomFillSurface::onButtonEdgeRemoveToggled);
|
||||
connect(ui->listWidget,
|
||||
&QListWidget::itemDoubleClicked,
|
||||
this,
|
||||
&GeomFillSurface::onListWidgetItemDoubleClicked);
|
||||
}
|
||||
|
||||
// stores object pointer, its old fill type and adjusts radio buttons according to it.
|
||||
void GeomFillSurface::setEditedObject(Surface::GeomFillSurface* obj)
|
||||
{
|
||||
editedObject = obj;
|
||||
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;
|
||||
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();
|
||||
@@ -277,16 +298,17 @@ void GeomFillSurface::setEditedObject(Surface::GeomFillSurface* obj)
|
||||
for (; it != objects.end() && jt != element.end(); ++it, ++jt, ++index) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
|
||||
if (index < boolean.size()) {
|
||||
if (boolean[index])
|
||||
if (boolean[index]) {
|
||||
item->setIcon(rotateLeft);
|
||||
else
|
||||
}
|
||||
else {
|
||||
item->setIcon(rotateRight);
|
||||
}
|
||||
}
|
||||
ui->listWidget->addItem(item);
|
||||
|
||||
QString text = QString::fromLatin1("%1.%2")
|
||||
.arg(QString::fromUtf8((*it)->Label.getValue()),
|
||||
QString::fromStdString(*jt));
|
||||
QString text = QString::fromLatin1("%1.%2").arg(QString::fromUtf8((*it)->Label.getValue()),
|
||||
QString::fromStdString(*jt));
|
||||
item->setText(text);
|
||||
|
||||
QList<QVariant> data;
|
||||
@@ -299,7 +321,7 @@ void GeomFillSurface::setEditedObject(Surface::GeomFillSurface* obj)
|
||||
attachDocument(Gui::Application::Instance->getDocument(doc));
|
||||
}
|
||||
|
||||
void GeomFillSurface::changeEvent(QEvent *e)
|
||||
void GeomFillSurface::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
@@ -358,29 +380,31 @@ bool GeomFillSurface::accept()
|
||||
int count = ui->listWidget->count();
|
||||
if (count > 4) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Too many edges"),
|
||||
tr("The tool requires two, three or four edges"));
|
||||
tr("Too many edges"),
|
||||
tr("The tool requires two, three or four edges"));
|
||||
return false;
|
||||
}
|
||||
else if (count < 2) {
|
||||
QMessageBox::warning(this,
|
||||
tr("Too less edges"),
|
||||
tr("The tool requires two, three or four edges"));
|
||||
tr("Too less edges"),
|
||||
tr("The tool requires two, three or four edges"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (editedObject->mustExecute())
|
||||
if (editedObject->mustExecute()) {
|
||||
editedObject->recomputeFeature();
|
||||
}
|
||||
if (!editedObject->isValid()) {
|
||||
QMessageBox::warning(this, tr("Invalid object"),
|
||||
QString::fromLatin1(editedObject->getStatusString()));
|
||||
QMessageBox::warning(this,
|
||||
tr("Invalid object"),
|
||||
QString::fromLatin1(editedObject->getStatusString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
this->vp->highlightReferences(false);
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::updateActive();
|
||||
return true;
|
||||
}
|
||||
@@ -392,7 +416,7 @@ bool GeomFillSurface::reject()
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::updateActive();
|
||||
return true;
|
||||
}
|
||||
@@ -414,7 +438,8 @@ void GeomFillSurface::onFillTypeCurvedClicked()
|
||||
|
||||
void GeomFillSurface::changeFillType(GeomFill_FillingStyle fillType)
|
||||
{
|
||||
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
|
||||
GeomFill_FillingStyle curtype =
|
||||
static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
|
||||
if (curtype != fillType) {
|
||||
checkOpenCommand();
|
||||
editedObject->FillType.setValue(static_cast<long>(fillType));
|
||||
@@ -449,8 +474,9 @@ void GeomFillSurface::onButtonEdgeRemoveToggled(bool checked)
|
||||
|
||||
void GeomFillSurface::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (selectionMode == None)
|
||||
if (selectionMode == None) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
checkOpenCommand();
|
||||
@@ -460,9 +486,9 @@ void GeomFillSurface::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
ui->listWidget->addItem(item);
|
||||
|
||||
Gui::SelectionObject sel(msg);
|
||||
QString text = QString::fromLatin1("%1.%2")
|
||||
.arg(QString::fromUtf8(sel.getObject()->Label.getValue()),
|
||||
QString::fromLatin1(msg.pSubName));
|
||||
QString text = QString::fromLatin1("%1.%2").arg(
|
||||
QString::fromUtf8(sel.getObject()->Label.getValue()),
|
||||
QString::fromLatin1(msg.pSubName));
|
||||
item->setText(text);
|
||||
|
||||
QList<QVariant> data;
|
||||
@@ -488,7 +514,7 @@ void GeomFillSurface::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
data << QByteArray(msg.pDocName);
|
||||
data << QByteArray(msg.pObjectName);
|
||||
data << QByteArray(msg.pSubName);
|
||||
for (int i=0; i<ui->listWidget->count(); i++) {
|
||||
for (int i = 0; i < ui->listWidget->count(); i++) {
|
||||
QListWidgetItem* item = ui->listWidget->item(i);
|
||||
if (item && item->data(Qt::UserRole) == data) {
|
||||
row = i;
|
||||
@@ -508,12 +534,13 @@ void GeomFillSurface::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
// remove the element of the bitset at position 'row'
|
||||
const boost::dynamic_bitset<>& old_booleans = editedObject->ReversedList.getValues();
|
||||
boost::dynamic_bitset<> new_booleans = old_booleans >> 1;
|
||||
new_booleans.resize(objects.size()-1);
|
||||
new_booleans.resize(objects.size() - 1);
|
||||
|
||||
// double-check in case 'old_booleans' is out of sync
|
||||
if (new_booleans.size() < old_booleans.size()) {
|
||||
for (int i=0; i<row; i++)
|
||||
for (int i = 0; i < row; i++) {
|
||||
new_booleans[i] = old_booleans[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (; it != objects.end() && jt != element.end(); ++it, ++jt) {
|
||||
@@ -556,12 +583,13 @@ void GeomFillSurface::onDeleteEdge()
|
||||
// remove the element of the bitset at position 'row'
|
||||
const boost::dynamic_bitset<>& old_booleans = editedObject->ReversedList.getValues();
|
||||
boost::dynamic_bitset<> new_booleans = old_booleans >> 1;
|
||||
new_booleans.resize(objects.size()-1);
|
||||
new_booleans.resize(objects.size() - 1);
|
||||
|
||||
// double-check in case 'old_booleans' is out of sync
|
||||
if (new_booleans.size() < old_booleans.size()) {
|
||||
for (int i=0; i<row; i++)
|
||||
for (int i = 0; i < row; i++) {
|
||||
new_booleans[i] = old_booleans[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (; it != objects.end() && jt != element.end(); ++it, ++jt) {
|
||||
@@ -625,13 +653,15 @@ void GeomFillSurface::exitSelectionMode()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TaskGeomFillSurface::TaskGeomFillSurface(ViewProviderGeomFillSurface* vp, Surface::GeomFillSurface* obj)
|
||||
TaskGeomFillSurface::TaskGeomFillSurface(ViewProviderGeomFillSurface* vp,
|
||||
Surface::GeomFillSurface* obj)
|
||||
{
|
||||
widget = new GeomFillSurface(vp, obj);
|
||||
widget->setWindowTitle(QObject::tr("Surface"));
|
||||
taskbox = new Gui::TaskView::TaskBox(
|
||||
Gui::BitmapFactory().pixmap("Surface_BSplineSurface"),
|
||||
widget->windowTitle(), true, nullptr);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("Surface_BSplineSurface"),
|
||||
widget->windowTitle(),
|
||||
true,
|
||||
nullptr);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
@@ -656,6 +686,6 @@ bool TaskGeomFillSurface::reject()
|
||||
return widget->reject();
|
||||
}
|
||||
|
||||
}
|
||||
}// namespace SurfaceGui
|
||||
|
||||
#include "moc_TaskGeomFillSurface.cpp"
|
||||
|
||||
Reference in New Issue
Block a user