1
/***************************************************************************
2
* Copyright (c) 2023 David Friedli <david[at]friedli-be.ch> *
4
* This file is part of FreeCAD. *
6
* FreeCAD is free software: you can redistribute it and/or modify it *
7
* under the terms of the GNU Lesser General Public License as *
8
* published by the Free Software Foundation, either version 2.1 of the *
9
* License, or (at your option) any later version. *
11
* FreeCAD is distributed in the hope that it will be useful, but *
12
* WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14
* Lesser General Public License for more details. *
16
* You should have received a copy of the GNU Lesser General Public *
17
* License along with FreeCAD. If not, see *
18
* <https://www.gnu.org/licenses/>. *
20
**************************************************************************/
22
#include "PreCompiled.h"
24
#include <App/Document.h>
25
#include <Gui/Application.h>
26
#include <Gui/Command.h>
27
#include <Gui/Control.h>
28
#include <Gui/MainWindow.h>
29
#include <Gui/MDIView.h>
30
#include <Gui/View3DInventor.h>
31
#include <Gui/View3DInventorViewer.h>
33
#include "TaskMeasure.h"
36
//===========================================================================
38
// this is the Unified Measurement Facility Measure command
39
//===========================================================================
42
DEF_STD_CMD_A(StdCmdMeasure)
44
StdCmdMeasure::StdCmdMeasure()
45
: Command("Std_Measure")
48
sMenuText = QT_TR_NOOP("&Measure");
49
sToolTipText = QT_TR_NOOP("Measure a feature");
50
sWhatsThis = "Std_Measure";
51
sStatusTip = QT_TR_NOOP("Measure a feature");
52
sPixmap = "umf-measurement";
55
void StdCmdMeasure::activated(int iMsg)
59
Gui::TaskMeasure* task = new Gui::TaskMeasure();
60
Gui::Control().showDialog(task);
63
bool StdCmdMeasure::isActive()
65
App::Document* doc = App::GetApplication().getActiveDocument();
66
if (!doc || doc->countObjectsOfType(App::GeoFeature::getClassTypeId()) == 0) {
70
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
71
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
72
Gui::View3DInventorViewer* viewer = dynamic_cast<Gui::View3DInventor*>(view)->getViewer();
73
return !viewer->isEditing();
78
void CreateMeasureCommands()
80
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
82
auto cmd = new StdCmdMeasure();
84
rcCmdMgr.addCommand(cmd);