| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include "Gui/Application.h"
|
| | #include "Gui/MDIView.h"
|
| |
|
| | #include <Inventor/actions/SoGetMatrixAction.h>
|
| | #include <Inventor/nodes/SoAnnotation.h>
|
| | #include <Inventor/nodes/SoBaseColor.h>
|
| | #include <Inventor/nodes/SoCoordinate3.h>
|
| | #include <Inventor/nodes/SoCamera.h>
|
| | #include <Inventor/nodes/SoDrawStyle.h>
|
| | #include <Inventor/nodes/SoIndexedLineSet.h>
|
| | #include <Inventor/nodes/SoMarkerSet.h>
|
| | #include <Inventor/nodes/SoPickStyle.h>
|
| | #include <Inventor/draggers/SoTranslate2Dragger.h>
|
| | #include <Inventor/engines/SoComposeMatrix.h>
|
| | #include <Inventor/engines/SoTransformVec3f.h>
|
| | #include <Inventor/engines/SoConcatenate.h>
|
| | #include <Inventor/SbViewportRegion.h>
|
| |
|
| |
|
| | #include <App/DocumentObject.h>
|
| | #include <Base/Console.h>
|
| | #include <Gui/BitmapFactory.h>
|
| | #include <Gui/Document.h>
|
| | #include <Gui/ViewParams.h>
|
| | #include <Gui/Inventor/MarkerBitmaps.h>
|
| | #include <Gui/View3DInventor.h>
|
| | #include <Gui/View3DInventorViewer.h>
|
| |
|
| | #include <Mod/Measure/App/Preferences.h>
|
| | #include "ViewProviderMeasureBase.h"
|
| |
|
| | using namespace MeasureGui;
|
| | using namespace Measure;
|
| |
|
| |
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasureGroup, Gui::ViewProviderDocumentObjectGroup)
|
| |
|
| | ViewProviderMeasureGroup::ViewProviderMeasureGroup()
|
| | {}
|
| |
|
| | ViewProviderMeasureGroup::~ViewProviderMeasureGroup() = default;
|
| |
|
| | QIcon ViewProviderMeasureGroup::getIcon() const
|
| | {
|
| | return Gui::BitmapFactory().pixmap("Measurement-Group.svg");
|
| | }
|
| |
|
| |
|
| |
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasureBase, Gui::ViewProviderDocumentObject)
|
| |
|
| |
|
| | ViewProviderMeasureBase::ViewProviderMeasureBase()
|
| | {
|
| | static const char* agroup = "Appearance";
|
| |
|
| | ADD_PROPERTY_TYPE(
|
| | TextColor,
|
| | (Preferences::defaultTextColor()),
|
| | agroup,
|
| | App::Prop_None,
|
| | "Color for the measurement text"
|
| | );
|
| | ADD_PROPERTY_TYPE(
|
| | TextBackgroundColor,
|
| | (Preferences::defaultTextBackgroundColor()),
|
| | agroup,
|
| | App::Prop_None,
|
| | "Color for the measurement text background"
|
| | );
|
| | ADD_PROPERTY_TYPE(
|
| | LineColor,
|
| | (Preferences::defaultLineColor()),
|
| | agroup,
|
| | App::Prop_None,
|
| | "Color for the measurement lines"
|
| | );
|
| | ADD_PROPERTY_TYPE(
|
| | FontSize,
|
| | (Preferences::defaultFontSize()),
|
| | agroup,
|
| | App::Prop_None,
|
| | "Size of measurement text"
|
| | );
|
| |
|
| |
|
| | pGlobalSeparator = new SoSeparator();
|
| | pGlobalSeparator->ref();
|
| |
|
| |
|
| | auto visibilitySwitch = new SoSwitch();
|
| | getRoot()->insertChild(visibilitySwitch, 0);
|
| | visibilitySwitch->addChild(pGlobalSeparator);
|
| | visibilitySwitch->whichChild.connectFrom(&pcModeSwitch->whichChild);
|
| |
|
| |
|
| | pLabel = new Gui::SoFrameLabel();
|
| | pLabel->ref();
|
| | pColor = new SoBaseColor();
|
| | pColor->ref();
|
| | pLabelTranslation = new SoTransform();
|
| | pLabelTranslation->ref();
|
| |
|
| | auto ps = getSoPickStyle();
|
| |
|
| |
|
| | SoSeparator* dragSeparator = new SoSeparator();
|
| | pDragger = new SoTranslate2Dragger();
|
| | pDragger->ref();
|
| | pDraggerOrientation = new SoTransform();
|
| | pDraggerOrientation->ref();
|
| | dragSeparator->addChild(pDraggerOrientation);
|
| | dragSeparator->addChild(pDragger);
|
| |
|
| |
|
| | auto matrixEngine = new SoComposeMatrix();
|
| | matrixEngine->rotation.connectFrom(&pDraggerOrientation->rotation);
|
| | auto transformEngine = new SoTransformVec3f();
|
| | transformEngine->vector.connectFrom(&pDragger->translation);
|
| | transformEngine->matrix.connectFrom(&matrixEngine->matrix);
|
| | pLabelTranslation->translation.connectFrom(&transformEngine->point);
|
| |
|
| | pTextSeparator = new SoSeparator();
|
| | pTextSeparator->ref();
|
| | pTextSeparator->addChild(dragSeparator);
|
| | pTextSeparator->addChild(pLabelTranslation);
|
| | pTextSeparator->addChild(pLabel);
|
| |
|
| |
|
| | pLineSeparator = new SoSeparator();
|
| | pLineSeparator->ref();
|
| | pLineSeparator->addChild(ps);
|
| | pLineSeparator->addChild(getSoLineStylePrimary());
|
| | pLineSeparator->addChild(pColor);
|
| |
|
| |
|
| | pLineSeparatorSecondary = new SoSeparator();
|
| | pLineSeparatorSecondary->ref();
|
| | pLineSeparatorSecondary->addChild(ps);
|
| | pLineSeparatorSecondary->addChild(getSoLineStyleSecondary());
|
| | pLineSeparatorSecondary->addChild(pColor);
|
| |
|
| | pRootSeparator = new SoAnnotation();
|
| | pRootSeparator->ref();
|
| | pRootSeparator->addChild(pLineSeparator);
|
| | pRootSeparator->addChild(pLineSeparatorSecondary);
|
| | pRootSeparator->addChild(pTextSeparator);
|
| | addDisplayMaskMode(pRootSeparator, "Base");
|
| |
|
| | pRootSeparator->touch();
|
| | pTextSeparator->touch();
|
| | pLineSeparator->touch();
|
| |
|
| |
|
| | auto dragger = pDragger;
|
| |
|
| | dragger->addValueChangedCallback(draggerChangedCallback, this);
|
| |
|
| |
|
| |
|
| | SoSearchAction sa;
|
| | sa.setInterest(SoSearchAction::FIRST);
|
| | sa.setSearchingAll(true);
|
| | sa.setNode(pLabel);
|
| | sa.apply(pcRoot);
|
| | SoPath* labelPath = sa.getPath();
|
| | assert(labelPath);
|
| | dragger->setPartAsPath("translator", labelPath);
|
| |
|
| |
|
| | dragger->setPart("translatorActive", NULL);
|
| | dragger->setPart("xAxisFeedback", NULL);
|
| | dragger->setPart("yAxisFeedback", NULL);
|
| |
|
| |
|
| |
|
| |
|
| | TextColor.touch();
|
| | TextBackgroundColor.touch();
|
| | FontSize.touch();
|
| | LineColor.touch();
|
| | fieldFontSize.setValue(FontSize.getValue());
|
| | }
|
| |
|
| | ViewProviderMeasureBase::~ViewProviderMeasureBase()
|
| | {
|
| | _mVisibilityChangedConnection.disconnect();
|
| | pGlobalSeparator->unref();
|
| | pLabel->unref();
|
| | pColor->unref();
|
| | pDragger->unref();
|
| | pDraggerOrientation->unref();
|
| | pLabelTranslation->unref();
|
| | pTextSeparator->unref();
|
| | pLineSeparator->unref();
|
| | pRootSeparator->unref();
|
| | }
|
| |
|
| | std::vector<std::string> ViewProviderMeasureBase::getDisplayModes() const
|
| | {
|
| |
|
| | std::vector<std::string> StrList;
|
| | StrList.emplace_back("Base");
|
| | return StrList;
|
| | }
|
| |
|
| | void ViewProviderMeasureBase::setDisplayMode(const char* ModeName)
|
| | {
|
| | if (strcmp(ModeName, "Base") == 0) {
|
| | setDisplayMaskMode("Base");
|
| | }
|
| | ViewProviderDocumentObject::setDisplayMode(ModeName);
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::finishRestoring()
|
| | {
|
| | if (Visibility.getValue() && isSubjectVisible()) {
|
| | show();
|
| | }
|
| | ViewProviderDocumentObject::finishRestoring();
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::onChanged(const App::Property* prop)
|
| | {
|
| | if (prop == &TextColor) {
|
| | const Base::Color& color = TextColor.getValue();
|
| | pLabel->textColor.setValue(color.r, color.g, color.b);
|
| | updateIcon();
|
| | }
|
| | else if (prop == &TextBackgroundColor) {
|
| | const Base::Color& color = TextBackgroundColor.getValue();
|
| | pLabel->backgroundColor.setValue(color.r, color.g, color.b);
|
| | }
|
| | else if (prop == &LineColor) {
|
| | const Base::Color& color = LineColor.getValue();
|
| | pColor->rgb.setValue(color.r, color.g, color.b);
|
| | }
|
| | else if (prop == &FontSize) {
|
| | pLabel->size = FontSize.getValue();
|
| | fieldFontSize.setValue(FontSize.getValue());
|
| | }
|
| |
|
| | ViewProviderDocumentObject::onChanged(prop);
|
| | }
|
| |
|
| | void ViewProviderMeasureBase::draggerChangedCallback(void* data, SoDragger*)
|
| | {
|
| | auto me = static_cast<ViewProviderMeasureBase*>(data);
|
| | me->onLabelMoved();
|
| | }
|
| |
|
| | void ViewProviderMeasureBase::setLabelValue(const Base::Quantity& value)
|
| | {
|
| | pLabel->string.setValue(value.getUserString().c_str());
|
| | }
|
| |
|
| | void ViewProviderMeasureBase::setLabelValue(const QString& value)
|
| | {
|
| | auto lines = value.split(QStringLiteral("\n"));
|
| |
|
| | int i = 0;
|
| | for (auto& it : lines) {
|
| | pLabel->string.set1Value(i, it.toUtf8().constData());
|
| | i++;
|
| | }
|
| | }
|
| |
|
| | void ViewProviderMeasureBase::setLabelTranslation(const SbVec3f& position)
|
| | {
|
| |
|
| | pDragger->translation.setValue(position);
|
| | }
|
| |
|
| |
|
| | SoPickStyle* ViewProviderMeasureBase::getSoPickStyle()
|
| | {
|
| | auto ps = new SoPickStyle();
|
| | ps->style = SoPickStyle::UNPICKABLE;
|
| | return ps;
|
| | }
|
| |
|
| | SoDrawStyle* ViewProviderMeasureBase::getSoLineStylePrimary()
|
| | {
|
| | auto style = new SoDrawStyle();
|
| | style->lineWidth = 2.0f;
|
| | return style;
|
| | }
|
| |
|
| | SoDrawStyle* ViewProviderMeasureBase::getSoLineStyleSecondary()
|
| | {
|
| | auto style = new SoDrawStyle();
|
| | style->lineWidth = 1.0f;
|
| | return style;
|
| | }
|
| |
|
| | SoSeparator* ViewProviderMeasureBase::getSoSeparatorText()
|
| | {
|
| | return pTextSeparator;
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::positionAnno(const Measure::MeasureBase* measureObject)
|
| | {
|
| | (void)measureObject;
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::updateIcon()
|
| | {
|
| |
|
| |
|
| | Gui::ColorMap colorMap {
|
| | {0x000000, TextColor.getValue().getPackedRGB() >> 8},
|
| | };
|
| | pLabel->setIcon(Gui::BitmapFactory().pixmapFromSvg(sPixmap, QSize(20, 20), colorMap));
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::attach(App::DocumentObject* pcObj)
|
| | {
|
| | ViewProviderDocumentObject::attach(pcObj);
|
| | updateIcon();
|
| | }
|
| |
|
| |
|
| |
|
| | void ViewProviderMeasureBase::updateData(const App::Property* prop)
|
| | {
|
| | bool doUpdate = false;
|
| |
|
| | auto obj = getMeasureObject();
|
| | if (!obj) {
|
| | return;
|
| | }
|
| |
|
| | if (strcmp(prop->getName(), "Label") == 0) {
|
| | doUpdate = true;
|
| | }
|
| |
|
| |
|
| | auto inputProps = obj->getInputProps();
|
| | if (std::ranges::find(inputProps, std::string(prop->getName())) != inputProps.end()) {
|
| | doUpdate = true;
|
| |
|
| |
|
| | connectToSubject(obj->getSubject());
|
| | }
|
| |
|
| |
|
| | auto resultProp = obj->getResultProp();
|
| | if (resultProp && prop == resultProp) {
|
| | doUpdate = true;
|
| | }
|
| |
|
| | if (doUpdate) {
|
| | redrawAnnotation();
|
| |
|
| |
|
| | std::string userLabel(obj->Label.getValue());
|
| | std::string name = userLabel.substr(0, userLabel.find(":"));
|
| | obj->Label.setValue((name + ": ") + obj->getResultString().toStdString());
|
| | }
|
| |
|
| | ViewProviderDocumentObject::updateData(prop);
|
| | }
|
| |
|
| |
|
| |
|
| | void ViewProviderMeasureBase::redrawAnnotation()
|
| | {
|
| |
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::connectToSubject(App::DocumentObject* subject)
|
| | {
|
| | if (!subject) {
|
| | return;
|
| | }
|
| |
|
| |
|
| | if (_mVisibilityChangedConnection.connected()) {
|
| | _mVisibilityChangedConnection.disconnect();
|
| | }
|
| |
|
| |
|
| | auto bndVisibility = std::bind(
|
| | &ViewProviderMeasureBase::onSubjectVisibilityChanged,
|
| | this,
|
| | std::placeholders::_1,
|
| | std::placeholders::_2
|
| | );
|
| |
|
| | _mVisibilityChangedConnection = subject->signalChanged.connect(bndVisibility);
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::connectToSubject(std::vector<App::DocumentObject*> subject)
|
| | {
|
| | if (subject.empty()) {
|
| | return;
|
| | }
|
| |
|
| |
|
| | auto proxy = subject.front();
|
| | connectToSubject(proxy);
|
| | }
|
| |
|
| |
|
| |
|
| | Measure::MeasureBase* ViewProviderMeasureBase::getMeasureObject()
|
| | {
|
| |
|
| |
|
| | auto feature = dynamic_cast<Measure::MeasureBase*>(pcObject);
|
| | if (!feature) {
|
| | throw Base::RuntimeError("Feature not found for ViewProviderMeasureBase");
|
| | }
|
| | return feature;
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | Base::Vector3d ViewProviderMeasureBase::getTextDirection(Base::Vector3d elementDirection, double tolerance)
|
| | {
|
| |
|
| |
|
| |
|
| |
|
| | Base::Vector3d viewDirection;
|
| | Base::Vector3d upDirection;
|
| |
|
| | Gui::View3DInventor* view = nullptr;
|
| | try {
|
| | view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
|
| | }
|
| | catch (const Base::RuntimeError&) {
|
| | Base::Console().log("ViewProviderMeasureBase::getTextDirection: Could not get active view\n");
|
| | }
|
| |
|
| | if (view) {
|
| | Gui::View3DInventorViewer* viewer = view->getViewer();
|
| | viewDirection = toVector3d(viewer->getViewDirection()).Normalize();
|
| | upDirection = toVector3d(viewer->getUpDirection()).Normalize();
|
| |
|
| |
|
| |
|
| | }
|
| | else {
|
| | viewDirection = Base::Vector3d(0.0, 1.0, 0.0);
|
| | upDirection = Base::Vector3d(0.0, 0.0, 1.0);
|
| | }
|
| |
|
| | Base::Vector3d textDirection = elementDirection.Cross(viewDirection);
|
| | if (textDirection.Length() < tolerance) {
|
| |
|
| | textDirection = elementDirection.Cross(upDirection);
|
| | }
|
| |
|
| | return textDirection.Normalize();
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | bool ViewProviderMeasureBase::isSubjectVisible()
|
| | {
|
| | Gui::Document* guiDoc = nullptr;
|
| | try {
|
| | guiDoc = this->getDocument();
|
| | }
|
| | catch (const Base::RuntimeError&) {
|
| | Base::Console().log("ViewProviderMeasureBase::isSubjectVisible: Could not get document\n");
|
| | return false;
|
| | }
|
| |
|
| |
|
| | if (!getMeasureObject() || !guiDoc) {
|
| | return false;
|
| | }
|
| |
|
| |
|
| | if (getMeasureObject()->getSubject().empty()) {
|
| | return true;
|
| | }
|
| |
|
| | for (auto& obj : getMeasureObject()->getSubject()) {
|
| | Gui::ViewProvider* vp = guiDoc->getViewProvider(obj);
|
| | if (!vp || !vp->isVisible()) {
|
| | return false;
|
| | }
|
| | }
|
| |
|
| |
|
| | return true;
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | void ViewProviderMeasureBase::onSubjectVisibilityChanged(
|
| | const App::DocumentObject& docObj,
|
| | const App::Property& prop
|
| | )
|
| | {
|
| | if (docObj.isRemoving()) {
|
| | return;
|
| | }
|
| |
|
| |
|
| | std::string propName = prop.getName();
|
| | if (propName == "Visibility") {
|
| | if (!docObj.Visibility.getValue()) {
|
| |
|
| | setVisible(false);
|
| | }
|
| | else {
|
| |
|
| |
|
| | setVisible(isSubjectVisible() && Visibility.getValue());
|
| | }
|
| | }
|
| | }
|
| |
|
| |
|
| | float ViewProviderMeasureBase::getViewScale()
|
| | {
|
| | float scale = 1.0;
|
| |
|
| | Gui::View3DInventor* view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
|
| | if (!view) {
|
| | Base::Console().log("ViewProviderMeasureBase::getViewScale: Could not get active view\n");
|
| | return scale;
|
| | }
|
| | Gui::View3DInventorViewer* viewer = view->getViewer();
|
| |
|
| | SoCamera* const camera = viewer->getSoRenderManager()->getCamera();
|
| | if (!camera) {
|
| | return false;
|
| | }
|
| |
|
| | SbViewVolume volume(camera->getViewVolume());
|
| | SbVec3f center(volume.getSightPoint(camera->focalDistance.getValue()));
|
| | scale = volume.getWorldToScreenScale(center, 1.0);
|
| | return scale;
|
| | }
|
| |
|
| |
|
| |
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasure, MeasureGui::ViewProviderMeasureBase)
|
| |
|
| |
|
| |
|
| |
|
| | ViewProviderMeasure::ViewProviderMeasure()
|
| | {
|
| | sPixmap = "umf-measurement";
|
| |
|
| |
|
| |
|
| | const size_t lineCount(3);
|
| |
|
| |
|
| |
|
| | static const int32_t lines[lineCount] = {0, 1, -1};
|
| |
|
| | pCoords = new SoCoordinate3();
|
| | pCoords->ref();
|
| |
|
| |
|
| | auto engineCat = new SoConcatenate(SoMFVec3f::getClassTypeId());
|
| | auto origin = new SoSFVec3f();
|
| | origin->setValue(0, 0, 0);
|
| | engineCat->input[0]->connectFrom(origin);
|
| | engineCat->input[1]->connectFrom(&pLabelTranslation->translation);
|
| | pCoords->point.setNum(engineCat->output->getNumConnections());
|
| | pCoords->point.connectFrom(engineCat->output);
|
| |
|
| | pLines = new SoIndexedLineSet();
|
| | pLines->ref();
|
| | pLines->coordIndex.setNum(lineCount);
|
| | pLines->coordIndex.setValues(0, lineCount, lines);
|
| |
|
| | auto lineSep = pLineSeparator;
|
| | lineSep->addChild(pCoords);
|
| | lineSep->addChild(pLines);
|
| | auto points = new SoMarkerSet();
|
| | points->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
|
| | "CROSS",
|
| | Gui::ViewParams::instance()->getMarkerSize()
|
| | );
|
| | points->numPoints = 1;
|
| | lineSep->addChild(points);
|
| |
|
| |
|
| | Gui::View3DInventor* view = nullptr;
|
| | try {
|
| | view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
|
| | }
|
| | catch (const Base::RuntimeError&) {
|
| | Base::Console().log("ViewProviderMeasure::ViewProviderMeasure: Could not get active view\n");
|
| | }
|
| |
|
| | if (view) {
|
| | Gui::View3DInventorViewer* viewer = view->getViewer();
|
| | auto renderManager = viewer->getSoRenderManager();
|
| | auto cam = renderManager->getCamera();
|
| | pDraggerOrientation->rotation.connectFrom(&cam->orientation);
|
| | }
|
| | }
|
| |
|
| | ViewProviderMeasure::~ViewProviderMeasure()
|
| | {
|
| | pCoords->unref();
|
| | pLines->unref();
|
| | }
|
| |
|
| | void ViewProviderMeasure::positionAnno(const Measure::MeasureBase* measureObject)
|
| | {
|
| | (void)measureObject;
|
| |
|
| |
|
| | Base::Vector3d textPos = getTextPosition();
|
| | auto srcVec = SbVec3f(textPos.x, textPos.y, textPos.z);
|
| |
|
| |
|
| | Gui::View3DInventor* view = nullptr;
|
| | try {
|
| | view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
|
| | }
|
| | catch (const Base::RuntimeError&) {
|
| | Base::Console().log("ViewProviderMeasure::positionAnno: Could not get active view\n");
|
| | }
|
| |
|
| | if (!view) {
|
| | return;
|
| | }
|
| |
|
| | Gui::View3DInventorViewer* viewer = view->getViewer();
|
| | auto gma = SoGetMatrixAction(viewer->getSoRenderManager()->getViewportRegion());
|
| | gma.apply(pDraggerOrientation);
|
| | auto mat = gma.getMatrix();
|
| | SbVec3f destVec(0, 0, 0);
|
| | mat.multVecMatrix(srcVec, destVec);
|
| |
|
| | setLabelTranslation(destVec);
|
| | updateView();
|
| | }
|
| |
|
| | void ViewProviderMeasure::onChanged(const App::Property* prop)
|
| | {
|
| | if (pcObject == nullptr) {
|
| | return;
|
| | }
|
| |
|
| | ViewProviderMeasureBase::onChanged(prop);
|
| | }
|
| |
|
| |
|
| |
|
| | void ViewProviderMeasure::redrawAnnotation()
|
| | {
|
| |
|
| | Base::Vector3d basePos = getBasePosition();
|
| | pcTransform->translation.setValue(SbVec3f(basePos.x, basePos.y, basePos.z));
|
| |
|
| | setLabelValue(getMeasureObject()->getResultString());
|
| |
|
| | ViewProviderMeasureBase::redrawAnnotation();
|
| | ViewProviderDocumentObject::updateView();
|
| | }
|
| |
|
| |
|
| | Base::Vector3d ViewProviderMeasure::getBasePosition()
|
| | {
|
| | auto measureObject = getMeasureObject();
|
| | Base::Placement placement = measureObject->getPlacement();
|
| | return placement.getPosition();
|
| | }
|
| |
|
| | Base::Vector3d ViewProviderMeasure::getTextPosition()
|
| | {
|
| |
|
| | auto basePoint = getBasePosition();
|
| |
|
| | Gui::View3DInventor* view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
|
| | if (!view) {
|
| | Base::Console().log("ViewProviderMeasureBase::getTextPosition: Could not get active view\n");
|
| | return Base::Vector3d();
|
| | }
|
| |
|
| | Gui::View3DInventorViewer* viewer = view->getViewer();
|
| |
|
| |
|
| | SbVec2s screenPos = viewer->getPointOnViewport(SbVec3f(basePoint.x, basePoint.y, basePoint.z));
|
| | SbVec3f vec = viewer->getPointOnFocalPlane(screenPos + SbVec2s(30.0, 30.0));
|
| | Base::Vector3d textPos(vec[0], vec[1], vec[2]);
|
| |
|
| | return textPos - basePoint;
|
| | }
|
| |
|
| |
|
| | void ViewProviderMeasureBase::show()
|
| | {
|
| | if (isSubjectVisible()) {
|
| |
|
| |
|
| | ViewProviderDocumentObject::show();
|
| | }
|
| | }
|
| |
|
| |
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasureArea, MeasureGui::ViewProviderMeasure)
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasureLength, MeasureGui::ViewProviderMeasure)
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasurePosition, MeasureGui::ViewProviderMeasure)
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasureRadius, MeasureGui::ViewProviderMeasure)
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasureDiameter, MeasureGui::ViewProviderMeasure)
|
| | PROPERTY_SOURCE(MeasureGui::ViewProviderMeasureCOM, MeasureGui::ViewProviderMeasure)
|
| |
|