All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -20,12 +20,12 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
# include <QMessageBox>
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoPickStyle.h>
|
||||
# include <BRep_Builder.hxx>
|
||||
#include <QMessageBox>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoPickStyle.h>
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/ServiceProvider.h>
|
||||
@@ -81,7 +81,8 @@ void ViewProvider::attach(App::DocumentObject* pcObject)
|
||||
|
||||
PreviewColor.setValue(
|
||||
isAdditive ? styleParameterManager->resolve(StyleParameters::PreviewAdditiveColor)
|
||||
: styleParameterManager->resolve(StyleParameters::PreviewSubtractiveColor));
|
||||
: styleParameterManager->resolve(StyleParameters::PreviewSubtractiveColor)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,11 +124,11 @@ bool ViewProvider::setEdit(int ModNum)
|
||||
// When double-clicking on the item for this feature the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgFeatureParameters *featureDlg = qobject_cast<TaskDlgFeatureParameters *>(dlg);
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
TaskDlgFeatureParameters* featureDlg = qobject_cast<TaskDlgFeatureParameters*>(dlg);
|
||||
// NOTE: if the dialog is not partDesigan dialog the featureDlg will be NULL
|
||||
if (featureDlg && featureDlg->getViewObject() != this) {
|
||||
featureDlg = nullptr; // another feature left open its task panel
|
||||
featureDlg = nullptr; // another feature left open its task panel
|
||||
}
|
||||
if (dlg && !featureDlg) {
|
||||
QMessageBox msgBox(Gui::getMainWindow());
|
||||
@@ -138,7 +139,8 @@ bool ViewProvider::setEdit(int ModNum)
|
||||
|
||||
if (msgBox.exec() == QMessageBox::Yes) {
|
||||
Gui::Control().reject();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -163,20 +165,22 @@ bool ViewProvider::setEdit(int ModNum)
|
||||
// start the edit dialog if
|
||||
if (!featureDlg) {
|
||||
featureDlg = this->getEditDialog();
|
||||
if (!featureDlg) { // Shouldn't generally happen
|
||||
throw Base::RuntimeError ("Failed to create new edit dialog.");
|
||||
if (!featureDlg) { // Shouldn't generally happen
|
||||
throw Base::RuntimeError("Failed to create new edit dialog.");
|
||||
}
|
||||
}
|
||||
|
||||
Gui::Control().showDialog(featureDlg);
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return PartGui::ViewProviderPart::setEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TaskDlgFeatureParameters *ViewProvider::getEditDialog() {
|
||||
TaskDlgFeatureParameters* ViewProvider::getEditDialog()
|
||||
{
|
||||
throw Base::NotImplementedError("getEditDialog() not implemented");
|
||||
}
|
||||
|
||||
@@ -208,7 +212,8 @@ void ViewProvider::updateData(const App::Property* prop)
|
||||
{
|
||||
if (strcmp(prop->getName(), "PreviewShape") == 0) {
|
||||
updatePreview();
|
||||
} else if (auto* previewExtension = getObject()->getExtensionByType<Part::PreviewExtension>(true)) {
|
||||
}
|
||||
else if (auto* previewExtension = getObject()->getExtensionByType<Part::PreviewExtension>(true)) {
|
||||
if (!previewExtension->isPreviewFresh() && isEditing()) {
|
||||
previewExtension->updatePreview();
|
||||
}
|
||||
@@ -248,7 +253,8 @@ void ViewProvider::updatePreview()
|
||||
Part::TopoShape toolShape = addSubFeature->AddSubShape.getShape();
|
||||
|
||||
updatePreviewShape(toolShape, pcToolPreview);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
updatePreviewShape({}, pcToolPreview);
|
||||
}
|
||||
}
|
||||
@@ -262,22 +268,25 @@ void ViewProvider::makeChildrenVisible()
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProvider::onChanged(const App::Property* prop) {
|
||||
void ViewProvider::onChanged(const App::Property* prop)
|
||||
{
|
||||
|
||||
//if the object is inside of a body we make sure it is the only visible one on activation
|
||||
if(prop == &Visibility && Visibility.getValue()) {
|
||||
// if the object is inside of a body we make sure it is the only visible one on activation
|
||||
if (prop == &Visibility && Visibility.getValue()) {
|
||||
|
||||
Part::BodyBase* body = Part::BodyBase::findBodyOf(getObject());
|
||||
if(body) {
|
||||
if (body) {
|
||||
|
||||
//hide all features in the body other than this object
|
||||
for(App::DocumentObject* obj : body->Group.getValues()) {
|
||||
// hide all features in the body other than this object
|
||||
for (App::DocumentObject* obj : body->Group.getValues()) {
|
||||
|
||||
if(obj->isDerivedFrom<PartDesign::Feature>() && obj != getObject()) {
|
||||
auto vpd = freecad_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(obj));
|
||||
if(vpd && vpd->Visibility.getValue())
|
||||
vpd->Visibility.setValue(false);
|
||||
if (obj->isDerivedFrom<PartDesign::Feature>() && obj != getObject()) {
|
||||
auto vpd = freecad_cast<Gui::ViewProviderDocumentObject*>(
|
||||
Gui::Application::Instance->getViewProvider(obj)
|
||||
);
|
||||
if (vpd && vpd->Visibility.getValue()) {
|
||||
vpd->Visibility.setValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,7 +311,8 @@ Gui::ViewProvider* ViewProvider::startEditing(int ModNum)
|
||||
return ViewProviderPart::startEditing(ModNum);
|
||||
}
|
||||
|
||||
void ViewProvider::setTipIcon(bool onoff) {
|
||||
void ViewProvider::setTipIcon(bool onoff)
|
||||
{
|
||||
isSetTipIcon = onoff;
|
||||
|
||||
signalChangeIcon();
|
||||
@@ -314,10 +324,11 @@ QIcon ViewProvider::mergeColorfulOverlayIcons(const QIcon& orig) const
|
||||
|
||||
if (isSetTipIcon) {
|
||||
static QPixmap px(Gui::BitmapFactory().pixmapFromSvg("PartDesign_Overlay_Tip", QSize(10, 10)));
|
||||
mergedicon = Gui::BitmapFactoryInst::mergePixmap(mergedicon, px, Gui::BitmapFactoryInst::BottomRight);
|
||||
mergedicon
|
||||
= Gui::BitmapFactoryInst::mergePixmap(mergedicon, px, Gui::BitmapFactoryInst::BottomRight);
|
||||
}
|
||||
|
||||
return Gui::ViewProvider::mergeColorfulOverlayIcons (mergedicon);
|
||||
return Gui::ViewProvider::mergeColorfulOverlayIcons(mergedicon);
|
||||
}
|
||||
|
||||
bool ViewProvider::onDelete(const std::vector<std::string>&)
|
||||
@@ -337,16 +348,17 @@ bool ViewProvider::onDelete(const std::vector<std::string>&)
|
||||
Part::BodyBase* body = PartDesign::Body::findBodyOf(getObject());
|
||||
|
||||
if (body) {
|
||||
// Deletion from the tree of a feature is handled by Document.removeObject, which has no clue
|
||||
// about what a body is. Therefore, Bodies, although an "activable" container, know nothing
|
||||
// about what happens at Document level with the features they contain.
|
||||
// Deletion from the tree of a feature is handled by Document.removeObject, which has no
|
||||
// clue about what a body is. Therefore, Bodies, although an "activable" container, know
|
||||
// nothing about what happens at Document level with the features they contain.
|
||||
//
|
||||
// The Deletion command StdCmdDelete::activated, however does notify the viewprovider corresponding
|
||||
// to the feature (not body) of the imminent deletion (before actually doing it).
|
||||
// The Deletion command StdCmdDelete::activated, however does notify the viewprovider
|
||||
// corresponding to the feature (not body) of the imminent deletion (before actually doing
|
||||
// it).
|
||||
//
|
||||
// Consequently, the only way of notifying a body of the imminent deletion of one of its features
|
||||
// so as to do the clean up required (moving basefeature references, tip management) is from the
|
||||
// viewprovider, so we call it here.
|
||||
// Consequently, the only way of notifying a body of the imminent deletion of one of its
|
||||
// features so as to do the clean up required (moving basefeature references, tip
|
||||
// management) is from the viewprovider, so we call it here.
|
||||
//
|
||||
// fixes (#3084)
|
||||
|
||||
@@ -372,9 +384,9 @@ Part::TopoShape ViewProvider::getPreviewShape() const
|
||||
void ViewProvider::showPreviousFeature(bool enable)
|
||||
{
|
||||
PartDesign::Feature* feature {getObject<PartDesign::Feature>()};
|
||||
PartDesign::Feature* baseFeature { nullptr };
|
||||
PartDesign::Feature* baseFeature {nullptr};
|
||||
|
||||
ViewProvider* baseFeatureViewProvider { nullptr };
|
||||
ViewProvider* baseFeatureViewProvider {nullptr};
|
||||
|
||||
if (!feature) {
|
||||
return;
|
||||
@@ -382,7 +394,9 @@ void ViewProvider::showPreviousFeature(bool enable)
|
||||
|
||||
baseFeature = dynamic_cast<PartDesign::Feature*>(feature->BaseFeature.getValue());
|
||||
if (baseFeature) {
|
||||
baseFeatureViewProvider = freecad_cast<ViewProvider*>(Gui::Application::Instance->getViewProvider(baseFeature));
|
||||
baseFeatureViewProvider = freecad_cast<ViewProvider*>(
|
||||
Gui::Application::Instance->getViewProvider(baseFeature)
|
||||
);
|
||||
}
|
||||
|
||||
if (!baseFeatureViewProvider) {
|
||||
@@ -392,31 +406,35 @@ void ViewProvider::showPreviousFeature(bool enable)
|
||||
if (enable) {
|
||||
baseFeatureViewProvider->show();
|
||||
hide();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
baseFeatureViewProvider->hide();
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProvider::setBodyMode(bool bodymode) {
|
||||
void ViewProvider::setBodyMode(bool bodymode)
|
||||
{
|
||||
|
||||
std::vector<App::Property*> props;
|
||||
getPropertyList(props);
|
||||
|
||||
auto vp = getBodyViewProvider();
|
||||
if(!vp)
|
||||
if (!vp) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(App::Property* prop : props) {
|
||||
for (App::Property* prop : props) {
|
||||
|
||||
//we keep visibility and selectibility per object
|
||||
if(prop == &Visibility ||
|
||||
prop == &Selectable)
|
||||
// we keep visibility and selectibility per object
|
||||
if (prop == &Visibility || prop == &Selectable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//we hide only properties which are available in the body, not special ones
|
||||
if(!vp->getPropertyByName(prop->getName()))
|
||||
// we hide only properties which are available in the body, not special ones
|
||||
if (!vp->getPropertyByName(prop->getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
prop->setStatus(App::Property::Hidden, bodymode);
|
||||
}
|
||||
@@ -424,21 +442,23 @@ void ViewProvider::setBodyMode(bool bodymode) {
|
||||
|
||||
void ViewProvider::makeTemporaryVisible(bool onoff)
|
||||
{
|
||||
//make sure to not use the overridden versions, as they change properties
|
||||
// make sure to not use the overridden versions, as they change properties
|
||||
if (onoff) {
|
||||
if (VisualTouched) {
|
||||
updateVisual();
|
||||
}
|
||||
Gui::ViewProvider::show();
|
||||
}
|
||||
else
|
||||
else {
|
||||
Gui::ViewProvider::hide();
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* ViewProvider::getPyObject()
|
||||
{
|
||||
if (!pyViewObject)
|
||||
if (!pyViewObject) {
|
||||
pyViewObject = new ViewProviderPy(this);
|
||||
}
|
||||
pyViewObject->IncRef();
|
||||
return pyViewObject;
|
||||
}
|
||||
@@ -448,20 +468,22 @@ ViewProviderBody* ViewProvider::getBodyViewProvider()
|
||||
|
||||
auto body = PartDesign::Body::findBodyOf(getObject());
|
||||
auto doc = getDocument();
|
||||
if(body && doc) {
|
||||
if (body && doc) {
|
||||
auto vp = doc->getViewProvider(body);
|
||||
if(vp && vp->isDerivedFrom<ViewProviderBody>())
|
||||
return static_cast<ViewProviderBody*>(vp);
|
||||
if (vp && vp->isDerivedFrom<ViewProviderBody>()) {
|
||||
return static_cast<ViewProviderBody*>(vp);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
namespace Gui
|
||||
{
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(PartDesignGui::ViewProviderPython, PartDesignGui::ViewProvider)
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class PartDesignGuiExport ViewProviderFeaturePythonT<PartDesignGui::ViewProvider>;
|
||||
}
|
||||
} // namespace Gui
|
||||
|
||||
Reference in New Issue
Block a user