1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : GEOMGUI_CreationInfoWdg.cxx
20 // Created : Fri Jun 7 13:07:59 2013
21 // Author : Edward AGAPOV (eap)
23 #include "GEOMGUI_CreationInfoWdg.h"
25 #include "GEOMImpl_Types.hxx"
27 #include <SUIT_Desktop.h>
28 #include <SUIT_ResourceMgr.h>
29 #include <SUIT_Session.h>
30 #include <SalomeApp_Application.h>
35 #include <QTreeWidget>
36 #include <QHeaderView>
38 #include <QVBoxLayout>
39 #include <QHBoxLayout>
41 GEOMGUI_CreationInfoWdg::GEOMGUI_CreationInfoWdg( SalomeApp_Application* app )
42 //:QWidget( app->desktop() )
44 setWindowTitle( tr( "CREATION_INFO_TITLE" ) );
46 myParamsTreeWd = new QTreeWidget( this );
47 myParamsTreeWd->setColumnCount( 2 );
48 myParamsTreeWd->setHeaderLabels( QStringList() << tr( "PARAMETER" ) << tr( "VALUE" ) );
49 myParamsTreeWd->header()->setStretchLastSection( true );
50 myParamsTreeWd->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
52 QVBoxLayout* aLayout = new QVBoxLayout( this );
53 aLayout->addWidget( myParamsTreeWd );
54 aLayout->setMargin(11);
56 // get a free dockable window id
58 while( app->dockWindow( myWindowID ))
60 ++myWindowID; // pb when a GEOM is a sole module: CreationInfoWdg replaces Python console
63 QTreeWidgetItem* GEOMGUI_CreationInfoWdg::addOperation(const QPixmap& icon, const QString& name)
65 QTreeWidgetItem* item = new QTreeWidgetItem( myParamsTreeWd );
67 item->setIcon( 0, icon );
68 item->setText( 0, name );
70 item->setText( 0, tr("NO_INFO"));
72 item->setExpanded( true );
77 void GEOMGUI_CreationInfoWdg::addParam (QTreeWidgetItem* operation,
81 QTreeWidgetItem* item = new QTreeWidgetItem( operation );
83 //item->setFlags( Qt::NoItemFlags );
84 item->setExpanded( true );
86 item->setText( 0, name );
87 item->setText( 1, value );
90 void GEOMGUI_CreationInfoWdg::clear()
92 myParamsTreeWd->clear();
95 GEOMGUI_CreationInfoWdg::~GEOMGUI_CreationInfoWdg()
97 //std::cout<<"~GEOMGUI_CreationInfoWdg"<<std::endl;
100 void GEOMGUI_CreationInfoWdg::setInfo( GEOM::CreationInformationSeq& info )
105 QString operationName;
109 if ( info.length() > 0 )
111 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
112 for ( int j = 0, nb = info.length(); j < nb; ++j )
114 QString name = info[j].operationName.in();
115 if ( !name.isEmpty() )
117 // get plugin_name if any
119 for ( size_t i = 0; i < info[j].params.length(); ++i )
121 QString value = info[j].params[i].name.in();
122 if ( value == PLUGIN_NAME )
123 plugin_name = info[j].params[i].value.in();
126 QString prefix = plugin_name.isEmpty() ? "GEOM" : plugin_name;
127 if ( name.startsWith( "Import"))
128 icon = resMgr->loadPixmap( "GEOM", tr("ICO_IMPORT_SHAPE"), true );
130 icon = resMgr->loadPixmap( prefix, tr( ("ICO_"+name).toLatin1().constData() ), false );
132 // translate operation name
133 operationName = tr( ("MEN_"+name).toLatin1().constData() );
134 if ( operationName.startsWith( "MEN_" ))
135 operationName = name; // no translation
137 QTreeWidgetItem* operation = addOperation( icon, operationName );
140 for ( size_t i = 0; i < info[j].params.length(); ++i )
142 info[j].params[i].name.in(),
143 info[j].params[i].value.in() );
149 addOperation( icon, operationName );