add base lines
This commit is contained in:
parent
e59b3cef4b
commit
915b8ef446
|
@ -96,6 +96,7 @@
|
|||
#include "MeasureDistance.h"
|
||||
#include "Placement.h"
|
||||
#include "Plane.h"
|
||||
#include "Line.h"
|
||||
#include "Part.h"
|
||||
#include "MaterialObject.h"
|
||||
#include "Expression.h"
|
||||
|
@ -1133,6 +1134,7 @@ void Application::initTypes(void)
|
|||
App ::MaterialObjectPython ::init();
|
||||
App ::Placement ::init();
|
||||
App ::Plane ::init();
|
||||
App ::Line ::init();
|
||||
App ::Part ::init();
|
||||
|
||||
// Expression classes
|
||||
|
|
|
@ -84,6 +84,7 @@ SET(Document_CPP_SRCS
|
|||
Placement.cpp
|
||||
Plane.cpp
|
||||
Range.cpp
|
||||
Line.cpp
|
||||
Transactions.cpp
|
||||
VRMLObject.cpp
|
||||
MaterialObject.cpp
|
||||
|
@ -114,6 +115,7 @@ SET(Document_HPP_SRCS
|
|||
Placement.h
|
||||
Plane.h
|
||||
Range.h
|
||||
Line.h
|
||||
Transactions.h
|
||||
VRMLObject.h
|
||||
MaterialObject.h
|
||||
|
|
225
src/App/CMakeLists.txt.orig
Normal file
225
src/App/CMakeLists.txt.orig
Normal file
|
@ -0,0 +1,225 @@
|
|||
if(WIN32)
|
||||
add_definitions(-DFCApp)
|
||||
add_definitions(-DBOOST_DYN_LINK)
|
||||
endif(WIN32)
|
||||
|
||||
# This causes some problems with the resource files to be found, especially with the StartPage
|
||||
IF(RESOURCEDIR)
|
||||
add_definitions(-DRESOURCEDIR="${RESOURCEDIR}")
|
||||
ENDIF(RESOURCEDIR)
|
||||
|
||||
IF(DOCDIR)
|
||||
add_definitions(-DDOCDIR="${DOCDIR}")
|
||||
ENDIF(DOCDIR)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
${QT_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(FreeCADApp_LIBS
|
||||
FreeCADBase
|
||||
${Boost_LIBRARIES}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTXML_LIBRARY}
|
||||
)
|
||||
|
||||
generate_from_xml(DocumentPy)
|
||||
generate_from_xml(DocumentObjectPy)
|
||||
generate_from_xml(DocumentObjectGroupPy)
|
||||
generate_from_xml(GeoFeaturePy)
|
||||
generate_from_xml(GeoFeatureGroupPy)
|
||||
generate_from_xml(PartPy)
|
||||
|
||||
generate_from_xml(ComplexGeoDataPy)
|
||||
generate_from_xml(PropertyContainerPy)
|
||||
generate_from_xml(MaterialPy)
|
||||
|
||||
generate_from_py(FreeCADInit InitScript.h)
|
||||
generate_from_py(FreeCADTest TestScript.h)
|
||||
|
||||
SET(FreeCADApp_XML_SRCS
|
||||
DocumentObjectGroupPy.xml
|
||||
DocumentObjectPy.xml
|
||||
GeoFeaturePy.xml
|
||||
GeoFeatureGroupPy.xml
|
||||
PartPy.xml
|
||||
DocumentPy.xml
|
||||
PropertyContainerPy.xml
|
||||
ComplexGeoDataPy.xml
|
||||
MaterialPy.xml
|
||||
)
|
||||
SOURCE_GROUP("XML" FILES ${FreeCADApp_XML_SRCS})
|
||||
|
||||
# The document stuff
|
||||
SET(Document_CPP_SRCS
|
||||
Annotation.cpp
|
||||
Document.cpp
|
||||
DocumentObject.cpp
|
||||
DocumentObjectFileIncluded.cpp
|
||||
DocumentObjectGroup.cpp
|
||||
DocumentObjectGroupPyImp.cpp
|
||||
PartPyImp.cpp
|
||||
GeoFeaturePyImp.cpp
|
||||
DocumentObjectPyImp.cpp
|
||||
DocumentObserver.cpp
|
||||
DocumentObserverPython.cpp
|
||||
DocumentPyImp.cpp
|
||||
Expression.cpp
|
||||
FeaturePython.cpp
|
||||
FeatureTest.cpp
|
||||
GeoFeature.cpp
|
||||
GeoFeatureGroupPyImp.cpp
|
||||
GeoFeatureGroup.cpp
|
||||
Part.cpp
|
||||
Path.cpp
|
||||
InventorObject.cpp
|
||||
MeasureDistance.cpp
|
||||
Placement.cpp
|
||||
Plane.cpp
|
||||
<<<<<<< 328aeaab9aed22c3b94c79bd7e49404342a44cea
|
||||
Range.cpp
|
||||
=======
|
||||
Line.cpp
|
||||
>>>>>>> add base lines
|
||||
Transactions.cpp
|
||||
VRMLObject.cpp
|
||||
MaterialObject.cpp
|
||||
MergeDocuments.cpp
|
||||
)
|
||||
|
||||
SET(Document_HPP_SRCS
|
||||
Annotation.h
|
||||
Document.h
|
||||
DocumentObject.h
|
||||
DocumentObjectFileIncluded.h
|
||||
DocumentObjectGroup.h
|
||||
DocumentObserver.h
|
||||
DocumentObserverPython.h
|
||||
Expression.h
|
||||
ExpressionVisitors.h
|
||||
FeatureCustom.h
|
||||
FeaturePython.h
|
||||
FeaturePythonPyImp.h
|
||||
FeaturePythonPyImp.inl
|
||||
FeatureTest.h
|
||||
GeoFeature.h
|
||||
GeoFeatureGroup.h
|
||||
Part.h
|
||||
Path.h
|
||||
InventorObject.h
|
||||
MeasureDistance.h
|
||||
Placement.h
|
||||
Plane.h
|
||||
<<<<<<< 328aeaab9aed22c3b94c79bd7e49404342a44cea
|
||||
Range.h
|
||||
=======
|
||||
Line.h
|
||||
>>>>>>> add base lines
|
||||
Transactions.h
|
||||
VRMLObject.h
|
||||
MaterialObject.h
|
||||
MergeDocuments.h
|
||||
)
|
||||
SET(Document_SRCS
|
||||
${Document_CPP_SRCS}
|
||||
${Document_HPP_SRCS}
|
||||
)
|
||||
SOURCE_GROUP("Document" FILES ${Document_SRCS})
|
||||
|
||||
# The property stuff
|
||||
SET(Properties_CPP_SRCS
|
||||
DynamicProperty.cpp
|
||||
ObjectIdentifier.cpp
|
||||
Property.cpp
|
||||
PropertyContainer.cpp
|
||||
PropertyContainerPyImp.cpp
|
||||
PropertyFile.cpp
|
||||
PropertyGeo.cpp
|
||||
PropertyLinks.cpp
|
||||
PropertyPythonObject.cpp
|
||||
PropertyStandard.cpp
|
||||
PropertyUnits.cpp
|
||||
PropertyExpressionEngine.cpp
|
||||
)
|
||||
SET(Properties_HPP_SRCS
|
||||
DynamicProperty.h
|
||||
ObjectIdentifier.h
|
||||
Property.h
|
||||
PropertyContainer.h
|
||||
PropertyFile.h
|
||||
PropertyGeo.h
|
||||
PropertyLinks.h
|
||||
PropertyPythonObject.h
|
||||
PropertyStandard.h
|
||||
PropertyUnits.h
|
||||
PropertyExpressionEngine.h
|
||||
)
|
||||
SET(Properties_SRCS
|
||||
${Properties_CPP_SRCS}
|
||||
${Properties_HPP_SRCS}
|
||||
)
|
||||
SOURCE_GROUP("Properties" FILES ${Properties_SRCS})
|
||||
|
||||
SET(FreeCADApp_CPP_SRCS
|
||||
${Document_CPP_SRCS}
|
||||
${Properties_CPP_SRCS}
|
||||
Application.cpp
|
||||
ApplicationPy.cpp
|
||||
Branding.cpp
|
||||
ColorModel.cpp
|
||||
ComplexGeoData.cpp
|
||||
ComplexGeoDataPyImp.cpp
|
||||
Enumeration.cpp
|
||||
Material.cpp
|
||||
MaterialPyImp.cpp
|
||||
)
|
||||
|
||||
SET(FreeCADApp_HPP_SRCS
|
||||
${Document_HPP_SRCS}
|
||||
${Properties_HPP_SRCS}
|
||||
Application.h
|
||||
Branding.h
|
||||
ColorModel.h
|
||||
ComplexGeoData.h
|
||||
Enumeration.h
|
||||
Material.h
|
||||
)
|
||||
|
||||
SET(FreeCADApp_SRCS
|
||||
${FreeCADApp_CPP_SRCS}
|
||||
${FreeCADApp_HPP_SRCS}
|
||||
${FreeCADApp_XML_SRCS}
|
||||
FreeCADInit.py
|
||||
FreeCADTest.py
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_PreComp_)
|
||||
ADD_MSVC_PRECOMPILED_HEADER(FreeCADApp PreCompiled.h PreCompiled.cpp FreeCADApp_CPP_SRCS)
|
||||
endif(MSVC)
|
||||
|
||||
add_library(FreeCADApp SHARED ${FreeCADApp_SRCS})
|
||||
|
||||
target_link_libraries(FreeCADApp ${FreeCADApp_LIBS})
|
||||
|
||||
SET_BIN_DIR(FreeCADApp FreeCADApp)
|
||||
|
||||
if(WIN32)
|
||||
INSTALL(TARGETS FreeCADApp
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else(WIN32)
|
||||
INSTALL(TARGETS FreeCADApp
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
endif(WIN32)
|
61
src/App/Line.cpp
Normal file
61
src/App/Line.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
/***************************************************************************
|
||||
* 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 "Line.h"
|
||||
|
||||
using namespace App;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(App::Line, App::GeoFeature)
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Feature
|
||||
//===========================================================================
|
||||
|
||||
Line::Line(void)
|
||||
{
|
||||
ADD_PROPERTY(LineType,(""));
|
||||
|
||||
}
|
||||
|
||||
Line::~Line(void)
|
||||
{
|
||||
}
|
||||
|
||||
Base::BoundBox3d Line::getBoundBox()
|
||||
{
|
||||
return Base::BoundBox3d(-10, -10, -10, 10, 10, 10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
69
src/App/Line.h
Normal file
69
src/App/Line.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/***************************************************************************
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
#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
|
|
@ -46,6 +46,7 @@ PROPERTY_SOURCE(App::Part, App::GeoFeatureGroup)
|
|||
|
||||
|
||||
const char* Part::BaseplaneTypes[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"};
|
||||
const char* Part::BaselineTypes[3] = {"X_Axis", "Y_Axis", "Z_Axis"};
|
||||
|
||||
Part::Part(void)
|
||||
{
|
||||
|
|
|
@ -90,6 +90,7 @@ public:
|
|||
virtual PyObject *getPyObject(void);
|
||||
|
||||
static const char* BaseplaneTypes[3];
|
||||
static const char* BaselineTypes[3];
|
||||
};
|
||||
|
||||
//typedef App::FeaturePythonT<Part> PartPython;
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
#include "ViewProviderMeasureDistance.h"
|
||||
#include "ViewProviderPlacement.h"
|
||||
#include "ViewProviderPlane.h"
|
||||
#include "ViewProviderLine.h"
|
||||
#include "ViewProviderPart.h"
|
||||
#include "ViewProviderMaterialObject.h"
|
||||
|
||||
|
@ -1543,6 +1544,7 @@ void Application::initTypes(void)
|
|||
Gui::ViewProviderPythonGeometry ::init();
|
||||
Gui::ViewProviderPlacement ::init();
|
||||
Gui::ViewProviderPlane ::init();
|
||||
Gui::ViewProviderLine ::init();
|
||||
Gui::ViewProviderPart ::init();
|
||||
Gui::ViewProviderMaterialObject ::init();
|
||||
Gui::ViewProviderMaterialObjectPython ::init();
|
||||
|
|
|
@ -821,6 +821,7 @@ SET(Viewprovider_CPP_SRCS
|
|||
ViewProviderBuilder.cpp
|
||||
ViewProviderPlacement.cpp
|
||||
ViewProviderPlane.cpp
|
||||
ViewProviderLine.cpp
|
||||
ViewProviderGeoFeatureGroup.cpp
|
||||
ViewProviderPart.cpp
|
||||
ViewProviderMaterialObject.cpp
|
||||
|
@ -841,6 +842,7 @@ SET(Viewprovider_SRCS
|
|||
ViewProviderBuilder.h
|
||||
ViewProviderPlacement.h
|
||||
ViewProviderPlane.h
|
||||
ViewProviderLine.h
|
||||
ViewProviderGeoFeatureGroup.h
|
||||
ViewProviderPart.h
|
||||
ViewProviderMaterialObject.h
|
||||
|
|
231
src/Gui/ViewProviderLine.cpp
Normal file
231
src/Gui/ViewProviderLine.cpp
Normal file
|
@ -0,0 +1,231 @@
|
|||
/***************************************************************************
|
||||
* 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_
|
||||
# include <sstream>
|
||||
# include <QApplication>
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/events/SoMouseButtonEvent.h>
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoBaseColor.h>
|
||||
# include <Inventor/nodes/SoFontStyle.h>
|
||||
# include <Inventor/nodes/SoPickStyle.h>
|
||||
# include <Inventor/nodes/SoText2.h>
|
||||
# include <Inventor/nodes/SoTranslation.h>
|
||||
# include <Inventor/nodes/SoCoordinate3.h>
|
||||
# include <Inventor/nodes/SoIndexedLineSet.h>
|
||||
# include <Inventor/nodes/SoMarkerSet.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
#endif
|
||||
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoAnnotation.h>
|
||||
#include <Inventor/details/SoLineDetail.h>
|
||||
#include <Inventor/nodes/SoAsciiText.h>
|
||||
#include "ViewProviderLine.h"
|
||||
#include "SoFCSelection.h"
|
||||
#include "Application.h"
|
||||
#include "Document.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
#include "Inventor/SoAutoZoomTranslation.h"
|
||||
#include "SoAxisCrossKit.h"
|
||||
//#include <SoDepthBuffer.h>
|
||||
|
||||
#include <App/PropertyGeo.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/MeasureDistance.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
PROPERTY_SOURCE(Gui::ViewProviderLine, Gui::ViewProviderGeometryObject)
|
||||
|
||||
|
||||
ViewProviderLine::ViewProviderLine()
|
||||
{
|
||||
|
||||
ADD_PROPERTY(Size,(1.0));
|
||||
|
||||
pMat = new SoMaterial();
|
||||
pMat->ref();
|
||||
|
||||
float size = Size.getValue(); // Note: If you change this, you need to also adapt App/Line.cpp getBoundBox()
|
||||
|
||||
SbVec3f verts[4] =
|
||||
{
|
||||
SbVec3f(-size,0,0), SbVec3f(size,0,0),
|
||||
};
|
||||
|
||||
// indexes used to create the edges
|
||||
static const int32_t lines[6] =
|
||||
{
|
||||
0,1,-1
|
||||
};
|
||||
|
||||
pMat->diffuseColor.setNum(1);
|
||||
pMat->diffuseColor.set1Value(0, SbColor(1.0f, 1.0f, 1.0f));
|
||||
|
||||
pCoords = new SoCoordinate3();
|
||||
pCoords->ref();
|
||||
pCoords->point.setNum(2);
|
||||
pCoords->point.setValues(0, 2, verts);
|
||||
|
||||
pLines = new SoIndexedLineSet();
|
||||
pLines->ref();
|
||||
pLines->coordIndex.setNum(3);
|
||||
pLines->coordIndex.setValues(0, 3, lines);
|
||||
|
||||
pFont = new SoFont();
|
||||
pFont->size.setValue(Size.getValue()/10.);
|
||||
|
||||
pTranslation = new SoTranslation();
|
||||
pTranslation->translation.setValue(SbVec3f(-1,0,0));
|
||||
|
||||
pText = new SoAsciiText();
|
||||
pText->width.setValue(-1);
|
||||
|
||||
sPixmap = "view-measurement";
|
||||
}
|
||||
|
||||
ViewProviderLine::~ViewProviderLine()
|
||||
{
|
||||
pCoords->unref();
|
||||
pLines->unref();
|
||||
pMat->unref();
|
||||
}
|
||||
|
||||
void ViewProviderLine::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &Size){
|
||||
float size = Size.getValue(); // Note: If you change this, you need to also adapt App/Line.cpp getBoundBox()
|
||||
|
||||
SbVec3f verts[2] =
|
||||
{
|
||||
SbVec3f(-size,0,0), SbVec3f(size,0,0),
|
||||
};
|
||||
|
||||
pCoords->point.setValues(0, 2, verts);
|
||||
pFont->size.setValue(Size.getValue()/10.);
|
||||
pTranslation->translation.setValue(SbVec3f(-size,0,0));
|
||||
}
|
||||
else
|
||||
ViewProviderGeometryObject::onChanged(prop);
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderLine::getDisplayModes(void) const
|
||||
{
|
||||
// add modes
|
||||
std::vector<std::string> StrList;
|
||||
StrList.push_back("Base");
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderLine::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if (strcmp(ModeName, "Base") == 0)
|
||||
setDisplayMaskMode("Base");
|
||||
ViewProviderGeometryObject::setDisplayMode(ModeName);
|
||||
}
|
||||
|
||||
void ViewProviderLine::attach(App::DocumentObject* pcObject)
|
||||
{
|
||||
ViewProviderGeometryObject::attach(pcObject);
|
||||
|
||||
SoSeparator *sep = new SoSeparator();
|
||||
SoAnnotation *lineSep = new SoAnnotation();
|
||||
|
||||
SoDrawStyle* style = new SoDrawStyle();
|
||||
style->lineWidth = 2.0f;
|
||||
|
||||
SoMaterialBinding* matBinding = new SoMaterialBinding;
|
||||
matBinding->value = SoMaterialBinding::OVERALL;
|
||||
|
||||
sep->addChild(matBinding);
|
||||
sep->addChild(pMat);
|
||||
sep->addChild(getHighlightNode());
|
||||
pcHighlight->addChild(style);
|
||||
pcHighlight->addChild(pCoords);
|
||||
pcHighlight->addChild(pLines);
|
||||
|
||||
style = new SoDrawStyle();
|
||||
style->lineWidth = 2.0f;
|
||||
style->linePattern.setValue(0x00FF);
|
||||
lineSep->addChild(style);
|
||||
lineSep->addChild(pLines);
|
||||
lineSep->addChild(pFont);
|
||||
pText->string.setValue(SbString(pcObject->Label.getValue()));
|
||||
lineSep->addChild(pTranslation);
|
||||
lineSep->addChild(pText);
|
||||
pcHighlight->addChild(lineSep);
|
||||
|
||||
pcHighlight->style = SoFCSelection::EMISSIVE_DIFFUSE;
|
||||
addDisplayMaskMode(sep, "Base");
|
||||
}
|
||||
|
||||
void ViewProviderLine::updateData(const App::Property* prop)
|
||||
{
|
||||
pText->string.setValue(SbString(pcObject->Label.getValue()));
|
||||
ViewProviderGeometryObject::updateData(prop);
|
||||
}
|
||||
|
||||
std::string ViewProviderLine::getElement(const SoDetail* detail) const
|
||||
{
|
||||
if (detail) {
|
||||
if (detail->getTypeId() == SoLineDetail::getClassTypeId()) {
|
||||
const SoLineDetail* line_detail = static_cast<const SoLineDetail*>(detail);
|
||||
int edge = line_detail->getLineIndex();
|
||||
if (edge == 0)
|
||||
{
|
||||
return std::string("Main");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
SoDetail* ViewProviderLine::getDetail(const char* subelement) const
|
||||
{
|
||||
SoLineDetail* detail = 0;
|
||||
std::string subelem(subelement);
|
||||
int edge = -1;
|
||||
|
||||
if(subelem == "Main") edge = 0;
|
||||
|
||||
if(edge >= 0) {
|
||||
detail = new SoLineDetail();
|
||||
detail->setPartIndex(edge);
|
||||
}
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
bool ViewProviderLine::isSelectable(void) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
84
src/Gui/ViewProviderLine.h
Normal file
84
src/Gui/ViewProviderLine.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/***************************************************************************
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_ViewProviderLine_H
|
||||
#define GUI_ViewProviderLine_H
|
||||
|
||||
#include "ViewProviderGeometryObject.h"
|
||||
#include <QObject>
|
||||
|
||||
class SoFontStyle;
|
||||
class SoText2;
|
||||
class SoBaseColor;
|
||||
class SoTranslation;
|
||||
class SoCoordinate3;
|
||||
class SoIndexedLineSet;
|
||||
class SoEventCallback;
|
||||
class SoMaterial;
|
||||
class SoAsciiText;
|
||||
class SoFont;
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
|
||||
class GuiExport ViewProviderLine : public ViewProviderGeometryObject
|
||||
{
|
||||
PROPERTY_HEADER(Gui::ViewProviderLine);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
ViewProviderLine(void);
|
||||
virtual ~ViewProviderLine();
|
||||
|
||||
App::PropertyFloat Size;
|
||||
|
||||
void attach(App::DocumentObject *);
|
||||
void updateData(const App::Property*);
|
||||
std::vector<std::string> getDisplayModes(void) const;
|
||||
void setDisplayMode(const char* ModeName);
|
||||
|
||||
/// 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 ;
|
||||
/// return a hit element to the selection path or 0
|
||||
virtual std::string getElement(const SoDetail *) const;
|
||||
virtual SoDetail* getDetail(const char*) const;
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
|
||||
private:
|
||||
SoCoordinate3 * pCoords;
|
||||
SoMaterial * pMat;
|
||||
SoIndexedLineSet * pLines;
|
||||
SoAsciiText * pText;
|
||||
SoFont * pFont;
|
||||
SoTranslation * pTranslation;
|
||||
};
|
||||
|
||||
} //namespace Gui
|
||||
|
||||
|
||||
#endif // GUI_ViewProviderLine_H
|
|
@ -30,11 +30,13 @@
|
|||
|
||||
#include <App/Part.h>
|
||||
#include <App/Plane.h>
|
||||
#include <App/Line.h>
|
||||
#include <App/Document.h>
|
||||
|
||||
/// Here the FreeCAD includes sorted by Base,App,Gui......
|
||||
#include "ViewProviderPart.h"
|
||||
#include "ViewProviderPlane.h"
|
||||
#include "ViewProviderLine.h"
|
||||
#include "Application.h"
|
||||
#include "Command.h"
|
||||
#include "BitmapFactory.h"
|
||||
|
@ -89,7 +91,9 @@ void ViewProviderPart::updateData(const App::Property* prop)
|
|||
void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App::Property&)
|
||||
{
|
||||
App::Part* part = static_cast<App::Part*>(pcObject);
|
||||
if(static_cast<App::Part*>(pcObject)->hasObject(&obj) && obj.getTypeId() != App::Plane::getClassTypeId()) {
|
||||
if(static_cast<App::Part*>(pcObject)->hasObject(&obj) &&
|
||||
obj.getTypeId() != App::Plane::getClassTypeId() &&
|
||||
obj.getTypeId() != App::Line::getClassTypeId()) {
|
||||
|
||||
View3DInventorViewer* viewer = static_cast<View3DInventor*>(this->getActiveView())->getViewer();
|
||||
SoGetBoundingBoxAction bboxAction(viewer->getSoRenderManager()->getViewportRegion());
|
||||
|
@ -97,7 +101,8 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
|||
//calculate for everything but planes
|
||||
SbBox3f bbox(0.0001f,0.0001f,0.0001f,0.0001f,0.0001f,0.0001f);
|
||||
for(App::DocumentObject* obj : part->getObjects()) {
|
||||
if(obj->getTypeId() != App::Plane::getClassTypeId()) {
|
||||
if(obj->getTypeId() != App::Plane::getClassTypeId() &&
|
||||
obj->getTypeId() != App::Line::getClassTypeId() ) {
|
||||
bboxAction.apply(Gui::Application::Instance->getViewProvider(obj)->getRoot());
|
||||
bbox.extendBy(bboxAction.getBoundingBox());
|
||||
}
|
||||
|
@ -138,6 +143,37 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
|||
vp->Size.setValue(std::max(std::abs(std::min(min[1], min[2])),std::max(max[1], max[2])));
|
||||
}
|
||||
}
|
||||
|
||||
//get the lines and set their values
|
||||
std::vector<App::DocumentObject*> lines = part->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 (strcmp(App::Part::BaselineTypes[0], dynamic_cast<App::Line*>(*p)->getNameInDocument()) == 0) {
|
||||
|
||||
Base::Placement cpl = dynamic_cast<App::Line*>(*p)->Placement.getValue();
|
||||
cpl = Base::Placement(-cpl.getPosition() + Base::Vector3d((max[0]+min[0])/2., (max[1]+min[1])/2., 0), Base::Rotation());
|
||||
//dynamic_cast<App::Plane*>(*p)->Placement.setValue(cpl);
|
||||
if(vp)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[1])),std::max(max[0], max[1])));
|
||||
}
|
||||
if (strcmp(App::Part::BaselineTypes[1], dynamic_cast<App::Line*>(*p)->getNameInDocument()) == 0) {
|
||||
|
||||
Base::Placement cpl = dynamic_cast<App::Line*>(*p)->Placement.getValue();
|
||||
cpl = Base::Placement(-cpl.getPosition() + Base::Vector3d((max[0]+min[0])/2., 0, (max[2]+min[2])/2.), Base::Rotation());
|
||||
//dynamic_cast<App::Plane*>(*p)->Placement.setValue(cpl);
|
||||
if(vp)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[2])),std::max(max[0], max[2])));
|
||||
}
|
||||
if (strcmp(App::Part::BaselineTypes[2], dynamic_cast<App::Line*>(*p)->getNameInDocument()) == 0) {
|
||||
|
||||
Base::Placement cpl = dynamic_cast<App::Line*>(*p)->Placement.getValue();
|
||||
cpl = Base::Placement(-cpl.getPosition() + Base::Vector3d(0, (max[1]+min[1])/2., (max[2]+min[2])/2.), Base::Rotation());
|
||||
//dynamic_cast<App::Plane*>(*p)->Placement.setValue(cpl);
|
||||
if(vp)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[1], min[2])),std::max(max[1], max[2])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,6 +255,23 @@ void ViewProviderPart::setUpPart(const App::Part *part)
|
|||
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)");
|
||||
|
||||
// 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().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().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?)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user