GUI: Add UI for Up To Shape feature

Add UI for Up To Shape feature and overall refactor of Pad / Pocket.
This commit is contained in:
Kacper Donat
2024-05-31 12:10:17 +02:00
parent 3f6f8c0172
commit b68da9d844
18 changed files with 684 additions and 118 deletions

View File

@@ -0,0 +1,64 @@
/***************************************************************************
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
* *
* 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 <QMenu>
#endif
#include <App/Document.h>
#include <Gui/Application.h>
#include <Mod/PartDesign/App/FeatureExtrude.h>
#include <Mod/Part/Gui/ReferenceHighlighter.h>
#include "TaskExtrudeParameters.h"
#include "ViewProviderExtrude.h"
using namespace PartDesignGui;
PROPERTY_SOURCE(PartDesignGui::ViewProviderExtrude, PartDesignGui::ViewProviderSketchBased)
void PartDesignGui::ViewProviderExtrude::highlightShapeFaces(const std::vector<std::string>& faces)
{
auto extrude = static_cast<PartDesign::FeatureExtrude*>(getObject());
auto base = static_cast<Part::Feature*>(extrude->UpToShape.getValue());
auto baseViewProvider =
static_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(base));
baseViewProvider->unsetHighlightedFaces();
baseViewProvider->updateView();
if (faces.size() > 0) {
std::vector<App::Color> colors = baseViewProvider->DiffuseColor.getValues();
auto color = baseViewProvider->ShapeAppearance.getDiffuseColor();
PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), color);
highlighter.getFaceColors(faces, colors);
baseViewProvider->setHighlightedFaces(colors);
}
}