1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <VInspector_ToolBar.hxx>
18 #include <QHBoxLayout>
19 #include <QToolButton>
22 // =======================================================================
23 // function : Constructor
25 // =======================================================================
26 VInspector_ToolBar::VInspector_ToolBar (QWidget* theParent)
29 myActionsMap[VInspector_ToolActionType_UpdateId] = new QToolButton (theParent);
30 myActionsMap[VInspector_ToolActionType_UpdateId]->setText ("Update");
32 myActionsMap[VInspector_ToolActionType_SelectPresentationsId] = new QToolButton (theParent);
33 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setText ("Select Presentations");
34 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setCheckable (true);
36 myActionsMap[VInspector_ToolActionType_SelectOwnersId] = new QToolButton (theParent);
37 myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setText ("Select Owners");
38 myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setCheckable (true);
40 myMainWindow = new QWidget (theParent);
42 QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
43 for (QMap<VInspector_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin();
44 anActionsIt != myActionsMap.end(); anActionsIt++)
46 QToolButton* aBtn = anActionsIt.value();
47 connect (aBtn, SIGNAL (clicked()), this, SLOT (onActionClicked()));
48 aLay->addWidget (aBtn);
52 // =======================================================================
53 // function : GetToolButton
55 // =======================================================================
56 QToolButton* VInspector_ToolBar::GetToolButton (const VInspector_ToolActionType& theActionId ) const
58 return myActionsMap.contains (theActionId) ? myActionsMap[theActionId] : 0;
61 // =======================================================================
62 // function : onActionClicked
64 // =======================================================================
65 void VInspector_ToolBar::onActionClicked()
68 QToolButton* aSenderBtn = (QToolButton*)sender();
70 for (QMap<VInspector_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin();
71 anActionsIt != myActionsMap.end(); anActionsIt++)
73 if (anActionsIt.value() != aSenderBtn)
75 anId = anActionsIt.key();
79 if (anId == VInspector_ToolActionType_SelectPresentationsId && myActionsMap[VInspector_ToolActionType_SelectOwnersId]->isChecked())
80 myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setChecked(false);
81 else if (anId == VInspector_ToolActionType_SelectOwnersId && myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->isChecked())
82 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setChecked(false);
85 emit actionClicked (anId);