PCH: Part GUI

This commit is contained in:
Abdullah Tahiri
2019-05-03 13:44:09 +02:00
committed by abdullahtahiriyo
parent 635ce5cd81
commit 7ea21c84c3
12 changed files with 370 additions and 293 deletions

View File

@@ -21,6 +21,32 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <TopoDS_Face.hxx>
# include <TopExp.hxx>
# include <TopExp_Explorer.hxx>
# include <BRepProj_Projection.hxx>
# include <TopoDS_Builder.hxx>
# include <TopoDS_Edge.hxx>
# include <ShapeAnalysis.hxx>
# include <ShapeAnalysis_FreeBounds.hxx>
# include <ShapeFix_Wire.hxx>
# include <BRep_Tool.hxx>
# include <BRepBuilderAPI_MakeWire.hxx>
# include <Geom_TrimmedCurve.hxx>
# include <GeomProjLib.hxx>
# include <BRepBuilderAPI_MakeEdge.hxx>
# include "ShapeFix_Edge.hxx"
# include <BRepBuilderAPI_MakeFace.hxx>
# include <ShapeFix_Face.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <ShapeFix_Wireframe.hxx>
# include <BRepPrimAPI_MakePrism.hxx>
# include <gp_Ax1.hxx>
# include <BRepBuilderAPI_Transform.hxx>
#endif
#include "DlgProjectionOnSurface.h"
#include "ui_DlgProjectionOnSurface.h"
@@ -35,28 +61,9 @@
#include "ViewProviderExt.h"
#include <TopoDS_Face.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepProj_Projection.hxx>
#include <TopoDS_Builder.hxx>
#include <TopoDS_Edge.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <ShapeFix_Wire.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomProjLib.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include "ShapeFix_Edge.hxx"
#include <BRepBuilderAPI_MakeFace.hxx>
#include <ShapeFix_Face.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <ShapeFix_Wireframe.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <gp_Ax1.hxx>
#include <BRepBuilderAPI_Transform.hxx>
using namespace PartGui;

View File

@@ -26,10 +26,9 @@
# include <QButtonGroup>
# include <QRegExp>
# include <QRegExpValidator>
# include <Interface_Static.hxx>
#endif
#include <Interface_Static.hxx>
#include <Base/Parameter.h>
#include <App/Application.h>
@@ -47,7 +46,7 @@ DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent)
ui->setupUi(this);
}
/**
/**
* Destroys the object and frees any allocated resources
*/
DlgSettingsGeneral::~DlgSettingsGeneral()
@@ -108,7 +107,7 @@ DlgImportExportIges::DlgImportExportIges(QWidget* parent)
ui->lineEditAuthor->setValidator(authorValidator);
}
/**
/**
* Destroys the object and frees any allocated resources
*/
DlgImportExportIges::~DlgImportExportIges()
@@ -217,7 +216,7 @@ DlgImportExportStep::DlgImportExportStep(QWidget* parent)
ui->lineEditAuthor->setValidator(authorValidator);
}
/**
/**
* Destroys the object and frees any allocated resources
*/
DlgImportExportStep::~DlgImportExportStep()

View File

@@ -37,7 +37,7 @@
#ifdef FC_OS_WIN32
# define NOMINMAX
#endif
#endif
// here get the warnings of too long specifiers disabled (needed for VC6)
#ifdef _MSC_VER
@@ -47,6 +47,10 @@
# pragma warning( disable : 4273 )
#endif
#ifdef FC_OS_WIN32
# include <windows.h>
#endif
#ifdef _PreComp_
// standard
@@ -57,6 +61,8 @@
//#include <io.h>
//#include <fcntl.h>
//#include <ctype.h>
# include <cmath>
#include <sstream>
// STL
#include <vector>
@@ -69,12 +75,9 @@
#include <queue>
#include <bitset>
#ifdef FC_OS_WIN32
# include <windows.h>
#endif
// OpenCasCade Base
#include <Standard_Failure.hxx>
#include <Standard_Version.hxx>
#include <BRepMesh.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
@@ -97,6 +100,8 @@
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
@@ -114,20 +119,90 @@
#include <GCPnts_UniformDeflection.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Interface_Static.hxx>
# include <BRepProj_Projection.hxx>
# include <TopoDS_Builder.hxx>
# include <ShapeAnalysis.hxx>
# include <ShapeAnalysis_FreeBounds.hxx>
# include <ShapeFix_Wire.hxx>
# include <BRepBuilderAPI_MakeWire.hxx>
# include <Geom_TrimmedCurve.hxx>
# include <GeomProjLib.hxx>
# include <BRepBuilderAPI_MakeEdge.hxx>
# include "ShapeFix_Edge.hxx"
# include <ShapeFix_Face.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <ShapeFix_Wireframe.hxx>
# include <BRepPrimAPI_MakePrism.hxx>
# include <gp_Ax1.hxx>
# include <BRepBuilderAPI_Transform.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepCheck_Result.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepTools_ShapeSet.hxx>
#if OCC_VERSION_HEX >= 0x060600
# include <BOPAlgo_ArgumentAnalyzer.hxx>
# include <BOPAlgo_ListOfCheckResult.hxx>
#endif
#include <TopoDS_Compound.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <Geom_ElementarySurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_Line.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
// Python
#include <Python.h>
// Boost
#include <boost/signals2.hpp>
#include <boost/bind.hpp>
// Qt Toolkit
#ifndef __Qt4All__
# include <Gui/Qt4All.h>
#endif
// Inventor
// GL
// Include glext before InventorAll
# ifdef FC_OS_WIN32
# include <GL/gl.h>
# include <GL/glext.h>
# else
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
# else
# include <GL/gl.h>
# include <GL/glext.h>
# endif //FC_OS_MACOSX
# endif //FC_OS_WIN32
// Should come after glext.h to avoid warnings
# include <Inventor/C/glue/gl.h>
#include <Inventor/nodes/SoVertexProperty.h>
#include <Inventor/nodes/SoNurbsCurve.h>
#include <Inventor/engines/SoCalculator.h>
#include <Inventor/nodes/SoResetTransform.h>
#include <Inventor/engines/SoConcatenate.h>
#include <Inventor/engines/SoComposeRotationFromTo.h>
#include <Inventor/engines/SoComposeRotation.h>
// Inventor includes OpenGL
#ifndef __InventorAll__
# include <Gui/InventorAll.h>
#endif
#elif defined(FC_OS_WIN32)
#include <windows.h>
#endif //_PreComp_
#endif
#endif // PARTGUI_PRECOMPILED_H

View File

@@ -22,10 +22,14 @@
#include "PreCompiled.h"
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#include <cmath>
#endif
#ifndef _PreComp_
# ifdef _MSC_VER
# define _USE_MATH_DEFINES
# include <cmath>
# endif //_MSC_VER
#endif // _PreComp_
#include <Gui/Application.h>
#include <Gui/Control.h>
#include <Gui/ViewProviderDocumentObject.h>
@@ -90,7 +94,7 @@ void PropertyEnumAttacherItem::openTask()
return;
}
}
Gui::Control().showDialog(task);
}

View File

@@ -25,12 +25,12 @@
#ifndef _PreComp_
# ifdef FC_OS_WIN32
# include <windows.h>
# include <windows.h>
# endif
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# include <OpenGL/gl.h>
# else
# include <GL/gl.h>
# include <GL/gl.h>
# endif
# include <float.h>
# include <algorithm>

View File

@@ -27,34 +27,49 @@
#endif
#ifndef _PreComp_
#include <float.h>
#include <algorithm>
#include <map>
#include <Python.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/actions/SoCallbackAction.h>
#include <Inventor/actions/SoGetBoundingBoxAction.h>
#include <Inventor/actions/SoGetPrimitiveCountAction.h>
#include <Inventor/actions/SoGLRenderAction.h>
#include <Inventor/actions/SoPickAction.h>
#include <Inventor/actions/SoWriteAction.h>
#include <Inventor/bundles/SoMaterialBundle.h>
#include <Inventor/bundles/SoTextureCoordinateBundle.h>
#include <Inventor/elements/SoLazyElement.h>
#include <Inventor/elements/SoOverrideElement.h>
#include <Inventor/elements/SoCoordinateElement.h>
#include <Inventor/elements/SoGLCoordinateElement.h>
#include <Inventor/elements/SoGLCacheContextElement.h>
#include <Inventor/elements/SoGLVBOElement.h>
#include <Inventor/elements/SoLineWidthElement.h>
#include <Inventor/elements/SoPointSizeElement.h>
#include <Inventor/errors/SoDebugError.h>
#include <Inventor/errors/SoReadError.h>
#include <Inventor/details/SoFaceDetail.h>
#include <Inventor/details/SoLineDetail.h>
#include <Inventor/misc/SoState.h>
#include <Inventor/misc/SoContextHandler.h>
# include <float.h>
# include <algorithm>
# include <map>
# include <Python.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/SoPrimitiveVertex.h>
# include <Inventor/actions/SoCallbackAction.h>
# include <Inventor/actions/SoGetBoundingBoxAction.h>
# include <Inventor/actions/SoGetPrimitiveCountAction.h>
# include <Inventor/actions/SoGLRenderAction.h>
# include <Inventor/actions/SoPickAction.h>
# include <Inventor/actions/SoWriteAction.h>
# include <Inventor/bundles/SoMaterialBundle.h>
# include <Inventor/bundles/SoTextureCoordinateBundle.h>
# include <Inventor/elements/SoLazyElement.h>
# include <Inventor/elements/SoOverrideElement.h>
# include <Inventor/elements/SoCoordinateElement.h>
# include <Inventor/elements/SoGLCoordinateElement.h>
# include <Inventor/elements/SoGLCacheContextElement.h>
# include <Inventor/elements/SoGLVBOElement.h>
# include <Inventor/elements/SoLineWidthElement.h>
# include <Inventor/elements/SoPointSizeElement.h>
# include <Inventor/errors/SoDebugError.h>
# include <Inventor/errors/SoReadError.h>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/details/SoLineDetail.h>
# include <Inventor/misc/SoState.h>
# include <Inventor/misc/SoContextHandler.h>
# ifdef FC_OS_WIN32
# include <windows.h>
# include <GL/gl.h>
# include <GL/glext.h>
# else
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
# else
# include <GL/gl.h>
# include <GL/glext.h>
# endif //FC_OS_MACOSX
# endif //FC_OS_WIN32
// Should come after glext.h to avoid warnings
# include <Inventor/C/glue/gl.h>
#endif
#include "SoBrepFaceSet.h"
@@ -62,24 +77,6 @@
#include <Gui/SoFCSelectionAction.h>
#include <Gui/SoFCInteractiveElement.h>
#ifdef FC_OS_WIN32
#include <windows.h>
#include <GL/gl.h>
#include <GL/glext.h>
#else
#ifdef FC_OS_MACOSX
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#endif
// Should come after glext.h to avoid warnings
#include <Inventor/C/glue/gl.h>
using namespace PartGui;
@@ -378,7 +375,7 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action)
if (num_selected > 0)
renderSelection(action);
//#endif
if(normalCacheUsed)
this->readUnlockNormalCache();
}
@@ -748,7 +745,7 @@ void SoBrepFaceSet::generatePrimitives(SoAction * action)
if (tb.isFunction()) {
vertex.setTextureCoords(tb.get(coords->get3(v1), *currnormal));
if (tb.needIndices()) pointDetail.setTextureCoordIndex(tindices ? *tindices++ : texidx++);
if (tb.needIndices()) pointDetail.setTextureCoordIndex(tindices ? *tindices++ : texidx++);
}
else if (tbind != NONE) {
pointDetail.setTextureCoordIndex(tindices ? *tindices : texidx);
@@ -870,7 +867,7 @@ void SoBrepFaceSet::renderHighlight(SoGLRenderAction *action)
nindices = &(nindices[start]);
else if (nbind == PER_VERTEX)
normals = &(normals[start]);
else
else
nbind = OVERALL;
// materials
@@ -881,7 +878,7 @@ void SoBrepFaceSet::renderHighlight(SoGLRenderAction *action)
&(pindices[id]), 1, normals, nindices, &mb, mindices, &tb, tindices, nbind, mbind, doTextures?1:0);
}
state->pop();
if (normalCacheUsed)
this->readUnlockNormalCache();
}
@@ -966,14 +963,14 @@ void SoBrepFaceSet::renderSelection(SoGLRenderAction *action)
nindices_s = &(nindices[start]);
else if (nbind == PER_VERTEX)
normals_s = &(normals[start]);
else
else
nbind = OVERALL;
renderShape(action, false, static_cast<const SoGLCoordinateElement*>(coords), &(cindices[start]), length,
&(pindices[id]), numparts, normals_s, nindices_s, &mb, mindices, &tb, tindices, nbind, mbind, doTextures?1:0);
}
state->pop();
if (normalCacheUsed)
this->readUnlockNormalCache();
}
@@ -1369,7 +1366,7 @@ void SoBrepFaceSet::renderShape(SoGLRenderAction * action,
matindices++;
}
glBegin(GL_TRIANGLES);
glBegin(GL_TRIANGLES);
while (viptr + 2 < viendptr) {
v1 = *viptr++;
v2 = *viptr++;

View File

@@ -25,12 +25,12 @@
#ifndef _PreComp_
# ifdef FC_OS_WIN32
# include <windows.h>
# include <windows.h>
# endif
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# include <OpenGL/gl.h>
# else
# include <GL/gl.h>
# include <GL/gl.h>
# endif
# include <float.h>
# include <algorithm>
@@ -108,7 +108,7 @@ void SoBrepPointSet::GLRenderBelowPath(SoGLRenderAction * action)
inherited::GLRenderBelowPath(action);
}
void SoBrepPointSet::renderShape(const SoGLCoordinateElement * const coords,
void SoBrepPointSet::renderShape(const SoGLCoordinateElement * const coords,
const int32_t *cindices,
int numindices)
{

View File

@@ -25,12 +25,12 @@
#ifndef _PreComp_
# ifdef FC_OS_WIN32
# include <windows.h>
# include <windows.h>
# endif
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# include <OpenGL/gl.h>
# else
# include <GL/gl.h>
# include <GL/gl.h>
# endif
# include <float.h>
# include <algorithm>

View File

@@ -30,36 +30,36 @@
# include <QThread>
# include <QTreeWidget>
# include <Python.h>
#endif
# include <Standard_Version.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <BRepCheck_Result.hxx>
# include <BRepCheck_ListIteratorOfListOfStatus.hxx>
# include <BRepBuilderAPI_Copy.hxx>
# include <BRepTools_ShapeSet.hxx>
#include <Standard_Version.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepCheck_Result.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepTools_ShapeSet.hxx>
# if OCC_VERSION_HEX >= 0x060600
# include <BOPAlgo_ArgumentAnalyzer.hxx>
# include <BOPAlgo_ListOfCheckResult.hxx>
# endif
#if OCC_VERSION_HEX >= 0x060600
#include <BOPAlgo_ArgumentAnalyzer.hxx>
#include <BOPAlgo_ListOfCheckResult.hxx>
#endif
# include <TopoDS.hxx>
# include <TopoDS_Compound.hxx>
# include <TopTools_IndexedMapOfShape.hxx>
# include <TopExp.hxx>
# include <TopExp_Explorer.hxx>
# include <Bnd_Box.hxx>
# include <BRepBndLib.hxx>
# include <ShapeAnalysis_FreeBounds.hxx>
# include <gp_Trsf.hxx>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoSwitch.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoCube.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoTransform.h>
# include <Inventor/nodes/SoResetTransform.h>
#endif //_PreComp_
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <gp_Trsf.hxx>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoCube.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoResetTransform.h>
#include "../App/PartFeature.h"
#include <Gui/BitmapFactory.h>
#include <Gui/Selection.h>
@@ -169,7 +169,7 @@ QVector<QString> buildBOPCheckResultVector()
results.push_back(QObject::tr("BOPAlgo GeomAbs_C0")); //BOPAlgo_GeomAbs_C0
results.push_back(QObject::tr("BOPAlgo_InvalidCurveOnSurface")); //BOPAlgo_InvalidCurveOnSurface
results.push_back(QObject::tr("BOPAlgo NotValid")); //BOPAlgo_NotValid
return results;
}
@@ -366,7 +366,7 @@ void ResultModel::setResults(ResultEntry *resultsIn)
}
ResultEntry* ResultModel::getEntry(const QModelIndex &index)
{
{
return nodeFromIndex(index);
}
@@ -407,7 +407,7 @@ void TaskCheckGeometryResults::setupInterface()
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(message);
layout->addWidget(treeView);
this->setLayout(layout);
this->setLayout(layout);
}
void TaskCheckGeometryResults::goCheck()
@@ -448,7 +448,7 @@ void TaskCheckGeometryResults::goCheck()
continue;
checkedCount++;
checkedMap.Clear();
buildShapeContent(baseName, shape);
BRepCheck_Analyzer shapeCheck(shape);
@@ -473,7 +473,7 @@ void TaskCheckGeometryResults::goCheck()
//BOPAlgo_ArgumentAnalyzer can be really slow!
//so only run it when the shape seems valid to BRepCheck_Analyzer And
//when the option is set.
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod")->GetGroup("Part")->GetGroup("CheckGeometry");
bool runSignal = group->GetBool("RunBOPCheck", false);
@@ -583,11 +583,11 @@ void TaskCheckGeometryResults::buildShapeContent(const QString &baseName, const
if (!shapeContentString.empty())
stream << std::endl << std::endl;
stream << baseName.toLatin1().data() << ":" << std::endl;
BRepTools_ShapeSet set;
set.Add(shape);
set.DumpExtent(stream);
shapeContentString += stream.str();
}
@@ -602,13 +602,13 @@ int TaskCheckGeometryResults::goBOPSingleCheck(const TopoDS_Shape& shapeIn, Resu
//ArgumentAnalyser was moved at version 6.6. no back port for now.
#if OCC_VERSION_HEX >= 0x060600
//Reference use: src/BOPTest/BOPTest_CheckCommands.cxx
//I don't why we need to make a copy, but it doesn't work without it.
//BRepAlgoAPI_Check also makes a copy of the shape.
//didn't use BRepAlgoAPI_Check because it calls BRepCheck_Analyzer itself and
//doesn't give us access to it. so I didn't want to run BRepCheck_Analyzer twice to get invalid results.
//BOPAlgo_ArgumentAnalyzer can check 2 objects with respect to a boolean op.
//this is left for another time.
TopoDS_Shape BOPCopy = BRepBuilderAPI_Copy(shapeIn).Shape();
@@ -636,7 +636,7 @@ int TaskCheckGeometryResults::goBOPSingleCheck(const TopoDS_Shape& shapeIn, Resu
BOPCheck.CurveOnSurfaceMode() = true;
BOPCheck.MergeEdgeMode() = true;
#endif
#ifdef FC_DEBUG
Base::TimeInfo start_time;
#endif
@@ -647,7 +647,7 @@ BOPCheck.Perform();
float bopAlgoTime = Base::TimeInfo::diffTimeF(start_time,Base::TimeInfo());
std::cout << std::endl << "BopAlgo check time is: " << bopAlgoTime << std::endl << std::endl;
#endif
if (!BOPCheck.HasFaulty())
return 0;
@@ -667,7 +667,7 @@ BOPCheck.Perform();
for (; BOPResultsIt.More(); BOPResultsIt.Next())
{
const BOPAlgo_CheckResult &current = BOPResultsIt.Value();
#if OCC_VERSION_HEX < 0x070000
const BOPCol_ListOfShape &faultyShapes1 = current.GetFaultyShapes1();
BOPCol_ListIteratorOfListOfShape faultyShapes1It(faultyShapes1);
@@ -687,7 +687,7 @@ BOPCheck.Perform();
faultyEntry->viewProviderRoot = currentSeparator;
entry->viewProviderRoot->ref();
goSetupResultBoundingBox(faultyEntry);
if (faultyShape.ShapeType() == TopAbs_FACE)
{
goSetupResultTypedSelection(faultyEntry, faultyShape, TopAbs_FACE);
@@ -843,7 +843,7 @@ void PartGui::goSetupResultBoundingBox(ResultEntry *entry)
Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
boundingBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
SbVec3f boundCenter((xmax - xmin)/2 + xmin, (ymax - ymin)/2 + ymin, (zmax - zmin)/2 + zmin);
entry->boxSep = new SoSeparator();
entry->viewProviderRoot->addChild(entry->boxSep);
entry->boxSwitch = new SoSwitch();
@@ -862,7 +862,7 @@ void PartGui::goSetupResultBoundingBox(ResultEntry *entry)
SoResetTransform *reset = new SoResetTransform();
group->addChild(reset);
SoTransform *position = new SoTransform();
position->translation.setValue(boundCenter);
group->addChild(position);
@@ -935,7 +935,7 @@ TaskCheckGeometryDialog::TaskCheckGeometryDialog() : widget(0), contentLabel(0)
widget->windowTitle(), false, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
contentLabel = new QTextEdit();
contentLabel->setText(widget->getShapeContentString());
shapeContentBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("Part_CheckGeometry"),

View File

@@ -25,48 +25,46 @@
#ifndef _PreCpmp_
# include <QButtonGroup>
# include <QPushButton>
# include <sstream>
# include <Python.h>
# include <TopoDS_Shape.hxx>
# include <TopoDS_Vertex.hxx>
# include <TopoDS_Edge.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS.hxx>
# include <BRepExtrema_DistShapeShape.hxx>
# include <BRep_Tool.hxx>
# include <TopExp.hxx>
# include <Geom_ElementarySurface.hxx>
# include <Geom_CylindricalSurface.hxx>
# include <Geom_SphericalSurface.hxx>
# include <Geom_Line.hxx>
# include <GeomAPI_ProjectPointOnCurve.hxx>
# include <GeomAPI_ExtremaCurveCurve.hxx>
# include <Inventor/nodes/SoTransform.h>
# include <Inventor/nodes/SoMatrixTransform.h>
# include <Inventor/nodes/SoVertexProperty.h>
# include <Inventor/nodes/SoLineSet.h>
# include <Inventor/nodes/SoIndexedLineSet.h>
# include <Inventor/nodes/SoText2.h>
# include <Inventor/nodes/SoFont.h>
# include <Inventor/nodes/SoAnnotation.h>
# include <Inventor/nodekits/SoShapeKit.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoCone.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoNurbsCurve.h>
# include <Inventor/engines/SoComposeVec3f.h>
# include <Inventor/engines/SoCalculator.h>
# include <Inventor/nodes/SoResetTransform.h>
# include <Inventor/engines/SoConcatenate.h>
# include <Inventor/engines/SoComposeRotationFromTo.h>
# include <Inventor/engines/SoComposeRotation.h>
# include <Inventor/nodes/SoMaterial.h>
#endif
#include <sstream>
#include <Python.h>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <Geom_ElementarySurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_Line.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoMatrixTransform.h>
#include <Inventor/nodes/SoVertexProperty.h>
#include <Inventor/nodes/SoLineSet.h>
#include <Inventor/nodes/SoIndexedLineSet.h>
#include <Inventor/nodes/SoText2.h>
#include <Inventor/nodes/SoFont.h>
#include <Inventor/nodes/SoAnnotation.h>
#include <Inventor/nodekits/SoShapeKit.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoNurbsCurve.h>
#include <Inventor/engines/SoComposeVec3f.h>
#include <Inventor/engines/SoCalculator.h>
#include <Inventor/nodes/SoResetTransform.h>
#include <Inventor/engines/SoConcatenate.h>
#include <Inventor/engines/SoComposeRotationFromTo.h>
#include <Inventor/engines/SoComposeRotation.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Base/Console.h>
#include <Base/UnitsApi.h>
#include "../App/PartFeature.h"
@@ -109,7 +107,7 @@ bool PartGui::evaluateLinearPreSelection(TopoDS_Shape &shape1, TopoDS_Shape &sha
return false;
std::vector<Gui::SelectionSingleton::SelObj>::iterator it;
std::vector<TopoDS_Shape> shapes;
for (it = selections.begin(); it != selections.end(); ++it)
{
Part::Feature *feature = dynamic_cast<Part::Feature *>((*it).pObject);
@@ -122,20 +120,20 @@ bool PartGui::evaluateLinearPreSelection(TopoDS_Shape &shape1, TopoDS_Shape &sha
break;
shapes.push_back(shape);
}
if (shapes.size() != 2)
return false;
shape1 = shapes.front();
shape2 = shapes.back();
return true;
}
void PartGui::goDimensionLinearRoot()
{
PartGui::ensureSomeDimensionVisible();
TopoDS_Shape shape1, shape2;
if(evaluateLinearPreSelection(shape1, shape2))
{
@@ -160,10 +158,10 @@ void PartGui::goDimensionLinearNoTask(const TopoDS_Shape &shape1, const TopoDS_S
BRepExtrema_DistShapeShape measure(shape1, shape2);
if (!measure.IsDone() || measure.NbSolution() < 1)
return;
dumpLinearResults(measure);
addLinearDimensions(measure);
//if we ever make this a class add viewer to member.
Gui::View3DInventorViewer *viewer = getViewer();
if (!viewer)
@@ -179,12 +177,12 @@ void PartGui::dumpLinearResults(const BRepExtrema_DistShapeShape &measure)
typeNames[0] = "Vertex";
typeNames[1] = "Edge";
typeNames[2] = "Face";
Base::Quantity quantity(measure.Value(), Base::Unit::Length);
out << std::endl<< std::setprecision(std::numeric_limits<double>::digits10 + 1) << "distance = " <<
measure.Value() << "mm unit distance = " << quantity.getUserString().toUtf8().constData() << std::endl <<
"solution count: " << measure.NbSolution() << std::endl;
for (int index = 1; index < measure.NbSolution() + 1; ++index) //not zero based.
{
gp_Pnt point1 = measure.PointOnShape1(index);
@@ -231,7 +229,7 @@ void PartGui::addLinearDimensions(const BRepExtrema_DistShapeShape &measure)
gp_Pnt point1 = measure.PointOnShape1(1);
gp_Pnt point2 = measure.PointOnShape2(1);
viewer->addDimension3d(createLinearDimension(point1, point2, SbColor(c.r, c.g, c.b)));
//create deltas. point1 will always be the same.
gp_Pnt temp = point1;
gp_Pnt lastTemp = temp;
@@ -255,10 +253,10 @@ SoNode* PartGui::createLinearDimension(const gp_Pnt &point1, const gp_Pnt &point
dimension->point1.setValue(vec1);
dimension->point2.setValue(vec2);
dimension->setupDimension();
Base::Quantity quantity(static_cast<double>((vec2-vec1).length()), Base::Unit::Length);
dimension->text.setValue(quantity.getUserString().toUtf8().constData());
dimension->dColor.setValue(color);
return dimension;
}
@@ -308,7 +306,7 @@ void PartGui::ensureSomeDimensionVisible()
group->SetBool("DimensionsVisible", true);
bool visibility3d = group->GetBool("Dimensions3dVisible", true);
bool visibilityDelta = group->GetBool("DimensionsDeltaVisible", true);
if (!visibility3d && !visibilityDelta) //both turned off.
group->SetBool("Dimensions3dVisible", true); //turn on 3d, so something is visible.
}
@@ -321,7 +319,7 @@ void PartGui::ensure3dDimensionVisible()
if (!visibilityAll)
group->SetBool("DimensionsVisible", true);
bool visibility3d = group->GetBool("Dimensions3dVisible", true);
if (!visibility3d) //both turned off.
group->SetBool("Dimensions3dVisible", true); //turn on 3d, so something is visible.
}
@@ -455,7 +453,7 @@ void PartGui::DimensionLinear::setupDimension()
SoTransform *textTransform = new SoTransform();
textTransform->translation.connectFrom(&textVecCalc->oA);
textSep->addChild(textTransform);
SoFont *fontNode = new SoFont();
fontNode->name.setValue("defaultFont");
fontNode->size.setValue(30);
@@ -541,10 +539,10 @@ void PartGui::TaskMeasureLinear::buildDimension()
{
if(selections1.selections.size() != 1 || selections2.selections.size() != 1)
return;
DimSelections::DimSelection current1 = selections1.selections.at(0);
DimSelections::DimSelection current2 = selections2.selections.at(0);
TopoDS_Shape shape1, shape2;
if (!getShapeFromStrings(shape1, current1.documentName, current1.objectName, current1.subObjectName))
{
@@ -568,27 +566,27 @@ void PartGui::TaskMeasureLinear::clearSelectionStrings()
void PartGui::TaskMeasureLinear::setUpGui()
{
QPixmap mainIcon = Gui::BitmapFactory().pixmap("Part_Measure_Linear");
Gui::TaskView::TaskBox* selectionTaskBox = new Gui::TaskView::TaskBox
(mainIcon, QObject::tr("Selections"), false, 0);
QVBoxLayout *selectionLayout = new QVBoxLayout();
stepped = new SteppedSelection(2, selectionTaskBox);
selectionLayout->addWidget(stepped);
selectionTaskBox->groupLayout()->addLayout(selectionLayout);
Gui::TaskView::TaskBox* controlTaskBox = new Gui::TaskView::TaskBox
(mainIcon, QObject::tr("Control"), false, 0);
QVBoxLayout *controlLayout = new QVBoxLayout();
DimensionControl *control = new DimensionControl(controlTaskBox);
controlLayout->addWidget(control);
controlTaskBox->groupLayout()->addLayout(controlLayout);
QObject::connect(control->resetButton, SIGNAL(clicked(bool)), this, SLOT(resetDialogSlot(bool)));
this->setButtonPosition(TaskDialog::South);
Content.push_back(selectionTaskBox);
Content.push_back(controlTaskBox);
stepped->getButton(0)->setChecked(true);//before wired up.
stepped->getButton(0)->setEnabled(true);
QObject::connect(stepped->getButton(0), SIGNAL(toggled(bool)), this, SLOT(selection1Slot(bool)));
@@ -604,7 +602,7 @@ void PartGui::TaskMeasureLinear::selection1Slot(bool checked)
return;
}
buttonSelectedIndex = 0;
this->blockConnection(true);
Gui::Selection().clearSelection();
//we should only be working with 1 entity, but oh well do the loop anyway.
@@ -668,7 +666,7 @@ PartGui::VectorAdapter::VectorAdapter(const TopoDS_Face &faceIn, const gp_Vec &p
vector.Normalize();
if (faceIn.Orientation() == TopAbs_REVERSED)
vector.Reverse();
if (surface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
if (surface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ||
surface->IsKind(STANDARD_TYPE(Geom_SphericalSurface))
)
{
@@ -690,7 +688,7 @@ PartGui::VectorAdapter::VectorAdapter(const TopoDS_Edge &edgeIn, const gp_Vec &p
if (vector.Magnitude() < Precision::Confusion())
return;
vector.Normalize();
status = true;
projectOriginOntoVector(pickedPointIn);
}
@@ -700,14 +698,14 @@ PartGui::VectorAdapter::VectorAdapter(const TopoDS_Vertex &vertex1In, const Topo
{
vector = PartGui::convert(vertex2In) - PartGui::convert(vertex1In);
vector.Normalize();
//build origin half way.
gp_Vec tempVector = (PartGui::convert(vertex2In) - PartGui::convert(vertex1In));
double mag = tempVector.Magnitude();
tempVector.Normalize();
tempVector *= (mag / 2.0);
origin = tempVector + PartGui::convert(vertex1In);
status = true;
}
@@ -716,14 +714,14 @@ PartGui::VectorAdapter::VectorAdapter(const gp_Vec &vector1, const gp_Vec &vecto
{
vector = vector2- vector1;
vector.Normalize();
//build origin half way.
gp_Vec tempVector = vector2 - vector1;
double mag = tempVector.Magnitude();
tempVector.Normalize();
tempVector *= (mag / 2.0);
origin = tempVector + vector1;
status = true;
}
@@ -754,7 +752,7 @@ gp_Vec PartGui::convert(const TopoDS_Vertex &vertex)
void PartGui::goDimensionAngularRoot()
{
PartGui::ensure3dDimensionVisible();
VectorAdapter adapter1, adapter2;
if(PartGui::evaluateAngularPreSelection(adapter1, adapter2))
goDimensionAngularNoTask(adapter1, adapter2);
@@ -789,7 +787,7 @@ bool PartGui::evaluateAngularPreSelection(VectorAdapter &vector1Out, VectorAdapt
shape = feature->Shape.getShape().getSubShape((*it).SubName);
if (shape.IsNull())
break;
if (shape.ShapeType() == TopAbs_VERTEX)
{
TopoDS_Vertex currentVertex = TopoDS::Vertex(shape);
@@ -808,7 +806,7 @@ bool PartGui::evaluateAngularPreSelection(VectorAdapter &vector1Out, VectorAdapt
}
//vertices have to be selected in succession. so if we make it here clear the last vertex.
lastVertex = TopoDS_Vertex();
gp_Vec pickPoint(it->x, it->y, it->z);
//can't use selections without a pick point.
if (pickPoint.IsEqual(gp_Vec(0.0, 0.0, 0.0), Precision::Confusion(), Precision::Angular()))
@@ -816,7 +814,7 @@ bool PartGui::evaluateAngularPreSelection(VectorAdapter &vector1Out, VectorAdapt
Base::Console().Message("Can't use selections without a pick point.\n");
continue;
}
if (shape.ShapeType() == TopAbs_EDGE)
{
TopoDS_Edge edge = TopoDS::Edge(shape);
@@ -835,7 +833,7 @@ bool PartGui::evaluateAngularPreSelection(VectorAdapter &vector1Out, VectorAdapt
adapters.push_back(VectorAdapter(edge, pickPoint));
continue;
}
if (shape.ShapeType() == TopAbs_FACE)
{
TopoDS_Face face = TopoDS::Face(shape);
@@ -843,22 +841,22 @@ bool PartGui::evaluateAngularPreSelection(VectorAdapter &vector1Out, VectorAdapt
continue;
}
}
if (adapters.size() != 2)
return false;
if (!adapters.front().isValid() || !adapters.back().isValid())
return false;
vector1Out = adapters.front();
vector2Out = adapters.back();
//making sure pick points are not equal
if ((vector1Out.getPickPoint() - vector2Out.getPickPoint()).Magnitude() < std::numeric_limits<float>::epsilon())
{
Base::Console().Message("pick points are equal\n");
return false;
}
return true;
}
@@ -867,32 +865,32 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
gp_Vec vector1 = vector1Adapter;
gp_Vec vector2 = vector2Adapter;
double angle = vector1.Angle(vector2);
std::ostringstream stream;
stream << std::setprecision(std::numeric_limits<double>::digits10 + 1) << std::fixed << std::endl <<
"angle in radians is: " << angle << std::endl <<
"angle in degrees is: " << 180 * angle / M_PI << std::endl;
if (angle < M_PI / 2.0)
stream << std::setprecision(std::numeric_limits<double>::digits10 + 1) <<
stream << std::setprecision(std::numeric_limits<double>::digits10 + 1) <<
"complement in radians is: " << M_PI / 2.0 - angle << std::endl <<
"complement in degrees is: " << 90 - 180 * angle / M_PI << std::endl;
//I don't think we get anything over 180, but just in case.
if (angle > M_PI / 2.0 && angle < M_PI)
stream << std::setprecision(std::numeric_limits<double>::digits10 + 1) <<
stream << std::setprecision(std::numeric_limits<double>::digits10 + 1) <<
"supplement in radians is: " << M_PI - angle << std::endl <<
"supplement in degrees is: " << 180 - 180 * angle / M_PI << std::endl;
Base::Console().Message(stream.str().c_str());
SbMatrix dimSys;
double radius;
double displayAngle;//have to fake the angle in the 3d.
if (vector1.IsParallel(vector2, Precision::Angular()))
{
//take first point project it onto second vector.
Handle(Geom_Curve) heapLine2 = new Geom_Line(vector2Adapter);
gp_Pnt tempPoint(vector1Adapter.getPickPoint().XYZ());
GeomAPI_ProjectPointOnCurve projection(tempPoint, heapLine2);
if (projection.NbPoints() < 1)
{
@@ -901,21 +899,21 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
}
gp_Vec newPoint2;
newPoint2.SetXYZ(projection.Point(1).XYZ());
//if points are colinear, projection doesn't work and returns the same point.
//In this case we just use the original point.
if ((newPoint2 - vector1Adapter.getPickPoint()).Magnitude() < Precision::Confusion())
newPoint2 = vector2Adapter.getPickPoint();
//now get midpoint between for dim origin.
gp_Vec point1 = vector1Adapter.getPickPoint();
gp_Vec midPointProjection = newPoint2 - point1;
double distance = midPointProjection.Magnitude();
midPointProjection.Normalize();
midPointProjection *= distance / 2.0;
gp_Vec origin = point1 + midPointProjection;
//yaxis should be the same as vector1, but doing this to eliminate any potential slop from
//using precision::angular. If lines are colinear and we have no plane, we can't establish zAxis from crossing.
//we just the absolute axis.
@@ -932,7 +930,7 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
zAxis = xAxis.Crossed(vector1).Normalized();
gp_Vec yAxis = zAxis.Crossed(xAxis).Normalized();
zAxis = xAxis.Crossed(yAxis).Normalized();
dimSys = SbMatrix
(
xAxis.X(), yAxis.X(), zAxis.X(), origin.X(),
@@ -941,7 +939,7 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
0.0, 0.0, 0.0, 1.0
);
dimSys = dimSys.transpose();
radius = midPointProjection.Magnitude();
displayAngle = M_PI;
}
@@ -949,15 +947,15 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
{
Handle(Geom_Curve) heapLine1 = new Geom_Line(vector1Adapter);
Handle(Geom_Curve) heapLine2 = new Geom_Line(vector2Adapter);
GeomAPI_ExtremaCurveCurve extrema(heapLine1, heapLine2);
if (extrema.NbExtrema() < 1)
{
Base::Console().Message("couldn't get extrema\n");
return;
}
gp_Pnt extremaPoint1, extremaPoint2, dimensionOriginPoint;
extrema.Points(1, extremaPoint1, extremaPoint2);
if (extremaPoint1.Distance(extremaPoint2) < Precision::Confusion())
@@ -973,7 +971,7 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
connection *= (distance / 2.0);
dimensionOriginPoint.SetXYZ((vec1 + connection).XYZ());
}
gp_Vec thirdPoint(vector2Adapter.getPickPoint());
gp_Vec originVector(dimensionOriginPoint.XYZ());
gp_Vec extrema2Vector(extremaPoint2.XYZ());
@@ -993,12 +991,12 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
otherSide.Normalize();
displayAngle = hyp.Angle(otherSide);
}
gp_Vec xAxis = (vector1Adapter.getPickPoint() - originVector).Normalized();
gp_Vec fakeYAxis = (thirdPoint - originVector).Normalized();
gp_Vec zAxis = (xAxis.Crossed(fakeYAxis)).Normalized();
gp_Vec yAxis = zAxis.Crossed(xAxis).Normalized();
dimSys = SbMatrix
(
xAxis.X(), yAxis.X(), zAxis.X(), dimensionOriginPoint.X(),
@@ -1006,7 +1004,7 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
xAxis.Z(), yAxis.Z(), zAxis.Z(), dimensionOriginPoint.Z(),
0.0, 0.0, 0.0, 1.0
);
dimSys = dimSys.transpose();
}
@@ -1023,7 +1021,7 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons
dimension->text.setValue((Base::Quantity(180 * angle / M_PI, Base::Unit::Angle)).getUserString().toUtf8().constData());
dimension->dColor.setValue(SbColor(c.r, c.g, c.b));
dimension->setupDimension();
Gui::View3DInventorViewer *viewer = getViewer();
if (viewer)
viewer->addDimension3d(dimension);
@@ -1101,7 +1099,7 @@ void PartGui::DimensionAngular::setupDimension()
setPart("arrow2.shape", cone);
set("arrow2.transform", "rotation 0.0 0.0 1.0 0.0");
set("arrow2.localTransform", str2);
//I was getting errors if I didn't manually allocate for these transforms. Not sure why.
SoTransform *arrow1Transform = new SoTransform();
SoComposeVec3f *arrow1Compose = new SoComposeVec3f();
@@ -1110,7 +1108,7 @@ void PartGui::DimensionAngular::setupDimension()
arrow1Compose->y.setValue(0.0);
arrow1Transform->translation.connectFrom(&arrow1Compose->vector);
setPart("arrow1.transform", arrow1Transform);
SoComposeRotation *arrow2Rotation = new SoComposeRotation();
arrow2Rotation->angle.connectFrom(&angle);
arrow2Rotation->axis.setValue(0.0, 0.0, 1.0);
@@ -1130,21 +1128,21 @@ void PartGui::DimensionAngular::setupDimension()
setPart("arrow1.material", material);
setPart("arrow2.material", material);
ArcEngine *arcEngine = new ArcEngine();
arcEngine->angle.connectFrom(&angle);
arcEngine->radius.connectFrom(&radius);
arcEngine->deviation.setValue(0.1f);
SoCoordinate3 *coordinates = new SoCoordinate3();
coordinates->point.connectFrom(&arcEngine->points);
SoLineSet *lineSet = new SoLineSet();
lineSet->ref();
lineSet->vertexProperty.setValue(coordinates);
lineSet->numVertices.connectFrom(&arcEngine->pointCount);
lineSet->startIndex.setValue(0);
SoSeparator *arcSep = static_cast<SoSeparator *>(getPart("arcSep", true));
if (arcSep) {
arcSep->addChild(material);
@@ -1162,17 +1160,17 @@ void PartGui::DimensionAngular::setupDimension()
textVecCalc->expression.set1Value(0, "oa = a / 2.0");
textVecCalc->expression.set1Value(1, "ob = cos(oa) * b"); //x
textVecCalc->expression.set1Value(2, "oc = sin(oa) * b"); //y
SoComposeVec3f *textLocation = new SoComposeVec3f();
textLocation->x.connectFrom(&textVecCalc->ob);
textLocation->y.connectFrom(&textVecCalc->oc);
textLocation->z.setValue(0.0);
SoTransform *textTransform = new SoTransform();
textTransform->translation.connectFrom(&textLocation->vector);
textSep->addChild(textTransform);
SoFont *fontNode = new SoFont();
fontNode->name.setValue("defaultFont");
fontNode->size.setValue(30);
@@ -1220,7 +1218,7 @@ void PartGui::ArcEngine::evaluate()
defaultValues();
return;
}
float deviationAngle(acos((radius.getValue() - deviation.getValue()) / radius.getValue()));
std::vector<SbVec3f> tempPoints;
int segmentCount;
@@ -1275,17 +1273,17 @@ PartGui::SteppedSelection::SteppedSelection(const uint& buttonCountIn, QWidget*
{
if (buttonCountIn < 1)
return;
QVBoxLayout *mainLayout = new QVBoxLayout();
this->setLayout(mainLayout);
QButtonGroup *buttonGroup = new QButtonGroup();
buttonGroup->setExclusive(true);
for (uint index = 0; index < buttonCountIn; ++index)
{
ButtonIconPairType tempPair;
std::ostringstream stream;
stream << "Selection " << ((index < 10) ? "0" : "") << index + 1;
QString buttonText = QObject::tr(stream.str().c_str());
@@ -1294,13 +1292,13 @@ PartGui::SteppedSelection::SteppedSelection(const uint& buttonCountIn, QWidget*
button->setEnabled(false);
buttonGroup->addButton(button);
connect(button, SIGNAL(toggled(bool)), this, SLOT(selectionSlot(bool)));
QLabel *label = new QLabel;
tempPair.first = button;
tempPair.second = label;
buttons.push_back(tempPair);
QHBoxLayout *layout = new QHBoxLayout();
mainLayout->addLayout(layout);
layout->addWidget(button);
@@ -1309,7 +1307,7 @@ PartGui::SteppedSelection::SteppedSelection(const uint& buttonCountIn, QWidget*
layout->addStretch();
}
mainLayout->addStretch();
buildPixmaps(); //uses button size
}
@@ -1346,7 +1344,7 @@ void PartGui::SteppedSelection::selectionSlot(bool checked)
if (it->first == sender)
break;
assert(it != buttons.end());
if (checked)
it->second->setPixmap(*stepActive);
else
@@ -1367,21 +1365,21 @@ PartGui::DimensionControl::DimensionControl(QWidget* parent): QWidget(parent)
{
QVBoxLayout *commandLayout = new QVBoxLayout();
this->setLayout(commandLayout);
resetButton = new QPushButton(Gui::BitmapFactory().pixmap("Part_Measure_Linear"),
QObject::tr("Reset Dialog"), this);
commandLayout->addWidget(resetButton);
QPushButton *toggle3dButton = new QPushButton(Gui::BitmapFactory().pixmap("Part_Measure_Toggle_3d"),
QObject::tr("Toggle 3d"), this);
QObject::connect(toggle3dButton, SIGNAL(clicked(bool)), this, SLOT(toggle3dSlot(bool)));
commandLayout->addWidget(toggle3dButton);
QPushButton *toggleDeltaButton = new QPushButton(Gui::BitmapFactory().pixmap("Part_Measure_Toggle_Delta"),
QObject::tr("Toggle Delta"), this);
QObject::connect(toggleDeltaButton, SIGNAL(clicked(bool)), this, SLOT(toggleDeltaSlot(bool)));
commandLayout->addWidget(toggleDeltaButton);
QPushButton *clearAllButton = new QPushButton(Gui::BitmapFactory().pixmap("Part_Measure_Clear_All"),
QObject::tr("Clear All"), this);
QObject::connect(clearAllButton, SIGNAL(clicked(bool)), this, SLOT(clearAllSlot(bool)));
@@ -1441,7 +1439,7 @@ void PartGui::TaskMeasureAngular::onSelectionChanged(const Gui::SelectionChanges
if (selections1.selections.at(0).shapeType != DimSelections::Vertex)
selections1.selections.clear();
}
newSelection.shapeType = DimSelections::Vertex;
selections1.selections.push_back(newSelection);
if (selections1.selections.size() == 1)
@@ -1450,28 +1448,28 @@ void PartGui::TaskMeasureAngular::onSelectionChanged(const Gui::SelectionChanges
assert(selections1.selections.size() == 2);
assert(selections1.selections.at(0).shapeType == DimSelections::Vertex);
assert(selections1.selections.at(1).shapeType == DimSelections::Vertex);
QTimer::singleShot(0, this, SLOT(selectionClearDelayedSlot()));
stepped->getButton(1)->setEnabled(true);
stepped->getButton(1)->setChecked(true);
return;
}
//here there should only be one in the selections container. so just clear it.
selections1.selections.clear();
if (shape.ShapeType() == TopAbs_EDGE)
{
newSelection.shapeType = DimSelections::Edge;
selections1.selections. push_back(newSelection);
}
if (shape.ShapeType() == TopAbs_FACE)
{
newSelection.shapeType = DimSelections::Face;
selections1.selections.push_back(newSelection);
}
QTimer::singleShot(0, this, SLOT(selectionClearDelayedSlot()));
stepped->getButton(1)->setEnabled(true);
stepped->getButton(1)->setChecked(true);
@@ -1493,7 +1491,7 @@ void PartGui::TaskMeasureAngular::onSelectionChanged(const Gui::SelectionChanges
if (selections2.selections.at(0).shapeType != DimSelections::Vertex)
selections2.selections.clear();
}
newSelection.shapeType = DimSelections::Vertex;
selections2.selections.push_back(newSelection);
if (selections2.selections.size() == 1)
@@ -1502,7 +1500,7 @@ void PartGui::TaskMeasureAngular::onSelectionChanged(const Gui::SelectionChanges
assert(selections2.selections.size() == 2);
assert(selections2.selections.at(0).shapeType == DimSelections::Vertex);
assert(selections2.selections.at(1).shapeType == DimSelections::Vertex);
buildDimension();
clearSelection();
QTimer::singleShot(0, this, SLOT(selectionClearDelayedSlot()));
@@ -1512,19 +1510,19 @@ void PartGui::TaskMeasureAngular::onSelectionChanged(const Gui::SelectionChanges
}
//vertices have to be selected in succession. if we get here,clear temp selection.
selections2.selections.clear();
if (shape.ShapeType() == TopAbs_EDGE)
{
newSelection.shapeType = DimSelections::Edge;
selections2.selections. push_back(newSelection);
}
if (shape.ShapeType() == TopAbs_FACE)
{
newSelection.shapeType = DimSelections::Face;
selections2.selections.push_back(newSelection);
}
buildDimension();
clearSelection();
QTimer::singleShot(0, this, SLOT(selectionClearDelayedSlot()));
@@ -1582,7 +1580,7 @@ PartGui::VectorAdapter PartGui::TaskMeasureAngular::buildAdapter(const PartGui::
TopoDS_Shape faceShape;
if (!getShapeFromStrings(faceShape, current.documentName, current.objectName, current.subObjectName))
return VectorAdapter();
TopoDS_Face face = TopoDS::Face(faceShape);
gp_Vec pickPoint(current.x, current.y, current.z);
return VectorAdapter(face, pickPoint);
@@ -1611,7 +1609,7 @@ void PartGui::TaskMeasureAngular::buildDimension()
//build adapters.
VectorAdapter adapt1 = buildAdapter(selections1);
VectorAdapter adapt2 = buildAdapter(selections2);
if (!adapt1.isValid() || !adapt2.isValid())
{
Base::Console().Message("\ncouldn't build adapter\n\n");
@@ -1629,27 +1627,27 @@ void PartGui::TaskMeasureAngular::clearSelection()
void PartGui::TaskMeasureAngular::setUpGui()
{
QPixmap mainIcon = Gui::BitmapFactory().pixmap("Part_Measure_Angular");
Gui::TaskView::TaskBox* selectionTaskBox = new Gui::TaskView::TaskBox
(mainIcon, QObject::tr("Selections"), false, 0);
QVBoxLayout *selectionLayout = new QVBoxLayout();
stepped = new SteppedSelection(2, selectionTaskBox);
selectionLayout->addWidget(stepped);
selectionTaskBox->groupLayout()->addLayout(selectionLayout);
Gui::TaskView::TaskBox* controlTaskBox = new Gui::TaskView::TaskBox
(mainIcon, QObject::tr("Control"), false, 0);
QVBoxLayout *controlLayout = new QVBoxLayout();
DimensionControl *control = new DimensionControl(controlTaskBox);
controlLayout->addWidget(control);
controlTaskBox->groupLayout()->addLayout(controlLayout);
QObject::connect(control->resetButton, SIGNAL(clicked(bool)), this, SLOT(resetDialogSlot(bool)));
this->setButtonPosition(TaskDialog::South);
Content.push_back(selectionTaskBox);
Content.push_back(controlTaskBox);
stepped->getButton(0)->setChecked(true);//before wired up.
stepped->getButton(0)->setEnabled(true);
QObject::connect(stepped->getButton(0), SIGNAL(toggled(bool)), this, SLOT(selection1Slot(bool)));

View File

@@ -43,11 +43,10 @@
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoCamera.h>
# include <Inventor/nodes/SoSeparator.h>
# include <boost/signals2.hpp>
# include <boost/bind.hpp>
#endif
#include <boost/signals2.hpp>
#include <boost/bind.hpp>
#include "ui_TaskFaceColors.h"
#include "TaskFaceColors.h"
#include "ViewProviderExt.h"

View File

@@ -45,11 +45,9 @@
# include <Inventor/nodes/SoSwitch.h>
# include <QAction>
# include <QMenu>
# include <boost/bind.hpp>
#endif
#include <boost/bind.hpp>
#include <App/PropertyStandard.h>
#include <Mod/Part/App/PartFeature.h>
#include <Gui/ActionFunction.h>