FreeCAD

Форк
0
/
Command.cpp 
120 строк · 4.7 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
#include <Inventor/events/SoButtonEvent.h>
26
#endif
27

28
#include <App/Document.h>
29
#include <Gui/Application.h>
30
#include <Gui/BitmapFactory.h>
31
#include <Gui/Command.h>
32
#include <Gui/Document.h>
33
#include <Gui/MainWindow.h>
34
#include <Gui/View3DInventor.h>
35
#include <Gui/View3DInventorViewer.h>
36
#include <Mod/Inspection/App/InspectionFeature.h>
37

38
#include "ViewProviderInspection.h"
39
#include "VisualInspection.h"
40

41

42
DEF_STD_CMD_A(CmdVisualInspection)
43

44
CmdVisualInspection::CmdVisualInspection()
45
    : Command("Inspection_VisualInspection")
46
{
47
    sAppModule = "Inspection";
48
    sGroup = QT_TR_NOOP("Inspection");
49
    sMenuText = QT_TR_NOOP("Visual inspection...");
50
    sToolTipText = QT_TR_NOOP("Visual inspection");
51
    sStatusTip = QT_TR_NOOP("Visual inspection");
52
    sWhatsThis = "Inspection_VisualInspection";
53
}
54

55
void CmdVisualInspection::activated(int)
56
{
57
    InspectionGui::VisualInspection dlg(Gui::getMainWindow());
58
    dlg.exec();
59
}
60

61
bool CmdVisualInspection::isActive()
62
{
63
    return App::GetApplication().getActiveDocument();
64
}
65

66
//--------------------------------------------------------------------------------------
67

68
DEF_STD_CMD_A(CmdInspectElement)
69

70
CmdInspectElement::CmdInspectElement()
71
    : Command("Inspection_InspectElement")
72
{
73
    sAppModule = "Inspection";
74
    sGroup = QT_TR_NOOP("Inspection");
75
    sMenuText = QT_TR_NOOP("Inspection...");
76
    sToolTipText = QT_TR_NOOP("Get distance information");
77
    sWhatsThis = "Inspection_InspectElement";
78
    sStatusTip = sToolTipText;
79
    sPixmap = "inspect_pipette";
80
}
81

82
void CmdInspectElement::activated(int)
83
{
84
    Gui::Document* doc = Gui::Application::Instance->activeDocument();
85
    Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
86
    if (view) {
87
        Gui::View3DInventorViewer* viewer = view->getViewer();
88
        viewer->setEditing(true);
89
        viewer->setRedirectToSceneGraphEnabled(true);
90
        viewer->setRedirectToSceneGraph(true);
91
        viewer->setSelectionEnabled(false);
92
        viewer->setEditingCursor(
93
            QCursor(Gui::BitmapFactory().pixmapFromSvg("inspect_pipette", QSize(32, 32)), 4, 29));
94
        viewer->addEventCallback(SoButtonEvent::getClassTypeId(),
95
                                 InspectionGui::ViewProviderInspection::inspectCallback);
96
    }
97
}
98

99
bool CmdInspectElement::isActive()
100
{
101
    App::Document* doc = App::GetApplication().getActiveDocument();
102
    if (!doc || doc->countObjectsOfType(Inspection::Feature::getClassTypeId()) == 0) {
103
        return false;
104
    }
105

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

112
    return false;
113
}
114

115
void CreateInspectionCommands()
116
{
117
    Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
118
    rcCmdMgr.addCommand(new CmdVisualInspection());
119
    rcCmdMgr.addCommand(new CmdInspectElement());
120
}
121

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

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

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

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