Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Std_MeasureDistance into unified measurement facility #13810

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/App/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
#include "LinkBaseExtensionPy.h"
#include "VarSet.h"
#include "MaterialObject.h"
#include "MeasureDistance.h"
#include "MeasureManagerPy.h"
#include "Origin.h"
#include "OriginFeature.h"
Expand All @@ -129,7 +128,7 @@
// If you stumble here, run the target "BuildExtractRevision" on Windows systems
// or the Python script "SubWCRev.py" on Linux based systems which builds
// src/Build/Version.h. Or create your own from src/Build/Version.h.in!
#include <Build/Version.h>

Check failure on line 131 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

'Build/Version.h' file not found [clang-diagnostic-error]
#include "Branding.h"


Expand All @@ -150,7 +149,7 @@
# include <new>
#endif

FC_LOG_LEVEL_INIT("App", true, true)

Check warning on line 152 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable '_s_fclvl' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

using namespace App;
using namespace Base;
Expand All @@ -164,12 +163,12 @@
// Application
//==========================================================================

Base::Reference<ParameterManager> App::Application::_pcSysParamMngr;

Check warning on line 166 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable '_pcSysParamMngr' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
Base::Reference<ParameterManager> App::Application::_pcUserParamMngr;

Check warning on line 167 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable '_pcUserParamMngr' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
Base::ConsoleObserverStd *Application::_pConsoleObserverStd = nullptr;

Check warning on line 168 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable '_pConsoleObserverStd' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

Check warning on line 168 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable '_pConsoleObserverStd' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
Base::ConsoleObserverFile *Application::_pConsoleObserverFile = nullptr;

Check warning on line 169 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable '_pConsoleObserverFile' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

Check warning on line 169 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable '_pConsoleObserverFile' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]

AppExport std::map<std::string, std::string> Application::mConfig;

Check warning on line 171 in src/App/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable 'mConfig' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]


//**************************************************************************
Expand Down Expand Up @@ -2105,7 +2104,6 @@
App::VRMLObject ::init();
App::Annotation ::init();
App::AnnotationLabel ::init();
App::MeasureDistance ::init();
App::MaterialObject ::init();
App::MaterialObjectPython ::init();
App::TextDocument ::init();
Expand Down
2 changes: 0 additions & 2 deletions src/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ SET(Document_CPP_SRCS
Origin.cpp
Path.cpp
InventorObject.cpp
MeasureDistance.cpp
Placement.cpp
ProjectFile.cpp
OriginFeature.cpp
Expand Down Expand Up @@ -212,7 +211,6 @@ SET(Document_HPP_SRCS
Origin.h
Path.h
InventorObject.h
MeasureDistance.h
Placement.h
ProjectFile.h
OriginFeature.h
Expand Down
59 changes: 0 additions & 59 deletions src/App/MeasureDistance.cpp

This file was deleted.

63 changes: 0 additions & 63 deletions src/App/MeasureDistance.h

This file was deleted.

3 changes: 0 additions & 3 deletions src/Gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#include "ExpressionBindingPy.h"
#include "FileDialog.h"
#include "GuiApplication.h"
#include "GuiInitScript.h"

Check failure on line 75 in src/Gui/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

'GuiInitScript.h' file not found [clang-diagnostic-error]
#include "LinkViewPy.h"
#include "MainWindow.h"
#include "Macro.h"
Expand Down Expand Up @@ -113,7 +113,6 @@
#include "ViewProviderLink.h"
#include "ViewProviderLinkPy.h"
#include "ViewProviderMaterialObject.h"
#include "ViewProviderMeasureDistance.h"
#include "ViewProviderOrigin.h"
#include "ViewProviderOriginFeature.h"
#include "ViewProviderOriginGroup.h"
Expand Down Expand Up @@ -1908,8 +1907,6 @@
Gui::ViewProviderVRMLObject ::init();
Gui::ViewProviderAnnotation ::init();
Gui::ViewProviderAnnotationLabel ::init();
Gui::ViewProviderPointMarker ::init();
Gui::ViewProviderMeasureDistance ::init();
Gui::ViewProviderPythonFeature ::init();
Gui::ViewProviderPythonGeometry ::init();
Gui::ViewProviderPlacement ::init();
Expand Down Expand Up @@ -2123,7 +2120,7 @@
Instance->d->startingUp = false;

// gets called once we start the event loop
QTimer::singleShot(0, &mw, SLOT(delayedStartup()));

Check warning on line 2123 in src/Gui/Application.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

QTimer::singleShot(0, &mw, SLOT(delayedStartup())); <--Consider using Functor-Based Connections

// run the Application event loop
Base::Console().Log("Init: Entering event loop\n");
Expand Down
2 changes: 0 additions & 2 deletions src/Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ SET(Viewprovider_CPP_SRCS
ViewProviderGeometryObject.cpp
ViewProviderImagePlane.cpp
ViewProviderInventorObject.cpp
ViewProviderMeasureDistance.cpp
ViewProviderPyImp.cpp
ViewProviderPythonFeature.cpp
ViewProviderVRMLObject.cpp
Expand Down Expand Up @@ -964,7 +963,6 @@ SET(Viewprovider_SRCS
ViewProviderGeometryObject.h
ViewProviderImagePlane.h
ViewProviderInventorObject.h
ViewProviderMeasureDistance.h
ViewProviderPythonFeature.h
ViewProviderVRMLObject.h
ViewProviderBuilder.h
Expand Down
59 changes: 0 additions & 59 deletions src/Gui/CommandStd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,64 +732,6 @@ void StdCmdReportBug::activated(int iMsg)
OpenURLInBrowser(url.c_str());
}


//===========================================================================
// Std_MeasurementSimple
//===========================================================================

DEF_STD_CMD(StdCmdMeasurementSimple)

StdCmdMeasurementSimple::StdCmdMeasurementSimple()
:Command("Std_MeasurementSimple")
{
sGroup = "Tools";
sMenuText = QT_TR_NOOP("Measure distance");
sToolTipText = QT_TR_NOOP("Measures distance between two selected objects");
sWhatsThis = "Std_MeasurementSimple";
sStatusTip = QT_TR_NOOP("Measures distance between two selected objects");
sPixmap = "view-measurement";
eType = 0;
}

void StdCmdMeasurementSimple::activated(int iMsg)
{
Q_UNUSED(iMsg);
unsigned int n = getSelection().countObjectsOfType(App::DocumentObject::getClassTypeId());

if (n == 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Only one object selected. Please select two objects.\n"
"Be aware the point where you click matters."));
return;
}
if (n < 1 || n > 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Please select two objects.\n"
"Be aware the point where you click matters."));
return;
}

std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();

std::string name;
name += "Dist ";
name += Sel[0].FeatName;
name += "-";
name += Sel[0].SubName;
name += " to ";
name += Sel[1].FeatName;
name += "-";
name += Sel[1].SubName;

openCommand(QT_TRANSLATE_NOOP("Command", "Insert measurement"));
doCommand(Doc,"_f = App.activeDocument().addObject(\"App::MeasureDistance\",\"%s\")","Measurement");
doCommand(Doc,"_f.Label ='%s'",name.c_str());
doCommand(Doc,"_f.P1 = FreeCAD.Vector(%f,%f,%f)",Sel[0].x,Sel[0].y,Sel[0].z);
doCommand(Doc,"_f.P2 = FreeCAD.Vector(%f,%f,%f)",Sel[1].x,Sel[1].y,Sel[1].z);
updateActive();
commitCommand();
}

//===========================================================================
// Std_TextDocument
//===========================================================================
Expand Down Expand Up @@ -1011,7 +953,6 @@ void CreateStdCommands()
rcCmdMgr.addCommand(new StdCmdUnitsCalculator());
rcCmdMgr.addCommand(new StdCmdUserEditMode());
rcCmdMgr.addCommand(new StdCmdReloadStyleSheet());
//rcCmdMgr.addCommand(new StdCmdMeasurementSimple());
//rcCmdMgr.addCommand(new StdCmdDownloadOnlineHelp());
//rcCmdMgr.addCommand(new StdCmdDescription());
}
Expand Down
59 changes: 0 additions & 59 deletions src/Gui/CommandView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include <App/GeoFeatureGroupExtension.h>
#include <App/Part.h>
#include <App/Link.h>
#include <App/MeasureDistance.h>
#include <Base/Console.h>
#include <Base/Parameter.h>

Expand Down Expand Up @@ -85,7 +84,6 @@
#include "View3DInventor.h"
#include "View3DInventorViewer.h"
#include "ViewParams.h"
#include "ViewProviderMeasureDistance.h"
#include "ViewProviderGeometryObject.h"
#include "WaitCursor.h"

Expand Down Expand Up @@ -2708,7 +2706,7 @@
};
}

std::unique_ptr<SelectionCallbackHandler> SelectionCallbackHandler::currentSelectionHandler = std::unique_ptr<SelectionCallbackHandler>();

Check warning on line 2709 in src/Gui/CommandView.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

non-POD static (unique_ptr) [-Wclazy-non-pod-global-static]
//===========================================================================
// Std_ViewBoxZoom
//===========================================================================
Expand Down Expand Up @@ -3139,62 +3137,6 @@
Selection().selStackPush();
}

//===========================================================================
// Std_MeasureDistance
//===========================================================================

DEF_STD_CMD_A(StdCmdMeasureDistance)

StdCmdMeasureDistance::StdCmdMeasureDistance()
: Command("Std_MeasureDistance")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Measure distance");
sToolTipText = QT_TR_NOOP("Activate the distance measurement tool");
sWhatsThis = "Std_MeasureDistance";
sStatusTip = QT_TR_NOOP("Activate the distance measurement tool");
sPixmap = "view-measurement";
eType = Alter3DView;
}

void StdCmdMeasureDistance::activated(int iMsg)
{
Q_UNUSED(iMsg);
Gui::Document* doc = Gui::Application::Instance->activeDocument();
auto view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);

// NOLINTBEGIN
QCursor cursor = SelectionCallbackHandler::makeCursor(viewer, QSize(32, 32),
"view-measurement-cross", 6, 25);
viewer->setEditingCursor(cursor);
// NOLINTEND

// Derives from QObject and we have a parent object, so we don't
// require a delete.
auto marker = new PointMarker(viewer);
viewer->addEventCallback(SoEvent::getClassTypeId(),
ViewProviderMeasureDistance::measureDistanceCallback, marker);
}
}

bool StdCmdMeasureDistance::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(App::GeoFeature::getClassTypeId()) == 0)
return false;

Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
return !viewer->isEditing();
}

return false;
}

//===========================================================================
// Std_Measure
// this is the Unified Measurement Facility Measure command
Expand Down Expand Up @@ -4124,7 +4066,6 @@
rcCmdMgr.addCommand(new StdCmdTreeExpand());
rcCmdMgr.addCommand(new StdCmdTreeCollapse());
rcCmdMgr.addCommand(new StdCmdTreeSelectAllInstances());
rcCmdMgr.addCommand(new StdCmdMeasureDistance());
rcCmdMgr.addCommand(new StdCmdMeasure());
rcCmdMgr.addCommand(new StdCmdSceneInspector());
rcCmdMgr.addCommand(new StdCmdTextureMapping());
Expand Down