TechDraw: Implement smart dimension tool.
This commit is contained in:
107
src/Mod/TechDraw/Gui/TechDrawHandler.cpp
Normal file
107
src/Mod/TechDraw/Gui/TechDrawHandler.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Pierre-Louis Boyer <development@ondsel.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cmath>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPainter>
|
||||
|
||||
#include <Inventor/events/SoKeyboardEvent.h>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
#include "MDIViewPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "TechDrawHandler.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
/**************************** TechDrawHandler *******************************************/
|
||||
|
||||
TechDrawHandler::TechDrawHandler() : Gui::ToolHandler(), viewPage(nullptr)
|
||||
{}
|
||||
|
||||
TechDrawHandler::~TechDrawHandler()
|
||||
{}
|
||||
|
||||
void TechDrawHandler::activate(QGVPage* vp)
|
||||
{
|
||||
viewPage = vp;
|
||||
|
||||
if (!Gui::ToolHandler::activate()) {
|
||||
viewPage->deactivateHandler();
|
||||
}
|
||||
}
|
||||
|
||||
void TechDrawHandler::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
// the default behaviour is to quit - specific handler categories may
|
||||
// override this behaviour, for example to implement a continuous mode
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
quit();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
bool TechDrawHandler::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
// the default behaviour is to quit - specific handler categories may
|
||||
// override this behaviour, for example to implement a continuous mode
|
||||
if (event->button() == Qt::RightButton) {
|
||||
quit();
|
||||
event->accept();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TechDrawHandler::quit()
|
||||
{
|
||||
viewPage->deactivateHandler();
|
||||
}
|
||||
|
||||
QWidget* TechDrawHandler::getCursorWidget()
|
||||
{
|
||||
return viewPage;
|
||||
}
|
||||
|
||||
void TechDrawHandler::setWidgetCursor(QCursor cursor)
|
||||
{
|
||||
if (viewPage) {
|
||||
viewPage->setCursor(cursor);
|
||||
viewPage->viewport()->setCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
TechDraw::DrawPage* TechDrawHandler::getPage()
|
||||
{
|
||||
return viewPage->getDrawPage();
|
||||
}
|
||||
Reference in New Issue
Block a user