Files
create/src/Mod/PartDesign/Gui/Utils.h
Zheng, Lei 11a93a0578 PartDesign changes
* Mostly for supporting in-place editing

* Add new SubShapeBinder that support cross coordinate system,
  external, and sub-object binding
2019-08-17 15:15:47 +02:00

92 lines
4.1 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 *
* *
***************************************************************************/
#ifndef UTILS_H_CS5LK2ZQ
#define UTILS_H_CS5LK2ZQ
/** \file PartDesign/Gui/Utils.h
* This file contains some utility function used over PartDesignGui module
*/
namespace PartDesign {
class Body;
class Feature;
}
namespace App {
class Document;
class DocumentObject;
class Part;
}
namespace Sketcher {
class SketchObject;
}
namespace PartDesignGui {
/// Activate edit mode of the given object
bool setEdit(App::DocumentObject *obj, PartDesign::Body *body = 0);
/// Return active body or show a warning message
PartDesign::Body *getBody(bool messageIfNot, bool autoActivate=true, bool assertModern=true,
App::DocumentObject **topParent=0, std::string *subname=0);
/// Display error when there are existing Body objects, but none are active
void needActiveBodyError(void);
/// Create a Body object in doc, set it active, and return pointer to it
PartDesign::Body * makeBody(App::Document *doc);
/**
* Finds a body for the given feature. And shows a message if not found
* Also unlike Body::findBodyFor it checks if the active body has the feature first.
*/
PartDesign::Body *getBodyFor(const App::DocumentObject*, bool messageIfNot,
bool autoActivate=true, bool assertModern=true,
App::DocumentObject **topParent=0, std::string *subname=0);
App::Part *getPartFor(const App::DocumentObject*, bool messageIfNot);
App::Part *getActivePart();
/// Fix sketch support after moving a free sketch into a body
void fixSketchSupport(Sketcher::SketchObject* sketch);
/**
* Returns true if document has any non-PartDesign objects that links to the given object.
* If respectGroups is true don't count links from App::GeoFeatureGroup-derived objects (default is false)
*/
bool isAnyNonPartDesignLinksTo ( PartDesign::Feature *feature, bool respectGroups=false );
/// Relink all nonPartDesign features to the body instead of the given partDesign Feature
void relinkToBody ( PartDesign::Feature *feature );
/// Check if feature is dependent on anything except movable sketches and datums
bool isFeatureMovable(App::DocumentObject* feature);
/// Collect dependencies of the features during the move. Dependencies should only be dependent on origin
std::vector<App::DocumentObject*> collectMovableDependencies(std::vector<App::DocumentObject*>& features);
/// Relink sketches and datums to target body's origin
void relinkToOrigin(App::DocumentObject* feature, PartDesign::Body* body);
} /* PartDesignGui */
#endif /* end of include guard: UTILS_H_CS5LK2ZQ */