Salome HOME
bd319bfab525a79d6ac6d2dd0a42ff626a8ac1d1
[modules/geom.git] / src / GEOMGUI / GEOMGUI_CreationInfoWdg.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File      : GEOMGUI_CreationInfoWdg.cxx
20 // Created   : Fri Jun  7 13:07:59 2013
21 // Author    : Edward AGAPOV (eap)
22
23 #include "GEOMGUI_CreationInfoWdg.h"
24
25 #include <SalomeApp_Application.h>
26 #include <SUIT_Desktop.h>
27
28 #include <QString>
29 #include <QLabel>
30 #include <QLineEdit>
31 #include <QTreeWidget>
32 #include <QHeaderView>
33 #include <QGroupBox>
34 #include <QVBoxLayout>
35 #include <QHBoxLayout>
36
37 GEOMGUI_CreationInfoWdg::GEOMGUI_CreationInfoWdg( SalomeApp_Application* app )
38 //:QWidget( app->desktop() )
39 {
40   setWindowTitle( tr( "CREATION_INFO_TITLE" ) );
41   setObjectName( "geomCreationInformation" );
42
43   QFrame* frame = new QFrame( this );
44
45   QVBoxLayout* myLayout = new QVBoxLayout( this );
46   myLayout->addWidget( frame );
47   myLayout->setMargin(0);
48
49   QGroupBox* operationGB = new QGroupBox( tr( "OPERATION" ), frame );
50
51   myIconLbl      = new QLabel( operationGB );
52   myOperaionLnEd = new QLineEdit( operationGB );
53   myOperaionLnEd->setReadOnly( true );
54   myParamsTreeWd = new QTreeWidget( frame );
55   myParamsTreeWd->setColumnCount( 2 );
56   myParamsTreeWd->setHeaderLabels( QStringList() << tr( "PARAMETER" ) << tr( "VALUE" ) );
57   myParamsTreeWd->header()->setStretchLastSection( true );
58   myParamsTreeWd->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
59
60   QHBoxLayout* operationLay = new QHBoxLayout( operationGB );
61   operationLay->addWidget( myIconLbl );
62   operationLay->addWidget( myOperaionLnEd );
63   operationLay->setMargin(5);
64
65   QVBoxLayout* aLayout = new QVBoxLayout( frame );
66   aLayout->addWidget( operationGB );
67   aLayout->addWidget( myParamsTreeWd );
68
69   // get a free dockable window id
70   myWindowID = 10;
71   while( app->dockWindow( myWindowID ))
72     ++myWindowID;
73   ++myWindowID; // pb when a GEOM is a sole module: CreationInfoWdg replaces Python console
74 }
75
76 void GEOMGUI_CreationInfoWdg::setOperation(const QPixmap& icon, const QString& name)
77 {
78   myIconLbl->setPixmap( icon );
79   myOperaionLnEd->setText( name );
80
81   if ( name.isEmpty() )
82     myOperaionLnEd->setText( tr("NO_INFO"));
83 }
84
85 void GEOMGUI_CreationInfoWdg::addParam (const QString& name, const QString& value)
86 {
87   QTreeWidgetItem* item = new QTreeWidgetItem( myParamsTreeWd );
88
89   //item->setFlags( Qt::NoItemFlags );
90   item->setExpanded( true );
91
92   item->setText( 0, name );
93   item->setText( 1, value );
94 }
95
96 void GEOMGUI_CreationInfoWdg::clear()
97 {
98   myIconLbl->setPixmap( QPixmap() );
99   myOperaionLnEd->setText( "" );
100   myParamsTreeWd->clear();
101 }
102
103 GEOMGUI_CreationInfoWdg::~GEOMGUI_CreationInfoWdg()
104 {
105   //std::cout<<"~GEOMGUI_CreationInfoWdg"<<std::endl;
106 }