FreeCAD

Форк
0
/
Command.cpp 
85 строк · 3.3 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2023 David Friedli <david[at]friedli-be.ch>             *
3
 *                                                                         *
4
 *   This file is part of FreeCAD.                                         *
5
 *                                                                         *
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.                       *
10
 *                                                                         *
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.                       *
15
 *                                                                         *
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/>.                                      *
19
 *                                                                         *
20
 **************************************************************************/
21

22
#include "PreCompiled.h"
23

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>
32

33
#include "TaskMeasure.h"
34

35

36
//===========================================================================
37
// Std_Measure
38
// this is the Unified Measurement Facility Measure command
39
//===========================================================================
40

41

42
DEF_STD_CMD_A(StdCmdMeasure)
43

44
StdCmdMeasure::StdCmdMeasure()
45
    : Command("Std_Measure")
46
{
47
    sGroup = "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";
53
}
54

55
void StdCmdMeasure::activated(int iMsg)
56
{
57
    Q_UNUSED(iMsg);
58

59
    Gui::TaskMeasure* task = new Gui::TaskMeasure();
60
    Gui::Control().showDialog(task);
61
}
62

63
bool StdCmdMeasure::isActive()
64
{
65
    App::Document* doc = App::GetApplication().getActiveDocument();
66
    if (!doc || doc->countObjectsOfType(App::GeoFeature::getClassTypeId()) == 0) {
67
        return false;
68
    }
69

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();
74
    }
75
    return false;
76
}
77

78
void CreateMeasureCommands()
79
{
80
    Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
81

82
    auto cmd = new StdCmdMeasure();
83
    cmd->initAction();
84
    rcCmdMgr.addCommand(cmd);
85
}
86

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.