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 <inspector/VInspector_ToolBar.hxx>
18 #include <QHBoxLayout>
19 #include <QPushButton>
23 // =======================================================================
24 // function : Constructor
26 // =======================================================================
27 VInspector_ToolBar::VInspector_ToolBar (QWidget* theParent)
30 myActionsMap[VInspector_ToolActionType_UpdateId] = new QPushButton (theParent);
31 myActionsMap[VInspector_ToolActionType_UpdateId]->setIcon (QIcon (":/icons/treeview_update.png"));
32 myActionsMap[VInspector_ToolActionType_UpdateId]->setText (tr ("Update Tree Model"));
33 myActionsMap[VInspector_ToolActionType_UpdateId]->setToolTip (tr ("Update Tree Model"));
35 myActionsMap[VInspector_ToolActionType_UpdateId]->setText ("Update");
37 myActionsMap[VInspector_ToolActionType_SelectPresentationsId] = new QPushButton (theParent);
38 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setText ("Select Presentations");
39 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setCheckable (true);
40 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setFixedHeight(20);
42 myActionsMap[VInspector_ToolActionType_SelectOwnersId] = new QPushButton (theParent);
43 myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setText ("Select Owners");
44 myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setCheckable (true);
45 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setFixedHeight(25);
47 myMainWindow = new QWidget (theParent);
49 QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
51 for (QMap<VInspector_ToolActionType, QPushButton*>::ConstIterator anActionsIt = myActionsMap.begin();
52 anActionsIt != myActionsMap.end(); anActionsIt++)
54 QPushButton* aBtn = anActionsIt.value();
55 connect (aBtn, SIGNAL (clicked()), this, SLOT (onActionClicked()));
56 aLay->addWidget (aBtn);
61 // =======================================================================
62 // function : GetToolButton
64 // =======================================================================
65 QPushButton* VInspector_ToolBar::GetToolButton (const VInspector_ToolActionType& theActionId ) const
67 return myActionsMap.contains (theActionId) ? myActionsMap[theActionId] : 0;
70 // =======================================================================
71 // function : onActionClicked
73 // =======================================================================
74 void VInspector_ToolBar::onActionClicked()
77 QPushButton* aSenderBtn = (QPushButton*)sender();
79 for (QMap<VInspector_ToolActionType, QPushButton*>::ConstIterator anActionsIt = myActionsMap.begin();
80 anActionsIt != myActionsMap.end(); anActionsIt++)
82 if (anActionsIt.value() != aSenderBtn)
84 anId = anActionsIt.key();
88 if (anId == VInspector_ToolActionType_SelectPresentationsId && myActionsMap[VInspector_ToolActionType_SelectOwnersId]->isChecked())
89 myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setChecked(false);
90 else if (anId == VInspector_ToolActionType_SelectOwnersId && myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->isChecked())
91 myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setChecked(false);
94 emit actionClicked (anId);