group coordinate planes and lines

This commit is contained in:
Stefan Tröger 2015-05-05 17:17:45 +02:00
parent 915b8ef446
commit 3f5caa2181
11 changed files with 268 additions and 23 deletions

View File

@ -98,6 +98,7 @@
#include "Plane.h"
#include "Line.h"
#include "Part.h"
#include "Origin.h"
#include "MaterialObject.h"
#include "Expression.h"
@ -1136,6 +1137,7 @@ void Application::initTypes(void)
App ::Plane ::init();
App ::Line ::init();
App ::Part ::init();
App ::Origin ::init();
// Expression classes
App ::Expression ::init();

View File

@ -78,6 +78,7 @@ SET(Document_CPP_SRCS
GeoFeatureGroupPyImp.cpp
GeoFeatureGroup.cpp
Part.cpp
Origin.cpp
Path.cpp
InventorObject.cpp
MeasureDistance.cpp
@ -109,6 +110,7 @@ SET(Document_HPP_SRCS
GeoFeature.h
GeoFeatureGroup.h
Part.h
Origin.h
Path.h
InventorObject.h
MeasureDistance.h

View File

@ -52,10 +52,6 @@ PyObject* GeoFeatureGroupPy::addObject(PyObject *args)
PyErr_SetString(PyExc_Exception, "Cannot add a GeoFeatureGroup to itself");
return NULL;
}
if (docObj->getDocumentObjectPtr()->getTypeId().isDerivedFrom(GeoFeatureGroup::getClassTypeId())) {
PyErr_SetString(PyExc_Exception, "Cannot add a GeoFeatureGroup to a GeoFeatureGroup");
return NULL;
}
getGeoFeatureGroupPtr()->addObject(docObj->getDocumentObjectPtr());

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2012 *
* Copyright (c) Stefan Tröger (stefantroeger@gmx.net) 2015 *
* *
* This file is part of the FreeCAD CAx development system. *
* *

54
src/App/Origin.cpp Normal file
View File

@ -0,0 +1,54 @@
/***************************************************************************
* 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 *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Document.h>
#include <App/Plane.h>
#include "Origin.h"
using namespace App;
PROPERTY_SOURCE(App::Origin, App::GeoFeatureGroup)
//===========================================================================
// Feature
//===========================================================================
Origin::Origin(void)
{
}
Origin::~Origin(void)
{
}

59
src/App/Origin.h Normal file
View File

@ -0,0 +1,59 @@
/***************************************************************************
* 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 APP_Origin_H
#define APP_Origin_H
#include "GeoFeatureGroup.h"
#include "PropertyLinks.h"
namespace App
{
/** Base class of all geometric document objects.
*/
class AppExport Origin : public App::GeoFeatureGroup
{
PROPERTY_HEADER(App::Origin);
public:
/// Constructor
Origin(void);
virtual ~Origin();
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
return "Gui::ViewProviderOrigin";
}
};
//typedef App::FeaturePythonT<Origin> OriginPython;
} //namespace App
#endif // APP_Origin_H

View File

@ -107,6 +107,7 @@
#include "ViewProviderPlane.h"
#include "ViewProviderLine.h"
#include "ViewProviderPart.h"
#include "ViewProviderOrigin.h"
#include "ViewProviderMaterialObject.h"
#include "Language/Translator.h"
@ -1546,6 +1547,7 @@ void Application::initTypes(void)
Gui::ViewProviderPlane ::init();
Gui::ViewProviderLine ::init();
Gui::ViewProviderPart ::init();
Gui::ViewProviderOrigin ::init();
Gui::ViewProviderMaterialObject ::init();
Gui::ViewProviderMaterialObjectPython ::init();

View File

@ -824,6 +824,7 @@ SET(Viewprovider_CPP_SRCS
ViewProviderLine.cpp
ViewProviderGeoFeatureGroup.cpp
ViewProviderPart.cpp
ViewProviderOrigin.cpp
ViewProviderMaterialObject.cpp
)
SET(Viewprovider_SRCS
@ -845,6 +846,7 @@ SET(Viewprovider_SRCS
ViewProviderLine.h
ViewProviderGeoFeatureGroup.h
ViewProviderPart.h
ViewProviderOrigin.h
ViewProviderMaterialObject.h
)
SOURCE_GROUP("View3D\\Viewprovider" FILES ${Viewprovider_SRCS})

View File

@ -0,0 +1,80 @@
/***************************************************************************
* 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 *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QApplication>
# include <QPixmap>
#endif
#include <App/Origin.h>
#include <App/Plane.h>
#include <App/Line.h>
#include <App/Document.h>
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include "ViewProviderOrigin.h"
#include "ViewProviderPlane.h"
#include "ViewProviderLine.h"
#include "Application.h"
#include "Command.h"
#include "BitmapFactory.h"
#include "Document.h"
#include "Tree.h"
#include "View3DInventor.h"
#include "View3DInventorViewer.h"
#include "Base/Console.h"
#include <boost/bind.hpp>
#include <Inventor/actions/SoGetBoundingBoxAction.h>
#include <Inventor/nodes/SoSeparator.h>
using namespace Gui;
PROPERTY_SOURCE(Gui::ViewProviderOrigin, Gui::ViewProviderGeometryObject)
/**
* Creates the view provider for an object group.
*/
ViewProviderOrigin::ViewProviderOrigin()
{
sPixmap = ":icon/delete.svg";
}
ViewProviderOrigin::~ViewProviderOrigin()
{
}
// Python feature -----------------------------------------------------------------------
namespace Gui {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Gui::ViewProviderOriginPython, Gui::ViewProviderOrigin)
/// @endcond
// explicit template instantiation
template class GuiExport ViewProviderPythonFeatureT<ViewProviderOrigin>;
}

View File

@ -0,0 +1,53 @@
/***************************************************************************
* 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 GUI_VIEWPROVIDER_ViewProviderOrigin_H
#define GUI_VIEWPROVIDER_ViewProviderOrigin_H
#include "ViewProviderGeoFeatureGroup.h"
#include <App/PropertyStandard.h>
#include <App/Origin.h>
namespace Gui {
class GuiExport ViewProviderOrigin : public ViewProviderGeoFeatureGroup
{
PROPERTY_HEADER(Gui::ViewProviderOrigin);
public:
/// constructor.
ViewProviderOrigin();
/// destructor.
virtual ~ViewProviderOrigin();
};
typedef ViewProviderPythonFeatureT<ViewProviderOrigin> ViewProviderOriginPython;
} // namespace Gui
#endif // GUI_VIEWPROVIDER_DOCUMENTOBJECTGROUP_H

View File

@ -235,45 +235,40 @@ void ViewProviderPart::setUpPart(const App::Part *part)
if (!found) {
// ... and put them in the 'Origin' group
//Gui::Command::doCommand(Gui::Command::Doc,"OGroup = App.activeDocument().addObject('App::DocumentObjectGroup','%s')", "Origin");
//Gui::Command::doCommand(Gui::Command::Doc,"OGroup.Label = '%s'", QObject::tr("Origin").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"Origin = App.activeDocument().addObject('App::Origin','%s')", "Origin");
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 ...
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%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)", part->getNameInDocument());
//Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", App::Part::BaseplaneTypes[1]);
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,0,0),90))");
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)", part->getNameInDocument());
//Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", App::Part::BaseplaneTypes[2]);
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.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", part->getNameInDocument());
//Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
// Add the lines ...
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%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)", part->getNameInDocument());
//Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", App::Part::BaselineTypes[1]);
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.Label = '%s'", QObject::tr("Y-Axis").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", part->getNameInDocument());
//Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", App::Part::BaselineTypes[2]);
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.Label = '%s'", QObject::tr("Z-Axis").toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", part->getNameInDocument());
//Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(OGroup)", part->getNameInDocument());
// TODO: Fold the group (is that possible through the Python interface?)
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
}
}