mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
0027398: Integrate Qt Browser Widget to Open CASCADE Technology
The following implementation has been made: - CMake procedure is extended to compile Qt tools. This is optional and is handled by USE_QT_TOOLS option(OFF by default) - It is possible to build Qt tools using Qt5 or Qt4, it is settled with USE_QT4 option. - Sample of DFBrowser tool is available in samples/tools/TInspectorEXE. It is build with tools, executable is placed in binaries. To start the sample, use dfbrowser.bat command. - DFBrowser tool may be started from DRAW
This commit is contained in:
134
tools/View/View_Window.cxx
Normal file
134
tools/View/View_Window.cxx
Normal file
@@ -0,0 +1,134 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#if !defined _WIN32
|
||||
#define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */
|
||||
#endif
|
||||
|
||||
#include <View_Window.hxx>
|
||||
|
||||
#include <View_Displayer.hxx>
|
||||
#include <View_ToolBar.hxx>
|
||||
#include <View_Viewer.hxx>
|
||||
#include <View_Widget.hxx>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDockWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QToolBar>
|
||||
|
||||
const int DEFAULT_SPACING = 3;
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
View_Window::View_Window (QWidget* theParent)
|
||||
: QWidget (theParent)
|
||||
{
|
||||
QGridLayout* aViewLayout = new QGridLayout (this);
|
||||
aViewLayout->setContentsMargins (0, 0, 0, 0);
|
||||
aViewLayout->setSpacing (DEFAULT_SPACING);
|
||||
|
||||
myView = new View_Widget (this);
|
||||
myViewToolBar = new View_ToolBar (this);
|
||||
aViewLayout->addWidget (myViewToolBar->GetControl(), 0, 0, 1, 2);
|
||||
connect (myViewToolBar, SIGNAL (contextChanged()), this, SLOT (onViewSelectorActivated()));
|
||||
connect (myViewToolBar, SIGNAL (actionClicked (int)),
|
||||
this, SLOT (onToolBarActionClicked (int)));
|
||||
|
||||
myActionsToolBar = new QToolBar (this);
|
||||
myActionsToolBar->layout()->setContentsMargins (0, 0, 0, 0);
|
||||
myActionsToolBar->setOrientation (Qt::Vertical);
|
||||
|
||||
for (int anActionId = View_ViewActionType_FitAllId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
|
||||
myActionsToolBar->addAction (myView->GetViewAction ((View_ViewActionType)anActionId));
|
||||
aViewLayout->addWidget (myActionsToolBar, 1, 0);
|
||||
aViewLayout->addWidget (myView, 1, 1);
|
||||
aViewLayout->setRowStretch (1, 1);
|
||||
|
||||
Handle(AIS_InteractiveContext) aContext = myView->GetViewer()->GetContext();
|
||||
myViewToolBar->SetContext (View_ContextType_Own, aContext);
|
||||
|
||||
myDisplayer = new View_Displayer();
|
||||
connect (myView, SIGNAL (displayModeClicked()), this, SLOT (onDisplayModeChanged()));
|
||||
onViewSelectorActivated();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetContext
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_InteractiveContext)& theContext)
|
||||
{
|
||||
GetViewToolBar()->SetContext (View_ContextType_External, theContext);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onViewSelectorActivated
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Window::onViewSelectorActivated()
|
||||
{
|
||||
View_ContextType aType = myViewToolBar->GetCurrentContextType();
|
||||
bool isViewEnabled = aType == View_ContextType_Own;
|
||||
|
||||
myView->SetEnabledView (isViewEnabled);
|
||||
|
||||
Handle(AIS_InteractiveContext) aContext = myViewToolBar->GetCurrentContext();
|
||||
myDisplayer->EraseAllPresentations (true);
|
||||
myDisplayer->SetContext (aContext);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onToolBarActionClicked
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Window::onToolBarActionClicked (const int theActionId)
|
||||
{
|
||||
switch (theActionId)
|
||||
{
|
||||
case View_ToolActionType_KeepViewId:
|
||||
{
|
||||
myDisplayer->KeepPresentations (myViewToolBar->IsActionChecked (theActionId));
|
||||
break;
|
||||
}
|
||||
case View_ToolActionType_KeepViewOffId:
|
||||
{
|
||||
myDisplayer->KeepPresentations (!myViewToolBar->IsActionChecked (theActionId));
|
||||
break;
|
||||
}
|
||||
case View_ToolActionType_ClearViewId:
|
||||
{
|
||||
myDisplayer->EraseAllPresentations (true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onDisplayModeChanged
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Window::onDisplayModeChanged()
|
||||
{
|
||||
int aDisplayMode = myView->GetDisplayMode();
|
||||
for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator
|
||||
anIterator(myDisplayer->GetDisplayed()); anIterator.More(); anIterator.Next())
|
||||
myDisplayer->SetDisplayMode (aDisplayMode, anIterator.Key(), false);
|
||||
myDisplayer->UpdateViewer();
|
||||
}
|
Reference in New Issue
Block a user