mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Coding - Apply .clang-format formatting #286
Update empty method guards to new style with regex (see PR). Used clang-format 18.1.8. New actions to validate code formatting is added. Update .clang-format with disabling of include sorting. It is temporary changes, then include will be sorted. Apply formatting for /src and /tools folder. The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
@@ -11,10 +11,10 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#if !defined _WIN32
|
||||
#define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */
|
||||
#define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */
|
||||
#endif
|
||||
|
||||
#include <inspector/View_Widget.hxx>
|
||||
@@ -58,43 +58,49 @@
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
View_Widget::View_Widget (QWidget* theParent,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const bool isFitAllActive)
|
||||
: QWidget (theParent), myFirst (true), myDefaultWidth (-1),
|
||||
myDefaultHeight (-1), myViewIsEnabled (true),
|
||||
myHasInitProj (Standard_False), myInitVx (0), myInitVy (0), myInitVz (0)
|
||||
View_Widget::View_Widget(QWidget* theParent,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const bool isFitAllActive)
|
||||
: QWidget(theParent),
|
||||
myFirst(true),
|
||||
myDefaultWidth(-1),
|
||||
myDefaultHeight(-1),
|
||||
myViewIsEnabled(true),
|
||||
myHasInitProj(Standard_False),
|
||||
myInitVx(0),
|
||||
myInitVy(0),
|
||||
myInitVz(0)
|
||||
{
|
||||
myViewer = new View_Viewer (View_Viewer::DefaultColor());
|
||||
myViewer = new View_Viewer(View_Viewer::DefaultColor());
|
||||
if (!theContext.IsNull())
|
||||
{
|
||||
myViewer->InitViewer (theContext);
|
||||
myViewer->InitViewer(theContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
myViewer->InitViewer (myViewer->CreateStandardViewer());
|
||||
myViewer->InitViewer(myViewer->CreateStandardViewer());
|
||||
}
|
||||
myController = new AIS_ViewController();
|
||||
|
||||
setAttribute (Qt::WA_PaintOnScreen);
|
||||
setAttribute (Qt::WA_NoSystemBackground);
|
||||
setAttribute(Qt::WA_PaintOnScreen);
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
|
||||
setMouseTracking (true);
|
||||
setBackgroundRole (QPalette::NoRole);
|
||||
// set focus policy to threat QContextMenuEvent from keyboard
|
||||
setFocusPolicy (Qt::StrongFocus);
|
||||
setMouseTracking(true);
|
||||
setBackgroundRole(QPalette::NoRole);
|
||||
// set focus policy to threat QContextMenuEvent from keyboard
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
initViewActions();
|
||||
((View_ToolButton*)myFitAllAction)->SetButtonChecked (isFitAllActive);
|
||||
((View_ToolButton*)myFitAllAction)->SetButtonChecked(isFitAllActive);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPredefinedSize
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::SetPredefinedSize (int theDefaultWidth, int theDefaultHeight)
|
||||
void View_Widget::SetPredefinedSize(int theDefaultWidth, int theDefaultHeight)
|
||||
{
|
||||
myDefaultWidth = theDefaultWidth;
|
||||
myDefaultWidth = theDefaultWidth;
|
||||
myDefaultHeight = theDefaultHeight;
|
||||
}
|
||||
|
||||
@@ -107,25 +113,26 @@ void View_Widget::Init()
|
||||
myViewer->CreateView();
|
||||
|
||||
#ifdef _WIN32
|
||||
Aspect_Handle aWindowHandle = (Aspect_Handle)winId();
|
||||
Handle(Aspect_Window) aWnd = new WNT_Window (aWindowHandle);
|
||||
#elif defined (HAVE_XLIB)
|
||||
Aspect_Drawable aWindowHandle = (Aspect_Drawable )winId();
|
||||
Handle(Aspect_DisplayConnection) aDispConnection = myViewer->GetContext()->CurrentViewer()->Driver()->GetDisplayConnection();
|
||||
Handle(Aspect_Window) aWnd = new Xw_Window (aDispConnection, aWindowHandle);
|
||||
#elif defined (__APPLE__)
|
||||
NSView* aViewHandle = (NSView*)winId();
|
||||
Handle(Aspect_Window) aWnd = new Cocoa_Window (aViewHandle);
|
||||
Aspect_Handle aWindowHandle = (Aspect_Handle)winId();
|
||||
Handle(Aspect_Window) aWnd = new WNT_Window(aWindowHandle);
|
||||
#elif defined(HAVE_XLIB)
|
||||
Aspect_Drawable aWindowHandle = (Aspect_Drawable)winId();
|
||||
Handle(Aspect_DisplayConnection) aDispConnection =
|
||||
myViewer->GetContext()->CurrentViewer()->Driver()->GetDisplayConnection();
|
||||
Handle(Aspect_Window) aWnd = new Xw_Window(aDispConnection, aWindowHandle);
|
||||
#elif defined(__APPLE__)
|
||||
NSView* aViewHandle = (NSView*)winId();
|
||||
Handle(Aspect_Window) aWnd = new Cocoa_Window(aViewHandle);
|
||||
#else
|
||||
//
|
||||
#endif
|
||||
myViewer->SetWindow (aWnd);
|
||||
myViewer->SetWindow(aWnd);
|
||||
|
||||
myViewer->GetView()->SetBackgroundColor (View_Viewer::DefaultColor());
|
||||
myViewer->GetView()->SetBackgroundColor(View_Viewer::DefaultColor());
|
||||
myViewer->GetView()->MustBeResized();
|
||||
|
||||
if (myHasInitProj)
|
||||
myViewer->GetView()->SetProj (myInitVx, myInitVy, myInitVz);
|
||||
myViewer->GetView()->SetProj(myInitVx, myInitVy, myInitVz);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -141,16 +148,17 @@ int View_Widget::DisplayMode() const
|
||||
// function : SetDisplayMode
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::SetDisplayMode (const int theMode)
|
||||
void View_Widget::SetDisplayMode(const int theMode)
|
||||
{
|
||||
myViewActions[View_ViewActionType_DisplayModeId]->setChecked ( theMode ? AIS_Shaded : AIS_WireFrame);
|
||||
myViewActions[View_ViewActionType_DisplayModeId]->setChecked(theMode ? AIS_Shaded
|
||||
: AIS_WireFrame);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : paintEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::paintEvent (QPaintEvent* /*theEvent*/)
|
||||
void View_Widget::paintEvent(QPaintEvent* /*theEvent*/)
|
||||
{
|
||||
#if (QT_VERSION < 0x050000 || QT_VERSION >= 0x050700)
|
||||
if (myFirst)
|
||||
@@ -168,7 +176,7 @@ void View_Widget::paintEvent (QPaintEvent* /*theEvent*/)
|
||||
// function : resizeEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::resizeEvent (QResizeEvent* /*theEvent*/)
|
||||
void View_Widget::resizeEvent(QResizeEvent* /*theEvent*/)
|
||||
{
|
||||
#if (QT_VERSION > 0x050000 && QT_VERSION < 0x050700)
|
||||
if (myFirst)
|
||||
@@ -188,7 +196,7 @@ void View_Widget::resizeEvent (QResizeEvent* /*theEvent*/)
|
||||
QSize View_Widget::sizeHint() const
|
||||
{
|
||||
if (myDefaultWidth > 0 && myDefaultHeight > 0)
|
||||
return QSize (myDefaultWidth, myDefaultHeight);
|
||||
return QSize(myDefaultWidth, myDefaultHeight);
|
||||
|
||||
return QWidget::sizeHint();
|
||||
}
|
||||
@@ -197,43 +205,44 @@ QSize View_Widget::sizeHint() const
|
||||
// function : SetEnabledView
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::SetEnabledView (const bool theIsEnabled)
|
||||
void View_Widget::SetEnabledView(const bool theIsEnabled)
|
||||
{
|
||||
myViewIsEnabled = theIsEnabled;
|
||||
|
||||
if (myViewer->GetView())
|
||||
myViewer->GetView()->SetBackgroundColor (theIsEnabled ? View_Viewer::DefaultColor()
|
||||
: View_Viewer::DisabledColor());
|
||||
ViewAction (View_ViewActionType_DisplayModeId)->setEnabled (theIsEnabled);
|
||||
myViewer->GetView()->SetBackgroundColor(theIsEnabled ? View_Viewer::DefaultColor()
|
||||
: View_Viewer::DisabledColor());
|
||||
ViewAction(View_ViewActionType_DisplayModeId)->setEnabled(theIsEnabled);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SaveState
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::SaveState (View_Widget* theWidget,
|
||||
QMap<QString, QString>& theItems,
|
||||
const QString& thePrefix)
|
||||
void View_Widget::SaveState(View_Widget* theWidget,
|
||||
QMap<QString, QString>& theItems,
|
||||
const QString& thePrefix)
|
||||
{
|
||||
theItems[thePrefix + "fitall"] = theWidget->ViewAction (View_ViewActionType_FitAllId)->isChecked();
|
||||
theItems[thePrefix + "dispmode"] = QString::number (theWidget->DisplayMode());
|
||||
theItems[thePrefix + "fitall"] = theWidget->ViewAction(View_ViewActionType_FitAllId)->isChecked();
|
||||
theItems[thePrefix + "dispmode"] = QString::number(theWidget->DisplayMode());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : RestoreState
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool View_Widget::RestoreState (View_Widget* theWidget,
|
||||
const QString& theKey, const QString& theValue,
|
||||
const QString& thePrefix)
|
||||
bool View_Widget::RestoreState(View_Widget* theWidget,
|
||||
const QString& theKey,
|
||||
const QString& theValue,
|
||||
const QString& thePrefix)
|
||||
{
|
||||
if (theKey == thePrefix + "fitall")
|
||||
{
|
||||
theWidget->SetActionChecked (View_ViewActionType_FitAllId, theValue.toInt() > 0);
|
||||
theWidget->SetActionChecked(View_ViewActionType_FitAllId, theValue.toInt() > 0);
|
||||
}
|
||||
else if (theKey == thePrefix + "dispmode")
|
||||
{
|
||||
theWidget->SetDisplayMode (theValue.toInt());
|
||||
theWidget->SetDisplayMode(theValue.toInt());
|
||||
}
|
||||
else
|
||||
return false;
|
||||
@@ -245,7 +254,7 @@ bool View_Widget::RestoreState (View_Widget* theWidget,
|
||||
// function : onCheckedStateChanged
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::onCheckedStateChanged (bool isOn)
|
||||
void View_Widget::onCheckedStateChanged(bool isOn)
|
||||
{
|
||||
QWidget* aSentByAction = (QWidget*)sender();
|
||||
|
||||
@@ -262,27 +271,36 @@ void View_Widget::initViewActions()
|
||||
if (!myViewActions.empty())
|
||||
return;
|
||||
|
||||
myFitAllAction = new View_ToolButton (this); // action for automatic fit all
|
||||
connect (myFitAllAction, SIGNAL (checkedStateChanged(bool)), this, SLOT (onCheckedStateChanged(bool)));
|
||||
createAction (View_ViewActionType_FitAllId, ":/icons/view_fitall.png", tr ("Fit All"), SLOT (OnFitAll()));
|
||||
myFitAllAction->setDefaultAction (ViewAction (View_ViewActionType_FitAllId));
|
||||
myFitAllAction = new View_ToolButton(this); // action for automatic fit all
|
||||
connect(myFitAllAction,
|
||||
SIGNAL(checkedStateChanged(bool)),
|
||||
this,
|
||||
SLOT(onCheckedStateChanged(bool)));
|
||||
createAction(View_ViewActionType_FitAllId,
|
||||
":/icons/view_fitall.png",
|
||||
tr("Fit All"),
|
||||
SLOT(OnFitAll()));
|
||||
myFitAllAction->setDefaultAction(ViewAction(View_ViewActionType_FitAllId));
|
||||
|
||||
createAction (View_ViewActionType_DisplayModeId, ":/icons/view_dm_shading.png", tr ("Display Mode"),
|
||||
SIGNAL (displayModeClicked()), true);
|
||||
createAction(View_ViewActionType_DisplayModeId,
|
||||
":/icons/view_dm_shading.png",
|
||||
tr("Display Mode"),
|
||||
SIGNAL(displayModeClicked()),
|
||||
true);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : mousePressEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::mousePressEvent (QMouseEvent* theEvent)
|
||||
void View_Widget::mousePressEvent(QMouseEvent* theEvent)
|
||||
{
|
||||
if (myController->PressMouseButton (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
|
||||
keyMouse (theEvent->button()),
|
||||
keyFlag (theEvent->modifiers()),
|
||||
Standard_False))
|
||||
if (myController->PressMouseButton(Graphic3d_Vec2i(theEvent->x(), theEvent->y()),
|
||||
keyMouse(theEvent->button()),
|
||||
keyFlag(theEvent->modifiers()),
|
||||
Standard_False))
|
||||
{
|
||||
myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
myController->FlushViewEvents(myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,14 +308,14 @@ void View_Widget::mousePressEvent (QMouseEvent* theEvent)
|
||||
// function : mouseReleaseEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::mouseReleaseEvent (QMouseEvent* theEvent)
|
||||
void View_Widget::mouseReleaseEvent(QMouseEvent* theEvent)
|
||||
{
|
||||
if (myController->ReleaseMouseButton (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
|
||||
keyMouse (theEvent->button()),
|
||||
keyFlag (theEvent->modifiers()),
|
||||
Standard_False))
|
||||
if (myController->ReleaseMouseButton(Graphic3d_Vec2i(theEvent->x(), theEvent->y()),
|
||||
keyMouse(theEvent->button()),
|
||||
keyFlag(theEvent->modifiers()),
|
||||
Standard_False))
|
||||
{
|
||||
myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
myController->FlushViewEvents(myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,34 +323,39 @@ void View_Widget::mouseReleaseEvent (QMouseEvent* theEvent)
|
||||
// function : mouseMoveEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::mouseMoveEvent (QMouseEvent* theEvent)
|
||||
void View_Widget::mouseMoveEvent(QMouseEvent* theEvent)
|
||||
{
|
||||
if (myViewer->GetView().IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myController->UpdateMousePosition (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
|
||||
keyMouse (theEvent->button()),
|
||||
keyFlag (theEvent->modifiers()), Standard_False);
|
||||
myController->UpdateMousePosition(Graphic3d_Vec2i(theEvent->x(), theEvent->y()),
|
||||
keyMouse(theEvent->button()),
|
||||
keyFlag(theEvent->modifiers()),
|
||||
Standard_False);
|
||||
|
||||
myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
myController->FlushViewEvents(myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createAction
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::createAction (const View_ViewActionType theActionId, const QString& theIcon, const QString& theText,
|
||||
const char* theSlot, const bool isCheckable, const QString& theToolBar,
|
||||
const QString& theStatusBar)
|
||||
void View_Widget::createAction(const View_ViewActionType theActionId,
|
||||
const QString& theIcon,
|
||||
const QString& theText,
|
||||
const char* theSlot,
|
||||
const bool isCheckable,
|
||||
const QString& theToolBar,
|
||||
const QString& theStatusBar)
|
||||
{
|
||||
QAction* anAction = new QAction (QIcon (theIcon), theText, this);
|
||||
anAction->setToolTip (!theToolBar.isEmpty() ? theToolBar : theText);
|
||||
anAction->setStatusTip (!theStatusBar.isEmpty() ? theStatusBar : theText);
|
||||
QAction* anAction = new QAction(QIcon(theIcon), theText, this);
|
||||
anAction->setToolTip(!theToolBar.isEmpty() ? theToolBar : theText);
|
||||
anAction->setStatusTip(!theStatusBar.isEmpty() ? theStatusBar : theText);
|
||||
if (isCheckable)
|
||||
anAction->setCheckable (true);
|
||||
connect(anAction, SIGNAL (triggered()) , this, theSlot);
|
||||
anAction->setCheckable(true);
|
||||
connect(anAction, SIGNAL(triggered()), this, theSlot);
|
||||
myViewActions[theActionId] = anAction;
|
||||
}
|
||||
|
||||
@@ -340,14 +363,18 @@ void View_Widget::createAction (const View_ViewActionType theActionId, const QSt
|
||||
// function : keyFlag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Aspect_VKeyFlags View_Widget::keyFlag (const int theModifierId)
|
||||
Aspect_VKeyFlags View_Widget::keyFlag(const int theModifierId)
|
||||
{
|
||||
switch (theModifierId)
|
||||
{
|
||||
case Qt::NoModifier: return Aspect_VKeyFlags_NONE;
|
||||
case Qt::ShiftModifier: return Aspect_VKeyFlags_SHIFT;
|
||||
case Qt::ControlModifier: return Aspect_VKeyFlags_CTRL;
|
||||
default: break;
|
||||
case Qt::NoModifier:
|
||||
return Aspect_VKeyFlags_NONE;
|
||||
case Qt::ShiftModifier:
|
||||
return Aspect_VKeyFlags_SHIFT;
|
||||
case Qt::ControlModifier:
|
||||
return Aspect_VKeyFlags_CTRL;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Aspect_VKeyFlags_NONE;
|
||||
}
|
||||
@@ -356,15 +383,20 @@ Aspect_VKeyFlags View_Widget::keyFlag (const int theModifierId)
|
||||
// function : keyMouse
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Aspect_VKeyMouse View_Widget::keyMouse (const int theButtonId)
|
||||
Aspect_VKeyMouse View_Widget::keyMouse(const int theButtonId)
|
||||
{
|
||||
switch (theButtonId)
|
||||
{
|
||||
case Qt::NoButton: return Aspect_VKeyMouse_NONE;
|
||||
case Qt::LeftButton: return Aspect_VKeyMouse_LeftButton;
|
||||
case Qt::RightButton: return Aspect_VKeyMouse_RightButton;
|
||||
case Qt::MidButton: return Aspect_VKeyMouse_MiddleButton;
|
||||
default: break;
|
||||
case Qt::NoButton:
|
||||
return Aspect_VKeyMouse_NONE;
|
||||
case Qt::LeftButton:
|
||||
return Aspect_VKeyMouse_LeftButton;
|
||||
case Qt::RightButton:
|
||||
return Aspect_VKeyMouse_RightButton;
|
||||
case Qt::MidButton:
|
||||
return Aspect_VKeyMouse_MiddleButton;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Aspect_VKeyMouse_NONE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user