App/Origin: big refactoring

- Rebase App::Origin on App::DocumentObject
 - Keep all control over the Origin structure inside the Origin and it's
   ViewProvider
 - Add OriginFeature class as common base for App::Plane and App::Line
 - Rebase App::Plane and App::Line on top of newly created class and
   move to the file.
 - Change Origin's ViewProvider API associated with temporary display
 - Lots of associated changes to files
 - Several minor fixes
 - Lots of new bugs
This commit is contained in:
Alexander Golubev 2015-09-01 05:35:10 +03:00 committed by Stefan Tröger
parent ecbb576330
commit 797d6d3a11
47 changed files with 641 additions and 673 deletions

View File

@ -95,8 +95,7 @@
#include "Annotation.h"
#include "MeasureDistance.h"
#include "Placement.h"
#include "Plane.h"
#include "Line.h"
#include "OriginFeature.h"
#include "Part.h"
#include "Origin.h"
#include "MaterialObject.h"
@ -1134,6 +1133,7 @@ void Application::initTypes(void)
App ::MaterialObject ::init();
App ::MaterialObjectPython ::init();
App ::Placement ::init();
App ::OriginFeature ::init();
App ::Plane ::init();
App ::Line ::init();
App ::Part ::init();

View File

@ -83,9 +83,8 @@ SET(Document_CPP_SRCS
InventorObject.cpp
MeasureDistance.cpp
Placement.cpp
Plane.cpp
OriginFeature.cpp
Range.cpp
Line.cpp
Transactions.cpp
VRMLObject.cpp
MaterialObject.cpp
@ -115,9 +114,8 @@ SET(Document_HPP_SRCS
InventorObject.h
MeasureDistance.h
Placement.h
Plane.h
OriginFeature.h
Range.h
Line.h
Transactions.h
VRMLObject.h
MaterialObject.h

View File

@ -78,16 +78,18 @@ SET(Document_CPP_SRCS
GeoFeatureGroupPyImp.cpp
GeoFeatureGroup.cpp
Part.cpp
Origin.cpp
Path.cpp
InventorObject.cpp
MeasureDistance.cpp
Placement.cpp
<<<<<<< ae7effa304095ee3d286ea7bb545636960e262d5
Plane.cpp
<<<<<<< 328aeaab9aed22c3b94c79bd7e49404342a44cea
Range.cpp
=======
Line.cpp
>>>>>>> add base lines
=======
OriginFeature.cpp
>>>>>>> App/Origin: big refactoring
Transactions.cpp
VRMLObject.cpp
MaterialObject.cpp
@ -112,16 +114,18 @@ SET(Document_HPP_SRCS
GeoFeature.h
GeoFeatureGroup.h
Part.h
Origin.h
Path.h
InventorObject.h
MeasureDistance.h
Placement.h
<<<<<<< ae7effa304095ee3d286ea7bb545636960e262d5
Plane.h
<<<<<<< 328aeaab9aed22c3b94c79bd7e49404342a44cea
Range.h
=======
Line.h
>>>>>>> add base lines
=======
OriginFeature.h
>>>>>>> App/Origin: big refactoring
Transactions.h
VRMLObject.h
MaterialObject.h

View File

@ -2084,7 +2084,6 @@ void Document::remObject(const char* sName)
pos->second->unsetupObject();
}
signalDeletedObject(*(pos->second));
// TODO Check me if it's needed (2015-09-01, Fat-Zer)
pos->second->StatusBits.reset (ObjectStatus::Delete); // Unset the bit to be on the safe side
if (!d->vertexMap.empty()) {
@ -2140,6 +2139,7 @@ void Document::remObject(const char* sName)
/// Remove an object out of the document (internal)
void Document::_remObject(DocumentObject* pcObject)
{
// TODO Refactoring: share code with Document::remObject() (2015-09-01, Fat-Zer)
_checkTransaction(pcObject);
std::map<std::string,DocumentObject*>::iterator pos = d->objectMap.find(pcObject->getNameInDocument());

View File

@ -1,69 +0,0 @@
/***************************************************************************
* Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2015 *
* *
* 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 _AppLine_h_
#define _AppLine_h_
#include "GeoFeature.h"
#include "PropertyGeo.h"
namespace App
{
/** Line Object
* Used to define planar support for all kind of operations in the document space
*/
class AppExport Line: public App::GeoFeature
{
PROPERTY_HEADER(App::Line);
public:
/// Constructor
Line(void);
virtual ~Line();
/// additional information about the plane usage (e.g. "BaseLine-xy" in a Part)
PropertyString LineType;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
return "Gui::ViewProviderLine";
}
/// Return the bounding box of the plane (this is always a fixed size)
static Base::BoundBox3d getBoundBox();
};
} //namespace App
#endif

View File

@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2015 *
* Copyright (c) Stefan Tr<EFBFBD>ger (stefantroeger@gmx.net) 2015 *
* Copyright (c) Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> 2015 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -24,10 +25,14 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <string>
#endif
#include <Base/Exception.h>
#include <Base/Placement.h>
#include <App/Document.h>
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include "Origin.h"
@ -35,20 +40,138 @@
using namespace App;
PROPERTY_SOURCE(App::Origin, App::GeoFeatureGroup)
PROPERTY_SOURCE(App::Origin, App::DocumentObject)
const char* Origin::AxisRoles[3] = {"X_Axis", "Y_Axis", "Z_Axis"};
const char* Origin::PlaneRoles[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"};
//===========================================================================
// Feature
//===========================================================================
Origin::Origin(void)
{
Placement.StatusBits.set(3, true);
Origin::Origin(void) {
ADD_PROPERTY_TYPE ( OriginFeatures, (0), 0, App::Prop_Hidden,
"Axis and baseplanes controlled by the origin" );
}
Origin::~Origin(void)
{
{ }
App::OriginFeature *Origin::getOriginFeature( const char *role) const {
const auto & features = OriginFeatures.getValues ();
auto featIt = std::find_if (features.begin(), features.end(),
[role] (App::DocumentObject *obj) {
return obj->isDerivedFrom ( App::OriginFeature::getClassTypeId () ) &&
strcmp (static_cast<App::OriginFeature *>(obj)->Role.getValue(), role) == 0;
} );
if (featIt != features.end()) {
return static_cast<App::OriginFeature *>(*featIt);
} else {
std::stringstream err;
err << "Origin \"" << getNameInDocument () << "\" doesn't contain feature with role \""
<< role << '"';
throw Base::Exception ( err.str().c_str () );
}
}
App::Line *Origin::getAxis( const char *role ) const {
App::OriginFeature *feat = getOriginFeature (role);
if ( feat->isDerivedFrom(App::Line::getClassTypeId () ) ) {
return static_cast<App::Line *> (feat);
} else {
std::stringstream err;
err << "Origin \"" << getNameInDocument () << "\" contains bad Axis object for role \""
<< role << '"';
throw Base::Exception ( err.str().c_str () );
}
}
App::Plane *Origin::getPlane( const char *role ) const {
App::OriginFeature *feat = getOriginFeature (role);
if ( feat->isDerivedFrom(App::Plane::getClassTypeId () ) ) {
return static_cast<App::Plane *> (feat);
} else {
std::stringstream err;
err << "Origin \"" << getNameInDocument () << "\" comtains bad Plane object for role \""
<< role << '"';
throw Base::Exception ( err.str().c_str () );
}
}
bool Origin::hasObject (DocumentObject *obj) const {
const auto & features = OriginFeatures.getValues ();
return std::find (features.begin(), features.end(), obj) != features.end ();
}
short Origin::mustExecute(void) const {
if (OriginFeatures.isTouched ()) {
return 1;
} else {
return DocumentObject::mustExecute();
}
}
App::DocumentObjectExecReturn *Origin::execute(void) {
try { // try to find all base axis and planes in the origin
for (const char* role: AxisRoles) {
App::Line *axis = getAxis (role);
assert(axis);
}
for (const char* role: PlaneRoles) {
App::Plane *plane = getPlane (role);
assert(plane);
}
} catch (const Base::Exception &ex) {
setError ();
return new App::DocumentObjectExecReturn ( ex.what () );
}
// purgeError ();
return DocumentObject::execute ();
}
void Origin::setupObject () {
const static struct {
const Base::Type type;
const char *role;
Base::Rotation rot;
} setupData [] = {
{App::Line::getClassTypeId(), "X_Axis", Base::Rotation () },
{App::Line::getClassTypeId(), "Y_Axis", Base::Rotation ( Base::Vector3d (1,1,1), M_PI*2/3 ) },
{App::Line::getClassTypeId(), "Z_Axis", Base::Rotation ( Base::Vector3d (1,1,1), M_PI*4/3 ) },
{App::Plane::getClassTypeId (), "XY_Plane", Base::Rotation () },
{App::Plane::getClassTypeId (), "XZ_Plane", Base::Rotation ( Base::Vector3d (0,1,1), M_PI ), },
{App::Plane::getClassTypeId (), "YZ_Plane", Base::Rotation ( Base::Vector3d (1,1,1), M_PI*2/3 ) },
};
App::Document *doc = getDocument ();
std::vector<App::DocumentObject *> links;
for (auto data: setupData) {
std::string objName = doc->getUniqueObjectName ( data.role );
App::DocumentObject *featureObj = doc->addObject ( data.type.getName(), objName.c_str () );
assert ( featureObj && featureObj->isDerivedFrom ( App::OriginFeature::getClassTypeId () ) );
App::OriginFeature *feature = static_cast <App::OriginFeature *> ( featureObj );
feature->Placement.setValue ( Base::Placement ( Base::Vector3d (), data.rot ) );
feature->Role.setValue ( data.role );
links.push_back (feature);
}
OriginFeatures.setValues (links);
}
void Origin::unsetupObject () {
const auto &objsLnk = OriginFeatures.getValues ();
// Copy to set to assert we won't call methode more then one time for each object
std::set<App::DocumentObject *> objs (objsLnk.begin(), objsLnk.end());
// Remove all controlled objects
for (auto obj: objs ) {
// Check that previous deletes wasn't inderectly removed one of our objects
const auto &objsLnk = OriginFeatures.getValues ();
if ( std::find(objsLnk.begin(), objsLnk.end(), obj) != objsLnk.end()) {
if ( ! obj->isDeleting () ) {
obj->getDocument ()->remObject (obj->getNameInDocument());
}
}
}
}

View File

@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2015 *
* Copyright (c) Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> 2015 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -24,23 +25,21 @@
#ifndef APP_Origin_H
#define APP_Origin_H
#include "GeoFeatureGroup.h"
#include "GeoFeature.h"
#include "OriginFeature.h"
#include "PropertyLinks.h"
namespace App
{
/** Base class of all geometric document objects.
*/
class AppExport Origin : public App::GeoFeatureGroup
class AppExport Origin : public App::DocumentObject
{
PROPERTY_HEADER(App::Origin);
public:
/// Constructor
Origin(void);
virtual ~Origin();
@ -49,11 +48,95 @@ public:
virtual const char* getViewProviderName(void) const {
return "Gui::ViewProviderOrigin";
}
};
//typedef App::FeaturePythonT<Origin> OriginPython;
/** @name Axis and plane access
* This functions returns casted axis and planes objects and asserts they are setted correctly
* otherwice Base::Exception is thrown.
*/
///@{
// returns X axis
App::Line *getX () const {
return getAxis ("X_Axis");
}
// returns Y axis
App::Line *getY () const {
return getAxis ("Y_Axis");
}
// returns Z axis
App::Line *getZ () const {
return getAxis ("Z_Axis");
}
// returns XY plane
App::Plane *getXY () const {
return getPlane ("XY_Plane");
}
// returns XZ plane
App::Plane *getXZ () const {
return getPlane ("XZ_Plane");
}
// returns YZ plane
App::Plane *getYZ () const {
return getPlane ("YZ_Plane");
}
/// Returns all axis objects to iterate on them
std::vector<App::Line *> axes() const {
return { getX(), getY(), getZ() };
}
/// Returns all base planes objects to iterate on them
std::vector<App::Plane *> planes() const {
return { getXY(), getXZ(), getYZ() };
}
/// Returns all controled objects (both planes and axis) to iterate on them
std::vector<App::OriginFeature *> baseObjects() const {
return { getX(), getY(), getZ(), getXY(), getXZ(), getYZ() };
}
/// Returns an axis by it's name
App::OriginFeature *getOriginFeature( const char* role ) const;
/// Returns an axis by it's name
App::Line *getAxis( const char* role ) const;
/// Returns an axis by it's name
App::Plane *getPlane( const char* role ) const;
///@}
/// Returns true if the given object is part of the origin
bool hasObject (DocumentObject *obj) const;
/// Returns the default bounding box of the origin (use this if you confused what should be s )
// TODO Delete me if not really needed (2015-09-01, Fat-Zer)
static Base::BoundBox3d defaultBoundBox();
/// Returns true on changing OriginFeature set
virtual short mustExecute(void) const;
/// Axis types
static const char* AxisRoles[3];
/// Baseplane types
static const char* PlaneRoles[3];
// Axis links
PropertyLinkList OriginFeatures;
protected:
/// Checks integrity of the Origin
virtual App::DocumentObjectExecReturn *execute(void);
/// Creates all corresponding Axises and Planes objects for the origin if they not linked yet
virtual void setupObject ();
/// Removes all planes and axis if they are still linked to the document
virtual void unsetupObject ();
private:
struct SetupData;
void setupOriginFeature (App::PropertyLink &featProp, const SetupData &data);
};
} //namespace App
#endif // APP_Origin_H

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2015 *
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -20,43 +20,50 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include "Document.h"
#include "Origin.h"
#include "Line.h"
#include "OriginFeature.h"
using namespace App;
PROPERTY_SOURCE(App::OriginFeature, App::GeoFeature)
PROPERTY_SOURCE(App::Plane, App::OriginFeature)
PROPERTY_SOURCE(App::Line, App::OriginFeature)
PROPERTY_SOURCE(App::Line, App::GeoFeature)
//===========================================================================
// Feature
//===========================================================================
Line::Line(void)
OriginFeature::OriginFeature()
{
ADD_PROPERTY(LineType,(""));
ADD_PROPERTY_TYPE ( Role, (""), 0, App::Prop_ReadOnly, "Role of the feature in the Origin" ) ;
// Set placement to read-only
Placement.StatusBits.set(3, true);
}
Line::~Line(void)
{
OriginFeature::~OriginFeature()
{ }
// Base::BoundBox3d OriginFeature::getBoundBox()
// {
// return Base::BoundBox3d(-10, -10, -10, 10, 10, 10);
// }
Origin * OriginFeature::getOrigin () {
App::Document *doc = getDocument();
auto origins = doc->getObjectsOfType ( App::Origin::getClassTypeId() );
auto originIt= std::find_if (origins.begin(), origins.end(), [this] (DocumentObject *origin) {
assert ( origin->isDerivedFrom ( App::Origin::getClassTypeId() ) );
return static_cast<App::Origin *> (origin)->hasObject (this);
} );
if (originIt == origins.end()) {
return 0;
} else {
assert ( (*originIt)->isDerivedFrom ( App::Origin::getClassTypeId() ) );
return static_cast<App::Origin *> (*originIt);
}
}
Base::BoundBox3d Line::getBoundBox()
{
return Base::BoundBox3d(-10, -10, -10, 10, 10, 10);
}

View File

@ -20,50 +20,50 @@
* *
***************************************************************************/
#ifndef _AppPlane_h_
#define _AppPlane_h_
#ifndef ORIGINFEATURE_H_6ZWJPB5V
#define ORIGINFEATURE_H_6ZWJPB5V
#include "GeoFeature.h"
#include "PropertyGeo.h"
namespace App
{
class Origin;
/** Plane Object
* Used to define planar support for all kind of operations in the document space
*/
class AppExport Plane: public App::GeoFeature
class AppExport OriginFeature: public App::GeoFeature
{
PROPERTY_HEADER(App::Plane);
PROPERTY_HEADER(App::OriginFeature);
public:
/// additional information about the feature usage (e.g. "BasePlane-XY" or "Axis-X" in a Origin)
PropertyString Role;
/// Constructor
Plane(void);
virtual ~Plane();
/// additional information about the plane usage (e.g. "BasePlane-xy" in a Part)
PropertyString PlaneType;
/// Constructor
OriginFeature(void);
virtual ~OriginFeature();
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
return "Gui::ViewProviderPlane";
}
/// Return the bounding box of the plane (this is always a fixed size)
static Base::BoundBox3d getBoundBox();
/// Finds the origin object this plane belongs to
App::Origin *getOrigin ();
};
class AppExport Plane: public App::OriginFeature {
PROPERTY_HEADER(App::OriginFeature);
public:
virtual const char* getViewProviderName(void) const {
return "Gui::ViewProviderPlane";
}
};
class AppExport Line: public App::OriginFeature {
PROPERTY_HEADER(App::OriginFeature);
public:
virtual const char* getViewProviderName(void) const {
return "Gui::ViewProviderLine";
}
};
} //namespace App
#endif
#endif /* end of include guard: ORIGINFEATURE_H_6ZWJPB5V */

View File

@ -27,7 +27,6 @@
#endif
#include <App/Document.h>
#include <App/Plane.h>
#include "Part.h"
#include "PartPy.h"

View File

@ -1,62 +0,0 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2012 *
* *
* 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 "Plane.h"
using namespace App;
PROPERTY_SOURCE(App::Plane, App::GeoFeature)
//===========================================================================
// Feature
//===========================================================================
Plane::Plane(void)
{
ADD_PROPERTY(PlaneType,(""));
Placement.StatusBits.set(3, true);
}
Plane::~Plane(void)
{
}
Base::BoundBox3d Plane::getBoundBox()
{
return Base::BoundBox3d(-10, -10, -10, 10, 10, 10);
}

View File

@ -109,9 +109,9 @@ std::vector<std::string> ViewProviderGeoFeatureGroup::getDisplayModes(void) cons
void ViewProviderGeoFeatureGroup::updateData(const App::Property* prop)
{
if (prop->isDerivedFrom(App::PropertyPlacement::getClassTypeId()) &&
strcmp(prop->getName(), "Placement") == 0) {
setTransformation ( static_cast<const App::PropertyPlacement*>(prop)->getValue().toMatrix() );
App::GeoFeatureGroup *obj = static_cast<App::GeoFeatureGroup*> ( getObject() );
if (prop == &obj->Placement) {
setTransformation ( obj->Placement.getValue().toMatrix() );
} else {
ViewProviderDocumentObjectGroup::updateData ( prop );
}

View File

@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2015 *
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -26,11 +27,15 @@
#ifndef _PreComp_
# include <QApplication>
# include <QPixmap>
# include <Inventor/actions/SoGetBoundingBoxAction.h>
# include <Inventor/nodes/SoSeparator.h>
# include <boost/bind.hpp>
#endif
#include <Base/Vector3D.h>
#include <App/Origin.h>
#include <App/Plane.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <App/Document.h>
/// Here the FreeCAD includes sorted by Base,App,Gui......
@ -46,125 +51,170 @@
#include "View3DInventorViewer.h"
#include "Base/Console.h"
#include <boost/bind.hpp>
#include <Inventor/actions/SoGetBoundingBoxAction.h>
#include <Inventor/nodes/SoSeparator.h>
#include <App/Origin.h>
using namespace Gui;
PROPERTY_SOURCE(Gui::ViewProviderOrigin, Gui::ViewProviderGeoFeatureGroup)
PROPERTY_SOURCE(Gui::ViewProviderOrigin, Gui::ViewProviderDocumentObject)
/**
* Creates the view provider for an object group.
*/
ViewProviderOrigin::ViewProviderOrigin()
: tempVisMode(false)
ViewProviderOrigin::ViewProviderOrigin()
{
ADD_PROPERTY_TYPE ( Size, (Base::Vector3d(10,10,10)), 0, App::Prop_ReadOnly,
"The displayed size of the origin" );
sPixmap = "CoordinateSystem";
Visibility.setValue(false);
pcGroupChildren = new SoGroup();
pcGroupChildren->ref();
}
ViewProviderOrigin::~ViewProviderOrigin()
{
ViewProviderOrigin::~ViewProviderOrigin() {
pcGroupChildren->unref();
pcGroupChildren = 0;
}
bool ViewProviderOrigin::canDragObjects() const
{
return false;
std::vector<App::DocumentObject*> ViewProviderOrigin::claimChildren(void) const {
return static_cast<App::Origin*>( getObject() )->OriginFeatures.getValues ();
}
bool ViewProviderOrigin::canDropObjects() const
{
return false;
std::vector<App::DocumentObject*> ViewProviderOrigin::claimChildren3D(void) const {
return claimChildren ();
}
bool ViewProviderOrigin::setEdit(int ModNum)
void ViewProviderOrigin::attach(App::DocumentObject* pcObject)
{
return true;
addDisplayMaskMode(pcGroupChildren, "Base");
Gui::ViewProviderDocumentObject::attach(pcObject);
}
void ViewProviderOrigin::unsetEdit(int ModNum)
std::vector<std::string> ViewProviderOrigin::getDisplayModes(void) const
{
return { "Base" };
}
QIcon ViewProviderOrigin::getIcon(void) const
void ViewProviderOrigin::setDisplayMode(const char* ModeName)
{
return Gui::ViewProvider::getIcon();
if (strcmp(ModeName, "Base") == 0)
setDisplayMaskMode("Base");
ViewProviderDocumentObject::setDisplayMode(ModeName);
}
void ViewProviderOrigin::setTemporaryVisibilityMode(bool onoff, Gui::Document* doc)
{
tempVisDoc = doc;
if(tempVisMode == onoff)
return;
tempVisMode = onoff;
if(onoff && doc) {
App::Origin* origin = static_cast<App::Origin*>(pcObject);
tempVisMap.clear();
for(App::DocumentObject* obj : origin->getObjects()) {
Gui::ViewProvider* vp = doc->getViewProvider(obj);
if(vp) {
tempVisMap[vp] = vp->isVisible();
vp->setVisible(false);
void ViewProviderOrigin::setTemporaryVisibility(bool axis, bool plane) {
App::Origin* origin = static_cast<App::Origin*>( getObject() );
bool saveState = tempVisMap.empty();
try {
// Remember & Set axis visability
for(App::DocumentObject* obj : origin->axes()) {
if (obj) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
if(vp) {
if (saveState) {
tempVisMap[vp] = vp->isVisible();
}
vp->setVisible(axis);
}
}
}
tempVisMap[this] = isVisible();
setVisible(true);
// Remember & Set plane visability
for(App::DocumentObject* obj : origin->planes()) {
if (obj) {
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj);
if(vp) {
if (saveState) {
tempVisMap[vp] = vp->isVisible();
}
vp->setVisible(plane);
}
}
}
} catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what() );
}
else if(!onoff) {
for(std::pair<Gui::ViewProvider*, bool> pair : tempVisMap)
pair.first->setVisible(pair.second);
// Remember & Set self visability
tempVisMap[this] = isVisible();
setVisible(true);
}
void ViewProviderOrigin::resetTemporaryVisibility() {
for(std::pair<Gui::ViewProvider*, bool> pair : tempVisMap) {
pair.first->setVisible(pair.second);
}
tempVisMap.clear ();
}
void ViewProviderOrigin::setTemporaryVisibility(App::DocumentObject* obj, bool onoff)
{
Gui::ViewProvider* vp = tempVisDoc->getViewProvider(obj);
if(vp) {
vp->setVisible(onoff);
bool ViewProviderOrigin::isTemporaryVisibility() {
return !tempVisMap.empty();
}
void ViewProviderOrigin::onChanged(const App::Property* prop) {
if (prop == &Size) {
try {
Gui::Application *app = Gui::Application::Instance;
Base::Vector3d sz = Size.getValue ();
App::Origin* origin = static_cast<App::Origin*>(pcObject);
// find planes view providers
Gui::ViewProviderPlane* vpPlaneXY, *vpPlaneXZ, *vpPlaneYZ;
vpPlaneXY = static_cast<Gui::ViewProviderPlane *> ( app->getViewProvider ( origin->getXY () ) );
vpPlaneXZ = static_cast<Gui::ViewProviderPlane *> ( app->getViewProvider ( origin->getXZ () ) );
vpPlaneYZ = static_cast<Gui::ViewProviderPlane *> ( app->getViewProvider ( origin->getYZ () ) );
// set their sizes
if (vpPlaneXY) {
vpPlaneXY->Size.setValue ( std::max ( sz.x, sz.y ) );
}
if (vpPlaneXZ) {
vpPlaneXZ->Size.setValue ( std::max ( sz.x, sz.z ) );
}
if (vpPlaneYZ) {
vpPlaneYZ->Size.setValue ( std::max ( sz.y, sz.z ) );
}
//find Lines view providers
Gui::ViewProviderLine* vpLineX, *vpLineY, *vpLineZ;
vpLineX = static_cast<Gui::ViewProviderLine *> ( app->getViewProvider ( origin->getX () ) );
vpLineY = static_cast<Gui::ViewProviderLine *> ( app->getViewProvider ( origin->getY () ) );
vpLineZ = static_cast<Gui::ViewProviderLine *> ( app->getViewProvider ( origin->getZ () ) );
if (vpLineX) {
vpLineX->Size.setValue ( std::min ( vpPlaneXY->Size.getValue(), vpPlaneXZ->Size.getValue() ) );
}
if (vpLineY) {
vpLineY->Size.setValue ( std::min ( vpPlaneXY->Size.getValue(), vpPlaneYZ->Size.getValue() ) );
}
if (vpLineZ) {
vpLineZ->Size.setValue ( std::min ( vpPlaneXZ->Size.getValue(), vpPlaneYZ->Size.getValue() ) );
}
} catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what() );
}
}
ViewProviderDocumentObject::onChanged ( prop );
}
bool ViewProviderOrigin::isTemporaryVisibilityMode()
{
return tempVisMode;
}
bool ViewProviderOrigin::onDelete(const std::vector<std::string> &) {
App::Origin* origin = static_cast<App::Origin*>( getObject() );
void ViewProviderOrigin::setTemporaryVisibilityAxis(bool onoff)
{
for(App::DocumentObject* obj : static_cast<App::Origin*>(pcObject)->getObjectsOfType(App::Line::getClassTypeId())) {
Gui::ViewProvider* vp = tempVisDoc->getViewProvider(obj);
vp->setVisible(onoff);
if ( !origin->getInList().empty() ) {
return false;
}
}
void ViewProviderOrigin::setTemporaryVisibilityPlanes(bool onoff)
{
for(App::DocumentObject* obj : static_cast<App::Origin*>(pcObject)->getObjectsOfType(App::Plane::getClassTypeId())) {
Gui::ViewProvider* vp = tempVisDoc->getViewProvider(obj);
vp->setVisible(onoff);
for (auto obj: origin->OriginFeatures.getValues() ) {
Gui::Command::doCommand( Gui::Command::Doc, "App.getDocument(\"%s\").removeObject(\"%s\")",
obj->getDocument()->getName(), obj->getNameInDocument() );
}
}
// Python feature -----------------------------------------------------------------------
namespace Gui {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Gui::ViewProviderOriginPython, Gui::ViewProviderOrigin)
/// @endcond
// explicit template instantiation
template class GuiExport ViewProviderPythonFeatureT<ViewProviderOrigin>;
return true;
}

View File

@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2015 *
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
@ -24,50 +25,62 @@
#ifndef GUI_VIEWPROVIDER_ViewProviderOrigin_H
#define GUI_VIEWPROVIDER_ViewProviderOrigin_H
#include <App/PropertyGeo.h>
#include "ViewProviderGeoFeatureGroup.h"
#include <App/PropertyStandard.h>
#include <App/Origin.h>
#include "ViewProviderDocumentObject.h"
namespace Gui {
class Document;
class GuiExport ViewProviderOrigin : public ViewProviderGeoFeatureGroup
class Document;
class GuiExport ViewProviderOrigin : public ViewProviderDocumentObject
{
PROPERTY_HEADER(Gui::ViewProviderOrigin);
public:
/// Size of the origin as setted by the part.
App::PropertyVector Size;
/// constructor.
ViewProviderOrigin();
/// destructor.
virtual ~ViewProviderOrigin();
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
virtual bool canDragObjects() const;
virtual bool canDropObjects() const;
/// @name Override methodes
///@{
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
virtual std::vector<App::DocumentObject*> claimChildren3D(void) const;
virtual SoGroup* getChildRoot(void) const {return pcGroupChildren;};
virtual void attach(App::DocumentObject* pcObject);
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void setDisplayMode(const char* ModeName);
///@}
/** @name Temporary visability mode
* Control the visability of origin and associated objects when needed
*/
///@{
/// Set temporary visability of some of origin's objects e.g. while rotating or mirroring
void setTemporaryVisibility (bool axis, bool planes);
/// Returns true if the origin in temporary visability mode
bool isTemporaryVisibility ();
/// Reset the visability
void resetTemporaryVisibility ();
///@}
/// Returns default size. Use this if it is not possible to determin apropriate size by other means
static double defaultSize() {return 10.;}
protected:
virtual void onChanged(const App::Property* prop);
virtual bool onDelete(const std::vector<std::string> &);
virtual QIcon getIcon(void) const;
//temporary mode to override visibility of grouped objects
void setTemporaryVisibilityMode(bool onoff, Gui::Document* doc = NULL);
bool isTemporaryVisibilityMode();
void setTemporaryVisibilityAxis(bool onoff);
void setTemporaryVisibilityPlanes(bool onoff);
void setTemporaryVisibility(App::DocumentObject* obj, bool onoff);
private:
bool tempVisMode;
Gui::Document* tempVisDoc;
std::map<Gui::ViewProvider*, bool> tempVisMap;
};
SoGroup *pcGroupChildren;
typedef ViewProviderPythonFeatureT<ViewProviderOrigin> ViewProviderOriginPython;
std::map<Gui::ViewProvider*, bool> tempVisMap;
};
} // namespace Gui

View File

@ -30,12 +30,12 @@
#include <App/Part.h>
#include <App/Origin.h>
#include <App/Plane.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <App/Document.h>
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include "ViewProviderPart.h"
#include "ViewProviderOrigin.h"
#include "ViewProviderPlane.h"
#include "ViewProviderLine.h"
#include "Application.h"
@ -92,6 +92,7 @@ void ViewProviderPart::updateData(const App::Property* prop)
void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App::Property&)
{
Gui::Document* gdoc = Gui::Application::Instance->getDocument ( getObject()->getDocument() );
App::Part* part = static_cast<App::Part*>(pcObject);
if ( &obj == pcObject || (
obj.getTypeId() != App::Origin::getClassTypeId() &&
@ -118,14 +119,9 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
}
};
if(bbox.getSize().length() < 1e-7) {
bbox = SbBox3f(10., 10., 10., 10., 10., 10.);
}
//get the bounding box values
SbVec3f size = bbox.getSize()*1.3;
SbVec3f max = bbox.getMax()*1.3;
SbVec3f min = bbox.getMin()*1.3;
SbVec3f max = bbox.getMax();
SbVec3f min = bbox.getMin();
auto origins = part->getObjectsOfType(App::Origin::getClassTypeId());
if (origins.empty())
@ -134,34 +130,20 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
if(!origin)
return;
//get the planes and set their values
std::vector<App::DocumentObject*> planes = origin->getObjectsOfType(App::Plane::getClassTypeId());
for (std::vector<App::DocumentObject*>::const_iterator p = planes.begin(); p != planes.end(); p++) {
Gui::ViewProviderPlane* vp = dynamic_cast<Gui::ViewProviderPlane*>(Gui::Application::Instance->getViewProvider(*p));
if(vp) {
if (strcmp(App::Part::BaseplaneTypes[0], dynamic_cast<App::Plane*>(*p)->PlaneType.getValue()) == 0)
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[1])),std::max(max[0], max[1])));
else if (strcmp(App::Part::BaseplaneTypes[1], dynamic_cast<App::Plane*>(*p)->PlaneType.getValue()) == 0)
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[2])),std::max(max[0], max[2])));
else if (strcmp(App::Part::BaseplaneTypes[2], dynamic_cast<App::Plane*>(*p)->PlaneType.getValue()) == 0)
vp->Size.setValue(std::max(std::abs(std::min(min[1], min[2])),std::max(max[1], max[2])));
}
Base::Vector3d size;
for (uint_fast8_t i=0; i<3; i++) {
size[i] = std::max ( fabs ( max[i] ), fabs ( min[i] ) );
if (size[i] < 1e-7) { // TODO replace it with some non-magick value (2015-08-31, Fat-Zer)
size[i] = ViewProviderOrigin::defaultSize();
}
}
//get the lines and set their values
std::vector<App::DocumentObject*> lines = origin->getObjectsOfType(App::Line::getClassTypeId());
for (std::vector<App::DocumentObject*>::const_iterator p = lines.begin(); p != lines.end(); p++) {
Gui::ViewProviderLine* vp = dynamic_cast<Gui::ViewProviderLine*>(Gui::Application::Instance->getViewProvider(*p));
if(vp) {
if (strcmp(App::Part::BaselineTypes[0], dynamic_cast<App::Line*>(*p)->LineType.getValue()) == 0)
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[1])),std::max(max[0], max[1])));
else if (strcmp(App::Part::BaselineTypes[1], dynamic_cast<App::Line*>(*p)->LineType.getValue()) == 0)
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[2])),std::max(max[0], max[2])));
else if (strcmp(App::Part::BaselineTypes[2], dynamic_cast<App::Line*>(*p)->LineType.getValue()) == 0)
vp->Size.setValue(std::max(std::abs(std::min(min[1], min[2])),std::max(max[1], max[2])));
}
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(origin);
if (vp) {
assert ( vp->isDerivedFrom ( Gui::ViewProviderOrigin::getClassTypeId () ) );
Gui::ViewProviderOrigin *vpOrigin = static_cast<Gui::ViewProviderOrigin *> (vp);
vpOrigin->Size.setValue ( size * 1.3 );
}
}
}
@ -180,14 +162,14 @@ bool ViewProviderPart::doubleClicked(void)
return true;
}
bool ViewProviderPart::onDelete(const std::vector<std::string> &)
{
if(getActiveView()->getActiveObject<App::Part*>(PARTKEY) == getObject())
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', None)", PARTKEY);
return true;
}
// commented out for thurther rewrite (2015-09-01, Fat-Zer)
// bool ViewProviderPart::onDelete(const std::vector<std::string> &)
// {
// if(getActiveView()->getActiveObject<App::Part*>(PARTKEY) == getObject())
// Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', None)", PARTKEY);
//
// return true;
// }
void ViewProviderPart::Restore(Base::XMLReader &reader)
{
@ -212,72 +194,16 @@ QIcon ViewProviderPart::getIcon() const
void ViewProviderPart::setUpPart(const App::Part *part)
{
// add the standard planes at the root of the Part
// add the origin at the root of the Part
// first check if they already exist
// FIXME: If the user renames them, they won't be found...
bool found = false;
std::vector<App::DocumentObject*> planes = part->getObjectsOfType(App::Plane::getClassTypeId());
for (std::vector<App::DocumentObject*>::const_iterator p = planes.begin(); p != planes.end(); p++) {
for (unsigned i = 0; i < 3; i++) {
if (strcmp(App::Part::BaseplaneTypes[i], dynamic_cast<App::Plane*>(*p)->PlaneType.getValue()) == 0) {
found = true;
break;
}
}
if (found) break;
}
std::vector<App::DocumentObject*> origins = part->getObjectsOfType(App::Origin::getClassTypeId());
if (!found) {
// ... and put them in the 'Origin' group
if ( origins.empty() ) {
std::string oname = part->getDocument()->getUniqueObjectName("Origin");
Gui::Command::doCommand(Gui::Command::Doc,"Origin = App.activeDocument().addObject('App::Origin','%s')", oname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"Origin.Label = '%s'", QObject::tr("Origin").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(Origin)", part->getNameInDocument());
// Add the planes ...
std::string pname = part->getDocument()->getUniqueObjectName(App::Part::BaseplaneTypes[0]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", pname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.PlaneType = '%s'", App::Part::BaseplaneTypes[0]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XY-Plane").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
pname = part->getDocument()->getUniqueObjectName(App::Part::BaseplaneTypes[1]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", pname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,1),180))");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.PlaneType = '%s'", App::Part::BaseplaneTypes[1]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XZ-Plane").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
pname = part->getDocument()->getUniqueObjectName(App::Part::BaseplaneTypes[2]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", pname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,1,1),120))");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.PlaneType = '%s'", App::Part::BaseplaneTypes[2]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
// Add the lines ...
std::string lname = part->getDocument()->getUniqueObjectName(App::Part::BaselineTypes[0]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", lname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.LineType = '%s'", App::Part::BaselineTypes[0]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("X-Axis").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
lname = part->getDocument()->getUniqueObjectName(App::Part::BaselineTypes[1]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", lname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,0,1),90))");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.LineType = '%s'", App::Part::BaselineTypes[1]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("Y-Axis").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
lname = part->getDocument()->getUniqueObjectName(App::Part::BaselineTypes[2]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", lname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,0),90))");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.LineType = '%s'", App::Part::BaselineTypes[2]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("Z-Axis").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
}
}

View File

@ -56,7 +56,7 @@ public:
virtual bool doubleClicked(void);
virtual bool onDelete(const std::vector<std::string> &);
// virtual bool onDelete(const std::vector<std::string> &);
/// helper to set up the standard content of a Part Object
static void setUpPart(const App::Part *part);

View File

@ -58,7 +58,7 @@ public:
std::vector<std::string> getDisplayModes(void) const;
void setDisplayMode(const char* ModeName);
/// indicates if the ViewProvider use the new Selection model
/// indicates if the ViewProvider use the new Selection model
virtual bool useNewSelectionModel(void) const {return true;}
/// indicates if the ViewProvider can be selected
virtual bool isSelectable(void) const ;

View File

@ -54,8 +54,7 @@
#include "Attacher.h"
#include <Base/Console.h>
#include <App/Plane.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
using namespace Part;
using namespace Attacher;
@ -614,6 +613,7 @@ void AttachEngine::readLinks(const App::PropertyLinkSubList &references,
shapes[i] = &(shape->_Shape);
}
} else if ( geof->isDerivedFrom(App::Plane::getClassTypeId()) ){
// TODO Why this assert is here? (2015-08-31, Fat-Zer)
assert(sub[i].length()==0);//no more support for "back"/"front" on planes. Use mapReversed instead.
//obtain Z axis and origin of placement
Base::Vector3d norm;

View File

@ -55,7 +55,6 @@
# include <Standard_Version.hxx>
#endif
#include <App/Plane.h>
#include "DatumFeature.h"
#include <Base/Tools.h>
#include <Base/Console.h>

View File

@ -46,7 +46,6 @@
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <App/Plane.h>
#include <App/Property.h>
#include <App/PropertyLinks.h>
#include "Part2DObject.h"

View File

@ -25,7 +25,6 @@
#ifndef _PreComp_
#endif
#include <App/Plane.h>
#include <Base/Placement.h>
#include "Feature.h"
@ -413,6 +412,7 @@ App::DocumentObjectExecReturn *Body::execute(void)
Base::BoundBox3d Body::getBoundBox()
{
// TODO review the function (2015-08-31, Fat-Zer)
Base::BoundBox3d result;
Part::Feature* tipSolid = static_cast<Part::Feature*>(Tip.getValue());
@ -422,7 +422,8 @@ Base::BoundBox3d Body::getBoundBox()
}
if (!tipSolid || tipSolid->Shape.getValue().IsNull()) {
result = App::Plane::getBoundBox();
// TODO check that all callers are correctly handle if bounding box is null (2015-08-31, Fat-Zer)
result = Base::BoundBox3d ();
} else {
result = tipSolid->Shape.getShape().getBoundBox();
}
@ -439,9 +440,6 @@ Base::BoundBox3d Body::getBoundBox()
} else if ((*m)->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(*m);
result.Add(plane->getBasePoint());
} else if ((*m)->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
// Note: We only take into account the base planes here
result.Add(Base::Vector3d(0,0,0));
}
}

View File

@ -29,9 +29,7 @@
#include "DatumPoint.h"
#include "DatumPlane.h"
#include "DatumLine.h"
#include <App/Plane.h>
#include <App/Part.h>
#include <App/Line.h>
#include <Base/Exception.h>
#include <gp_Pln.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>

View File

@ -61,9 +61,8 @@
#endif
#include <QObject>
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <App/Part.h>
#include <App/Line.h>
#include "DatumPoint.h"
#include "DatumLine.h"
#include "DatumPlane.h"

View File

@ -59,9 +59,7 @@
#endif
#include <QObject>
#include <App/Plane.h>
#include <App/Part.h>
#include <App/Line.h>
#include "DatumPoint.h"
#include "DatumLine.h"
#include "DatumPlane.h"

View File

@ -59,8 +59,6 @@
#endif
#include <QObject>
#include <App/Plane.h>
#include <App/Line.h>
#include <App/Part.h>
#include "DatumPoint.h"
#include "DatumLine.h"

View File

@ -36,8 +36,7 @@
#include <Base/Exception.h>
#include "App/Document.h"
#include "App/Plane.h"
#include <App/Line.h>
#include "App/OriginFeature.h"
#include "Body.h"
#include "Feature.h"
#include "Mod/Part/App/DatumFeature.h"
@ -140,8 +139,7 @@ const Part::TopoShape Feature::getBaseTopoShape() const {
bool Feature::isDatum(const App::DocumentObject* feature)
{
return feature->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) ||
feature->getTypeId().isDerivedFrom(App::Line::getClassTypeId()) ||
return feature->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) ||
feature->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId());
}

View File

@ -47,7 +47,7 @@
# include <BRepBuilderAPI_MakeEdge.hxx>
#endif
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <Base/Tools.h>
#include <Base/Exception.h>
#include <Mod/Part/App/TopoShape.h>

View File

@ -36,8 +36,7 @@
#include "FeatureLinearPattern.h"
#include "DatumPlane.h"
#include "DatumLine.h"
#include <App/Plane.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <Base/Axis.h>
#include <Base/Exception.h>
#include <Mod/Part/App/TopoShape.h>

View File

@ -31,7 +31,7 @@
#endif
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <Base/Exception.h>
#include "FeatureMirrored.h"
#include "DatumPlane.h"

View File

@ -38,7 +38,7 @@
#include <Base/Tools.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/Part2DObject.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
using namespace PartDesign;

View File

@ -67,11 +67,10 @@
#include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <App/Plane.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <App/Part.h>
#include <Mod/Part/App/modelRefine.h>
#include "FeatureSketchBased.h"
@ -1054,12 +1053,7 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std:
if (pcReferenceAxis->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
const App::Line* line = static_cast<const App::Line*>(pcReferenceAxis);
base = Base::Vector3d(0,0,0);
if( strcmp(line->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
dir = Base::Vector3d(1,0,0);
else if( strcmp(line->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
dir = Base::Vector3d(0,1,0);
else if( strcmp(line->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
dir = Base::Vector3d(0,0,1);
line->Placement.getValue().multVec (Base::Vector3d (1,0,0), dir);
// Check that axis is perpendicular with sketch plane!
if (sketchplane.Axis().Direction().Angle(gp_Dir(dir.x, dir.y, dir.z)) < Precision::Angular())

View File

@ -35,7 +35,7 @@
#include <algorithm>
#include <App/DocumentObjectGroup.h>
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <App/Part.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
@ -307,11 +307,12 @@ void CmdPartDesignNewSketch::activated(int iMsg)
}
if (!pcActiveBody->hasFeature(obj)) {
// TODO check what the heck is going on here (2015-08-31, Fat-Zer)
bool isBasePlane = false;
if(obj->isDerivedFrom(App::Plane::getClassTypeId())) {
App::Plane* pfeat = static_cast<App::Plane*>(obj);
for (unsigned i = 0; i < 3; i++) {
if (strcmp(App::Part::BaseplaneTypes[i], pfeat->PlaneType.getValue()) == 0) {
if (strcmp(App::Part::BaseplaneTypes[i], pfeat->Role.getValue()) == 0) {
isBasePlane = true;
break;
}
@ -360,7 +361,7 @@ void CmdPartDesignNewSketch::activated(int iMsg)
if((*p)->isDerivedFrom(App::Plane::getClassTypeId())) {
App::Plane* pfeat = static_cast<App::Plane*>(*p);
for (unsigned i = 0; i < 3; i++) {
if (strcmp(App::Part::BaseplaneTypes[i], pfeat->PlaneType.getValue()) == 0) {
if (strcmp(App::Part::BaseplaneTypes[i], pfeat->Role.getValue()) == 0) {
if(pcActivePart->hasObject(pfeat, true))
status.push_back(PartDesignGui::TaskFeaturePick::basePlane);
else

View File

@ -30,9 +30,8 @@
# include <BRepAdaptor_Surface.hxx>
#endif
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <App/Part.h>
#include <App/Line.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Mod/Part/App/TopoShape.h>

View File

@ -34,8 +34,8 @@
#include <Base/Console.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/Plane.h>
#include <App/Line.h>
#include <App/Origin.h>
#include <App/OriginFeature.h>
#include <App/Part.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
@ -67,8 +67,7 @@ const QString makeRefString(const App::DocumentObject* obj, const std::string& s
if (obj == NULL)
return QObject::tr("No reference selected");
if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) ||
obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId()) ||
if (obj->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) ||
obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()))
// App::Plane, Liine or Datum feature
return QString::fromAscii(obj->getNameInDocument());
@ -217,10 +216,8 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
origin->setTemporaryVisibilityAxis(true);
origin->setTemporaryVisibilityPlanes(true);
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->setTemporaryVisibility(true, true);
}
}
if (pcDatum->Support.getSize() == 0)
@ -402,8 +399,7 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
std::string subname = msg.pSubName;
// Remove subname for planes and datum features
if (selObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) ||
selObj->getTypeId().isDerivedFrom(App::Line::getClassTypeId()) ||
if (selObj->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) ||
selObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()))
subname = "";
@ -778,8 +774,8 @@ TaskDatumParameters::~TaskDatumParameters()
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(false);
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->resetTemporaryVisibility();
}
}

View File

@ -32,6 +32,8 @@
#include <Gui/Document.h>
#include <Gui/ViewProviderOrigin.h>
#include <App/Document.h>
#include <App/Origin.h>
#include <App/OriginFeature.h>
#include <App/Part.h>
#include <Base/Tools.h>
#include <Base/Reader.h>
@ -85,32 +87,43 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
connect(ui->nobodyRadioIndependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->nobodyRadioXRef, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
auto guidoc = Gui::Application::Instance->activeDocument();
auto origin_obj = App::GetApplication().getActiveDocument()->getObjectsOfType<App::Origin>();
enum { axisBit=0, planeBit = 1};
// Note generally there shouldn't be more then one origin
std::map <App::Origin*, std::bitset<2> > originVisStatus;
auto statusIt = status.cbegin();
auto objIt = objects.begin();
assert(status.size() == objects.size());
std::vector<featureStatus>::const_iterator st = status.begin();
for (std::vector<App::DocumentObject*>::const_iterator o = objects.begin(); o != objects.end(); o++) {
QListWidgetItem* item = new QListWidgetItem(QString::fromAscii((*o)->getNameInDocument()) +
QString::fromAscii(" (") + getFeatureStatusString(*st) + QString::fromAscii(")"));
for (; statusIt != status.end(); ++statusIt, ++objIt) {
QListWidgetItem* item = new QListWidgetItem(
QString::fromAscii((*objIt)->getNameInDocument()) +
QString::fromAscii(" (") + getFeatureStatusString(*statusIt) + QString::fromAscii(")") );
ui->listWidget->addItem(item);
//check if we need to set any origin in temporary visibility mode
for(App::Origin* obj : origin_obj) {
if(obj->hasObject(*o) && (*st != invalidShape)) {
Gui::ViewProviderOrigin* vpo = static_cast<Gui::ViewProviderOrigin*>(guidoc->getViewProvider(obj));
if(!vpo->isTemporaryVisibilityMode())
vpo->setTemporaryVisibilityMode(true, guidoc);
if (*statusIt != invalidShape && (*objIt)->isDerivedFrom ( App::OriginFeature::getClassTypeId () )) {
App::Origin *origin = static_cast<App::OriginFeature*> (*objIt)->getOrigin ();
if (origin) {
if ((*objIt)->isDerivedFrom ( App::Plane::getClassTypeId () )) {
originVisStatus[ origin ].set (planeBit, true);
} else if ( (*objIt)->isDerivedFrom ( App::Line::getClassTypeId () ) ) {
originVisStatus[ origin ].set (axisBit, true);
}
vpo->setTemporaryVisibility(*o, true);
Gui::ViewProviderOrigin* vpo = static_cast<Gui::ViewProviderOrigin*> (
Gui::Application::Instance->getViewProvider(*objIt) );
if (vpo) {
vpo->setTemporaryVisibility( originVisStatus[origin][axisBit],
originVisStatus[origin][planeBit]);
}
origins.push_back(vpo);
break;
}
}
st++;
}
// TODO may be update origin API to show only some objects (2015-08-31, Fat-Zer)
groupLayout()->addWidget(proxy);
statuses = status;
updateList();
@ -119,7 +132,7 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
TaskFeaturePick::~TaskFeaturePick()
{
for(Gui::ViewProviderOrigin* vpo : origins)
vpo->setTemporaryVisibilityMode(false, NULL);
vpo->resetTemporaryVisibility();
}

View File

@ -34,7 +34,7 @@
#include <App/Document.h>
#include <App/Part.h>
#include <App/Origin.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -170,10 +170,9 @@ void TaskLinearPatternParameters::setupUI()
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
origin->setTemporaryVisibilityAxis(true);
}
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->setTemporaryVisibility(true, false);
}
}
}
@ -370,8 +369,8 @@ TaskLinearPatternParameters::~TaskLinearPatternParameters()
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(false);
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->resetTemporaryVisibility();
}
}

View File

@ -31,7 +31,8 @@
#include <App/Application.h>
#include <App/Document.h>
#include <App/Part.h>
#include <App/Plane.h>
#include <App/Origin.h>
#include <App/OriginFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -141,15 +142,14 @@ void TaskMirroredParameters::setupUI()
//show the parts coordinate system axis for selection
App::Part* part = getPartFor(getObject(), false);
if(part) {
if(part) {
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
origin->setTemporaryVisibilityAxis(true);
}
}
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin.front() ));
origin->setTemporaryVisibility(true, false);
}
}
}
void TaskMirroredParameters::updateUI()
@ -281,8 +281,8 @@ TaskMirroredParameters::~TaskMirroredParameters()
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(false);
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->resetTemporaryVisibility();
}
}

View File

@ -32,7 +32,8 @@
#include <App/Application.h>
#include <App/Document.h>
#include <App/Part.h>
#include <App/Line.h>
#include <App/Origin.h>
#include <App/OriginFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -163,9 +164,8 @@ void TaskPolarPatternParameters::setupUI()
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
origin->setTemporaryVisibilityAxis(true);
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->setTemporaryVisibility(true, false);
}
}
}
@ -365,7 +365,7 @@ TaskPolarPatternParameters::~TaskPolarPatternParameters()
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(false);
origin->resetTemporaryVisibility();
}
}

View File

@ -32,7 +32,7 @@
#include <App/Document.h>
#include <App/Part.h>
#include <App/Origin.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -136,15 +136,15 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider*
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
origin->setTemporaryVisibilityAxis(true);
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->setTemporaryVisibility(true, false);
}
}
}
void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
{
// TODO share the code with TaskTransformedParameters (2015-08-31, Fat-Zer)
bool oldVal_blockUpdate = blockUpdate;
blockUpdate = true;
@ -174,16 +174,21 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
}
//add part axes
App::DocumentObject* line = 0;
line = getPartLines(App::Part::BaselineTypes[0]);
if(line)
addAxisToCombo(line,"",tr("Base X axis"));
line = getPartLines(App::Part::BaselineTypes[1]);
if(line)
addAxisToCombo(line,"",tr("Base Y axis"));
line = getPartLines(App::Part::BaselineTypes[2]);
if(line)
addAxisToCombo(line,"",tr("Base Z axis"));
App::DocumentObject* obj = vp->getObject();
App::Part* part = getPartFor(obj, false);
if (part) {
try {
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
addAxisToCombo(orig->getX(),"",tr("Base X axis"));
addAxisToCombo(orig->getY(),"",tr("Base Y axis"));
addAxisToCombo(orig->getZ(),"",tr("Base Z axis"));
} catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what() );
}
}
//add "Select reference"
addAxisToCombo(0,std::string(),tr("Select reference..."));
@ -360,8 +365,8 @@ TaskRevolutionParameters::~TaskRevolutionParameters()
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
if(!app_origin.empty()) {
ViewProviderOrigin* origin;
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(false);
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(app_origin[0]));
origin->resetTemporaryVisibility();
}
}

View File

@ -33,10 +33,9 @@
#include <Base/Console.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/Plane.h>
#include <App/Part.h>
#include <App/Origin.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -200,59 +199,6 @@ void TaskSketchBasedParameters::recomputeFeature()
}
}
App::DocumentObject* TaskSketchBasedParameters::getPartPlanes(const char* str) const {
//TODO: Adjust to GRAPH handling when available
App::DocumentObject* obj = vp->getObject();
App::Part* part = getPartFor(obj, false);
if(!part)
return nullptr;
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
if(origs.size()<1)
return nullptr;
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
for(App::DocumentObject* plane : planes) {
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
return plane;
}
return nullptr;
}
App::DocumentObject* TaskSketchBasedParameters::getPartLines(const char* str) const {
//TODO: Adjust to GRAPH handling when available
App::DocumentObject* obj = vp->getObject();
App::Part* part = getPartFor(obj, false);
std::vector<App::DocumentObject*> origs;
if(part)
origs = part->getObjectsOfType(App::Origin::getClassTypeId());
else
origs = vp->getObject()->getDocument()->getObjectsOfType(App::Origin::getClassTypeId());
if(origs.size()<1)
return nullptr;
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
for(App::DocumentObject* line : lines) {
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
return line;
}
return nullptr;
}
TaskSketchBasedParameters::~TaskSketchBasedParameters()
{
}

View File

@ -56,9 +56,6 @@ protected:
QString getFaceReference(const QString& obj, const QString& sub) const;
void recomputeFeature();
App::DocumentObject* getPartPlanes(const char* str) const;
App::DocumentObject* getPartLines(const char* str) const;
protected Q_SLOTS:
void onUpdateView(bool on);

View File

@ -36,8 +36,7 @@
#include <App/Document.h>
#include <App/Part.h>
#include <App/Origin.h>
#include <App/Plane.h>
#include <App/Line.h>
#include <App/OriginFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -173,51 +172,6 @@ void TaskTransformedParameters::removeItemFromListWidget(QListWidget* widget, co
}
}
App::DocumentObject* TaskTransformedParameters::getPartPlanes(const char* str) const {
//TODO: Adjust to GRAPH handling when available
App::DocumentObject* obj = getObject();
App::Part* part = getPartFor(obj, false);
if (part) {
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
if(origs.size()<1)
return nullptr;
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
for(App::DocumentObject* plane : planes) {
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
return plane;
}
}
return nullptr;
}
App::DocumentObject* TaskTransformedParameters::getPartLines(const char* str) const {
//TODO: Adjust to GRAPH handling when available
App::DocumentObject* obj = getObject();
App::Part* part = getPartFor(obj, false);
if (part) {
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
if(origs.size()<1)
return nullptr;
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
for(App::DocumentObject* line : lines) {
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
return line;
}
}
return nullptr;
}
void TaskTransformedParameters::fillAxisCombo(ComboLinks &combolinks,
Part::Part2DObject* sketch)
{
@ -237,16 +191,21 @@ void TaskTransformedParameters::fillAxisCombo(ComboLinks &combolinks,
}
//add part axes
App::DocumentObject* line = 0;
line = getPartLines(App::Part::BaselineTypes[0]);
if(line)
combolinks.addLink(line,"",tr("Base X axis"));
line = getPartLines(App::Part::BaselineTypes[1]);
if(line)
combolinks.addLink(line,"",tr("Base Y axis"));
line = getPartLines(App::Part::BaselineTypes[2]);
if(line)
combolinks.addLink(line,"",tr("Base Z axis"));
App::DocumentObject* obj = getObject();
App::Part* part = getPartFor(obj, false);
if (part) {
try {
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
combolinks.addLink(orig->getX(),"",tr("Base X axis"));
combolinks.addLink(orig->getY(),"",tr("Base Y axis"));
combolinks.addLink(orig->getZ(),"",tr("Base Z axis"));
} catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what() );
}
}
//add "Select reference"
combolinks.addLink(0,std::string(),tr("Select reference..."));
@ -270,20 +229,24 @@ void TaskTransformedParameters::fillPlanesCombo(ComboLinks &combolinks,
}
//add part baseplanes
App::DocumentObject* plane = 0;
plane = getPartPlanes(App::Part::BaseplaneTypes[0]);
if(plane)
combolinks.addLink(plane,"",tr("Base XY plane"));
plane = getPartPlanes(App::Part::BaseplaneTypes[1]);
if(plane)
combolinks.addLink(plane,"",tr("Base XZ plane"));
plane = getPartPlanes(App::Part::BaseplaneTypes[2]);
if(plane)
combolinks.addLink(plane,"",tr("Base YZ plane"));
App::DocumentObject* obj = getObject();
App::Part* part = getPartFor(obj, false);
if (part) {
try {
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
combolinks.addLink(orig->getXY(),"",tr("Base XY plane"));
combolinks.addLink(orig->getYZ(),"",tr("Base YZ plane"));
combolinks.addLink(orig->getXZ(),"",tr("Base XZ plane"));
} catch (const Base::Exception &ex) {
Base::Console().Error ("%s\n", ex.what() );
}
}
//add "Select reference"
combolinks.addLink(0,std::string(),tr("Select reference..."));
}
void TaskTransformedParameters::recomputeFeature() {

View File

@ -189,9 +189,6 @@ protected:
virtual void clearButtons()=0;
static void removeItemFromListWidget(QListWidget* widget, const char* itemstr);
App::DocumentObject* getPartPlanes(const char* str) const;
App::DocumentObject* getPartLines(const char* str) const;
void fillAxisCombo(ComboLinks &combolinks, Part::Part2DObject *sketch);
void fillPlanesCombo(ComboLinks &combolinks, Part2DObject *sketch);

View File

@ -64,7 +64,7 @@
#include <Base/Console.h>
#include <Base/Vector3D.h>
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <Mod/Part/App/Geometry.h>
#include <Mod/Part/App/DatumFeature.h>

View File

@ -38,7 +38,7 @@
#include <Base/Tools.h>
#include <Base/QuantityPy.h>
#include <App/Document.h>
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <CXX/Objects.hxx>
// inclusion of the generated files (generated out of SketchObjectSFPy.xml)

View File

@ -33,7 +33,7 @@
#endif
#include <App/DocumentObjectGroup.h>
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/Command.h>

View File

@ -36,7 +36,7 @@
#include <Base/Exception.h>
#include <Base/Tools.h>
#include <App/Plane.h>
#include <App/OriginFeature.h>
#include <Gui/Action.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>