1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00
occt/samples/qt/Tutorial/src/ApplicationTut.cxx
nds 55a40de890 0028934: Coding - Eliminate compiler warnings in OCCT samples
- covering Qt warnings for compilation under MSVC 2013 and greater
- avoid warning about 'M_PI'(and others) redefinition warning of math.h: includes of QtWidgets should follow after other includes.
2018-04-09 10:18:38 +03:00

71 lines
2.0 KiB
C++
Executable File

#include "ApplicationTut.h"
#include "DocumentTut.h"
#include <OSD_Environment.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QFileDialog>
#include <QStatusBar>
#include <QMdiSubWindow>
#include <Standard_WarningsRestore.hxx>
ApplicationTut::ApplicationTut()
: ApplicationCommonWindow( )
{
createMakeBottleOperation();
}
ApplicationTut::~ApplicationTut()
{
}
void ApplicationTut::createMakeBottleOperation(){
QPixmap MakeBottleIcon;
QString dir = getTutResourceDir() + QString( "/" );
MakeBottleIcon = QPixmap( dir+QObject::tr( "ICON_MAKE_BOTTLE" ) );
QAction * MakeBottleAction = new QAction( MakeBottleIcon, QObject::tr("TBR_MAKEBOT"), this );
MakeBottleAction->setToolTip( QObject::tr( "TBR_MAKEBOT" ) );
MakeBottleAction->setStatusTip( QObject::tr("TBR_MAKEBOT") );
MakeBottleAction->setShortcut( QObject::tr( "CTRL+M" ) );
connect( MakeBottleAction, SIGNAL( triggered() ) , this, SLOT( onMakeBottleAction() ) );
myMakeBottleBar = addToolBar( tr( "Make Bottle" ) );
insertToolBar( getCasCadeBar(), myMakeBottleBar );
myMakeBottleBar->addAction( MakeBottleAction );
myMakeBottleBar->hide();
}
void ApplicationTut::updateFileActions()
{
if ( getWorkspace()->subWindowList().isEmpty() )
{
if ( !isDocument() )
{
myMakeBottleBar->show();
}
else
{
myMakeBottleBar->hide();
}
}
ApplicationCommonWindow::updateFileActions();
}
void ApplicationTut::onMakeBottleAction()
{
QMdiArea* ws = ApplicationCommonWindow::getWorkspace();
DocumentTut* doc = (DocumentTut*)( qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() )->getDocument() );
statusBar()->showMessage( QObject::tr("INF_MAKE_BOTTLE"), 5000 );
doc->onMakeBottle();
statusBar()->showMessage(QObject::tr("INF_DONE"));
}
QString ApplicationTut::getTutResourceDir()
{
static QString resDir (OSD_Environment ("CSF_TutorialResourcesDefaults").Value().ToCString());
if (resDir.isEmpty())
resDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples";
return resDir;
}