PartDesign/Gui: start to unify view providers code
- Moved all common code for part design features view providers to a base class. - Move shared code for Sketch based features to newly created ViewProviderSketchBased class - Add ViewProviderSketchBased to initialization - Make Pad and Pocket ViewProviders to use the shared code - Minor fixes to TaskFeatureParameters and some derived classes
This commit is contained in:
committed by
Stefan Tröger
parent
6266d514d3
commit
5ee0cea467
74
src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp
Normal file
74
src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
|
||||
* *
|
||||
* 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_
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/App/FeatureSketchBased.h>
|
||||
|
||||
#include "ViewProviderSketchBased.h"
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderSketchBased, PartDesignGui::ViewProvider)
|
||||
|
||||
|
||||
ViewProviderSketchBased::ViewProviderSketchBased()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ViewProviderSketchBased::~ViewProviderSketchBased()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderSketchBased::claimChildren(void) const {
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
App::DocumentObject* sketch = static_cast<PartDesign::SketchBased*>(getObject())->Sketch.getValue();
|
||||
if (sketch != NULL)
|
||||
temp.push_back(sketch);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
bool ViewProviderSketchBased::onDelete(const std::vector<std::string> &s) {
|
||||
PartDesign::SketchBased* feature = static_cast<PartDesign::SketchBased*>(getObject());
|
||||
|
||||
// get the Sketch
|
||||
Sketcher::SketchObject *pcSketch = 0;
|
||||
if (feature->Sketch.getValue())
|
||||
pcSketch = static_cast<Sketcher::SketchObject*>(feature->Sketch.getValue());
|
||||
|
||||
// if abort command deleted the object the sketch is visible again
|
||||
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
|
||||
Gui::Application::Instance->getViewProvider(pcSketch)->show();
|
||||
|
||||
return ViewProvider::onDelete(s);
|
||||
}
|
||||
Reference in New Issue
Block a user