Files
create/src/Mod/PartDesign/Gui/ViewProviderSketchBased.cpp
Alexander Golubev 5ee0cea467 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
2016-04-12 18:12:15 +02:00

75 lines
2.9 KiB
C++

/***************************************************************************
* 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);
}