diff --git a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp index b4d9687c0d..ad0d94011a 100644 --- a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp +++ b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp @@ -21,6 +21,32 @@ ***************************************************************************/ #include "PreCompiled.h" + +#ifndef _PreComp_ +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include "ShapeFix_Edge.hxx" +# include +# include +# include +# include +# include +# include +# include +#endif + #include "DlgProjectionOnSurface.h" #include "ui_DlgProjectionOnSurface.h" @@ -35,28 +61,9 @@ #include "ViewProviderExt.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ShapeFix_Edge.hxx" -#include -#include -#include -#include -#include -#include -#include + + + using namespace PartGui; diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp index 2c422ac987..a687134b7f 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp @@ -26,10 +26,9 @@ # include # include # include +# include #endif -#include - #include #include @@ -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() diff --git a/src/Mod/Part/Gui/PreCompiled.h b/src/Mod/Part/Gui/PreCompiled.h index f6a9a1782c..c97a5005b4 100644 --- a/src/Mod/Part/Gui/PreCompiled.h +++ b/src/Mod/Part/Gui/PreCompiled.h @@ -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 +#endif + #ifdef _PreComp_ // standard @@ -57,6 +61,8 @@ //#include //#include //#include +# include +#include // STL #include @@ -69,12 +75,9 @@ #include #include -#ifdef FC_OS_WIN32 -# include -#endif - // OpenCasCade Base #include +#include #include #include @@ -97,6 +100,8 @@ #include #include #include +#include +#include #include #include #include @@ -114,20 +119,90 @@ #include #include +#include + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include "ShapeFix_Edge.hxx" +# include +# include +# include +# include +# include +# include + +#include +#include +#include +#include +#include + +#if OCC_VERSION_HEX >= 0x060600 +# include +# include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +// Python + #include +// Boost +#include +#include + // Qt Toolkit #ifndef __Qt4All__ # include #endif -// Inventor +// GL +// Include glext before InventorAll +# ifdef FC_OS_WIN32 +# include +# include +# else +# ifdef FC_OS_MACOSX +# include +# include +# else +# include +# include +# endif //FC_OS_MACOSX +# endif //FC_OS_WIN32 +// Should come after glext.h to avoid warnings +# include + +#include +#include +#include +#include +#include +#include +#include + +// Inventor includes OpenGL #ifndef __InventorAll__ # include #endif -#elif defined(FC_OS_WIN32) -#include #endif //_PreComp_ -#endif +#endif // PARTGUI_PRECOMPILED_H diff --git a/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp b/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp index 424f03f283..688f952673 100644 --- a/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp +++ b/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp @@ -22,10 +22,14 @@ #include "PreCompiled.h" -#ifdef _MSC_VER -#define _USE_MATH_DEFINES -#include -#endif + +#ifndef _PreComp_ +# ifdef _MSC_VER +# define _USE_MATH_DEFINES +# include +# endif //_MSC_VER +#endif // _PreComp_ + #include #include #include @@ -90,7 +94,7 @@ void PropertyEnumAttacherItem::openTask() return; } } - + Gui::Control().showDialog(task); } diff --git a/src/Mod/Part/Gui/SoBrepEdgeSet.cpp b/src/Mod/Part/Gui/SoBrepEdgeSet.cpp index 423784bc68..4c0f75c337 100644 --- a/src/Mod/Part/Gui/SoBrepEdgeSet.cpp +++ b/src/Mod/Part/Gui/SoBrepEdgeSet.cpp @@ -25,12 +25,12 @@ #ifndef _PreComp_ # ifdef FC_OS_WIN32 -# include +# include # endif # ifdef FC_OS_MACOSX -# include +# include # else -# include +# include # endif # include # include diff --git a/src/Mod/Part/Gui/SoBrepFaceSet.cpp b/src/Mod/Part/Gui/SoBrepFaceSet.cpp index 4a952eae27..c74280b384 100644 --- a/src/Mod/Part/Gui/SoBrepFaceSet.cpp +++ b/src/Mod/Part/Gui/SoBrepFaceSet.cpp @@ -27,34 +27,49 @@ #endif #ifndef _PreComp_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# ifdef FC_OS_WIN32 +# include +# include +# include +# else +# ifdef FC_OS_MACOSX +# include +# include +# else +# include +# include +# endif //FC_OS_MACOSX +# endif //FC_OS_WIN32 +// Should come after glext.h to avoid warnings +# include #endif #include "SoBrepFaceSet.h" @@ -62,24 +77,6 @@ #include #include -#ifdef FC_OS_WIN32 -#include -#include -#include -#else -#ifdef FC_OS_MACOSX -#include -#include -#else -#include -#include -#endif -#endif - -// Should come after glext.h to avoid warnings -#include - - 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(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++; diff --git a/src/Mod/Part/Gui/SoBrepPointSet.cpp b/src/Mod/Part/Gui/SoBrepPointSet.cpp index 5c5bfe0aa1..d404b2a059 100644 --- a/src/Mod/Part/Gui/SoBrepPointSet.cpp +++ b/src/Mod/Part/Gui/SoBrepPointSet.cpp @@ -25,12 +25,12 @@ #ifndef _PreComp_ # ifdef FC_OS_WIN32 -# include +# include # endif # ifdef FC_OS_MACOSX -# include +# include # else -# include +# include # endif # include # include @@ -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) { diff --git a/src/Mod/Part/Gui/SoFCShapeObject.cpp b/src/Mod/Part/Gui/SoFCShapeObject.cpp index af853a0f4e..c061a3b69e 100644 --- a/src/Mod/Part/Gui/SoFCShapeObject.cpp +++ b/src/Mod/Part/Gui/SoFCShapeObject.cpp @@ -25,12 +25,12 @@ #ifndef _PreComp_ # ifdef FC_OS_WIN32 -# include +# include # endif # ifdef FC_OS_MACOSX -# include +# include # else -# include +# include # endif # include # include diff --git a/src/Mod/Part/Gui/TaskCheckGeometry.cpp b/src/Mod/Part/Gui/TaskCheckGeometry.cpp index 0b74eec02b..3310088f95 100644 --- a/src/Mod/Part/Gui/TaskCheckGeometry.cpp +++ b/src/Mod/Part/Gui/TaskCheckGeometry.cpp @@ -30,36 +30,36 @@ # include # include # include -#endif +# include +# include +# include +# include +# include +# include -#include -#include -#include -#include -#include -#include +# if OCC_VERSION_HEX >= 0x060600 +# include +# include +# endif -#if OCC_VERSION_HEX >= 0x060600 -#include -#include -#endif +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif //_PreComp_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "../App/PartFeature.h" #include #include @@ -169,7 +169,7 @@ QVector 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 ¤t = 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"), diff --git a/src/Mod/Part/Gui/TaskDimension.cpp b/src/Mod/Part/Gui/TaskDimension.cpp index b1adf22d8e..7e962d19da 100644 --- a/src/Mod/Part/Gui/TaskDimension.cpp +++ b/src/Mod/Part/Gui/TaskDimension.cpp @@ -25,48 +25,46 @@ #ifndef _PreCpmp_ # include # include +# include +# include + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include #endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include #include "../App/PartFeature.h" @@ -109,7 +107,7 @@ bool PartGui::evaluateLinearPreSelection(TopoDS_Shape &shape1, TopoDS_Shape &sha return false; std::vector::iterator it; std::vector shapes; - + for (it = selections.begin(); it != selections.end(); ++it) { Part::Feature *feature = dynamic_cast((*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::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((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::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::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::digits10 + 1) << + stream << std::setprecision(std::numeric_limits::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::digits10 + 1) << + stream << std::setprecision(std::numeric_limits::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(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 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))); diff --git a/src/Mod/Part/Gui/TaskFaceColors.cpp b/src/Mod/Part/Gui/TaskFaceColors.cpp index 23f5e162b6..449af4cffc 100644 --- a/src/Mod/Part/Gui/TaskFaceColors.cpp +++ b/src/Mod/Part/Gui/TaskFaceColors.cpp @@ -43,11 +43,10 @@ # include # include # include +# include +# include #endif -#include -#include - #include "ui_TaskFaceColors.h" #include "TaskFaceColors.h" #include "ViewProviderExt.h" diff --git a/src/Mod/Part/Gui/ViewProviderSpline.cpp b/src/Mod/Part/Gui/ViewProviderSpline.cpp index 77e52559a2..feaeb35b97 100644 --- a/src/Mod/Part/Gui/ViewProviderSpline.cpp +++ b/src/Mod/Part/Gui/ViewProviderSpline.cpp @@ -45,11 +45,9 @@ # include # include # include +# include #endif -#include - - #include #include #include