1 // Copyright (C) 2020-2021 CEA/DEN, EDF R&D
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
20 #include "SMESHGUI_MgAdaptDlg.h"
22 #include "MED_Factory.hxx"
24 #include <SalomeApp_Tools.h>
25 #include <SalomeApp_Module.h>
26 #include <SUIT_MessageBox.h>
27 #include <SUIT_OverrideCursor.h>
28 #include <SUIT_FileDlg.h>
30 #include <QApplication>
31 #include <QButtonGroup>
34 #include <QDoubleSpinBox>
35 #include <QFileDialog>
36 #include <QGridLayout>
38 #include <QHBoxLayout>
39 #include <QHeaderView>
40 #include <QItemDelegate>
44 #include <QMessageBox>
45 #include <QPushButton>
46 #include <QRadioButton>
47 #include <QSpacerItem>
51 #include <QTreeWidget>
52 #include <QTreeWidgetItem>
53 #include <QVBoxLayout>
55 const int SPACING = 6; // layout spacing
56 const int MARGIN = 9; // layout margin
61 // ======================================================
62 QString lireNomDimMaillage(QString aFile, int& meshdim)
63 // ========================================================
65 QString nomMaillage = QString::null ;
71 MED::PWrapper aMed = MED::CrWrapperR( aFile.toUtf8().data() );
72 MED::TInt numberOfMeshes = aMed->GetNbMeshes();
74 if (numberOfMeshes == 0 )
76 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
77 QObject::tr("MG_ADAPT_MED_FILE_2") );
80 if (numberOfMeshes > 1 )
82 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
83 QObject::tr("MG_ADAPT_MED_FILE_3") );
87 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo( 1 );
88 nomMaillage = aMeshInfo->GetName().c_str();
89 meshdim = (int) aMeshInfo->GetDim();
94 catch ( const SALOME::SALOME_Exception & S_ex )
96 SalomeApp_Tools::QtCatchCorbaException(S_ex);
102 // =======================================================================
103 std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage=true)
104 // =======================================================================
106 // Il faut voir si plusieurs maillages
108 std::map<QString, int> ListeChamp ;
114 MED::PWrapper aMed = MED::CrWrapperR( aFile.toUtf8().data() );
115 MED::TInt jaux = aMed->GetNbFields();
120 QMessageBox::critical( 0, QObject::tr("_ERROR"),
121 QObject::tr("HOM_MED_FILE_5") );
125 // nbofcstp inutile pour le moment
126 MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo( 1 );
128 for( MED::TInt j=0;j<jaux;j++)
130 MED::PFieldInfo aFiledInfo = aMed->GetPFieldInfo( aMeshInfo, j + 1 );
131 ListeChamp.insert({ QString( aFiledInfo->GetName().c_str()), nbofcstp });
136 catch ( const SALOME::SALOME_Exception & S_ex )
138 SalomeApp_Tools::QtCatchCorbaException(S_ex);
144 // =======================================================================
145 std::string remove_extension(const std::string& filename)
146 // =======================================================================
148 size_t lastdot = filename.find_last_of(".");
149 if (lastdot == std::string::npos) return filename;
150 return filename.substr(0, lastdot);
154 //=================================================================================
155 // function : SMESHGUI_MgAdaptDlg()
157 //=================================================================================
158 SMESHGUI_MgAdaptDlg::SMESHGUI_MgAdaptDlg( SalomeApp_Module* theModule, SMESH::MG_ADAPT_ptr myModel, QWidget* parent, bool isCreation )
159 : QDialog(parent), mySMESHGUI( theModule )
161 //~model = new MgAdapt(*myModel);
162 model = SMESH::MG_ADAPT::_duplicate(myModel);
164 myData = model->getData();
166 if (!isCreation) readParamsFromHypo();
169 void SMESHGUI_MgAdaptDlg::buildDlg()
172 setAttribute( Qt::WA_DeleteOnClose, true );
173 setWindowTitle( tr( "ADAPT_PREF_MG_ADAPT" ) );
174 setSizeGripEnabled( true );
176 myTabWidget = new QTabWidget( this );
180 myArgs = new SMESHGUI_MgAdaptArguments( myTabWidget );
181 SMESH::string_array_var str = model->getOptionValuesStrVec();
182 SMESH::string_array_var str2 = model->getCustomOptionValuesStrVec();
183 std::vector<std::string> s;
184 for (CORBA::ULong i = 0; i< str->length(); i++) s.push_back( str[i].in());
185 for (CORBA::ULong j = str->length(); j< str2->length(); j++) s.push_back(str[ j - str->length() ].in() );
186 //~str.insert( str.end(), str2.begin(), str2.end() );
188 myAdvOpt = new MgAdaptAdvWidget(myTabWidget, &s);
190 /*int argsTab =*/ myTabWidget->addTab( myArgs, tr( "Args" ) );
191 /*int advTab =*/ myTabWidget->addTab( myAdvOpt, tr( "ADVOP" ) );
193 myAdvOpt->workingDirectoryLabel ->setText (tr( "WORKING_DIR" ));
194 myAdvOpt->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
195 myAdvOpt->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
196 myAdvOpt->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
197 myAdvOpt->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
198 myAdvOpt->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
199 myAdvOpt->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
202 QPushButton* buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this);
203 buttonOk->setAutoDefault(false);
204 QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this);
205 buttonApply->setAutoDefault(false);
206 QPushButton* buttonCancel = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this );
207 buttonCancel->setAutoDefault( false );
208 QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
209 buttonHelp->setAutoDefault( false );
211 QHBoxLayout* btnLayout = new QHBoxLayout;
212 btnLayout->setSpacing( SPACING );
213 btnLayout->setMargin( 0 );
214 btnLayout->addWidget( buttonOk );
215 btnLayout->addStretch( 10 );
216 btnLayout->addWidget( buttonApply );
217 btnLayout->addStretch( 10 );
218 btnLayout->addWidget( buttonCancel );
219 btnLayout->addStretch( 10 );
220 btnLayout->addWidget( buttonHelp );
222 QVBoxLayout* l = new QVBoxLayout ( this );
223 l->setMargin( MARGIN );
224 l->setSpacing( SPACING );
225 l->addWidget( myTabWidget );
227 l->addLayout( btnLayout );
229 connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK()));
230 connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply()));
231 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
232 connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp()));
234 connect( myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE)) );
238 //=================================================================================
239 // function : ~SMESHGUI_MgAdaptDlg()
240 // purpose : Destroys the object and frees any allocated resources
241 //=================================================================================
242 SMESHGUI_MgAdaptDlg::~SMESHGUI_MgAdaptDlg()
247 //~void SMESHGUI_MgAdaptDlg::setModel(MgAdapt* mg)
251 SMESH::MG_ADAPT_ptr SMESHGUI_MgAdaptDlg::getModel() const
256 \brief Perform clean-up actions on the dialog box closing.
258 bool SMESHGUI_MgAdaptDlg::PushOnApply()
260 bool ret = readParamsFromWidgets();
263 void SMESHGUI_MgAdaptDlg::PushOnOK()
265 bool ret = PushOnApply();
268 void SMESHGUI_MgAdaptDlg::reject()
272 bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const
275 myArgs->aMedfile->setChecked(myData->fromMedFile) ;
276 if (myData->fromMedFile)
279 myArgs->myFileInDir = myData->myFileInDir;
280 myArgs->selectMedFileLineEdit->setText(QString(myData->myMeshFileIn)) ;
281 // myData->myInMeshName = // TODO
286 myArgs->aBrowserObject->setText(QString(myData->myInMeshName));
287 //~ myArgs->myFileInDir =""; // TODO
288 //~ myArgs->selectMedFileLineEdit->setText(); // TODO
290 myArgs->meshNameLineEdit->setText(QString(myData->myOutMeshName));
291 myArgs->medFileCheckBox->setChecked(myData->myMeshOutMed);
293 if(myData->myMeshOutMed)
295 myArgs->myFileOutDir = QString(myData->myFileOutDir);
296 myArgs->selectOutMedFileLineEdit->setText(myData->myMeshFileOut.in());
300 myArgs->myFileOutDir = ""; //TODO
303 myArgs->publishOut->setChecked(myData->myPublish);
305 myArgs->localButton->setChecked(myData->myUseLocalMap);
306 myArgs->backgroundButton->setChecked(myData->myUseBackgroundMap);
307 myArgs->constantButton->setChecked(myData->myUseConstantValue);
309 if (myData->myUseConstantValue)
311 myArgs->dvalue->setValue(myData->myConstantValue);
315 myArgs->dvalue->setValue(0.0);
318 if (myData->myUseBackgroundMap)
321 myArgs->myFileSizeMapDir = QString(myData->myFileSizeMapDir) ;
322 myArgs->selectMedFileBackgroundLineEdit->setText(QString(myData->myMeshFileBackground));
326 myArgs->myFileSizeMapDir = ""; //TODO
327 myArgs->selectMedFileBackgroundLineEdit->setText(""); //TODO
330 myArgs->fieldNameCmb->setCurrentText(QString(myData->myFieldName));
331 myArgs->noTimeStep->setChecked(myData->myUseNoTimeStep);
332 myArgs->lastTimeStep->setChecked( myData->myUseLastTimeStep);
333 myArgs->chosenTimeStep->setChecked(myData->myUseChosenTimeStep);
334 if (myData->myUseChosenTimeStep)
336 myArgs->rankSpinBox->setValue(myData->myRank);
337 myArgs->timeStep->setValue(myData->myTimeStep);
340 myAdvOpt->workingDirectoryLineEdit->setText(QString(myData->myWorkingDir));
341 myAdvOpt->logInFileCheck->setChecked(myData->myPrintLogInFile);
343 myAdvOpt->verboseLevelSpin->setValue(myData->myVerboseLevel);
344 myAdvOpt->removeLogOnSuccessCheck->setChecked(myData->myRemoveLogOnSuccess);
345 myAdvOpt->keepWorkingFilesCheck->setChecked(myData->myKeepFiles);
351 bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets()
354 SMESH::MgAdaptHypothesisData data, *aData = &data;
357 // 1. Fichier du maillage de départ
358 aData->fromMedFile = myArgs->aMedfile->isChecked();
359 if (aData->fromMedFile)
361 aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir.toUtf8().data());
362 aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toUtf8().data());
363 // aData->myInMeshName = // TODO
367 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
368 QObject::tr("MG_ADAPT_MED_FILE_4") );
371 // aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str());
372 // aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
374 // TCollection_AsciiString aGenericName = (char*)aData->myFileInDir;
375 // TCollection_AsciiString aGenericName2 = "MgAdapt_";
376 // aGenericName2 += getpid();
377 // aGenericName2 += "_";
378 // aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString());
379 // aGenericName2 += ".med";
380 // aGenericName+=aGenericName2;
381 // emit myArgs->toExportMED(aGenericName.ToCString());
382 // aData->myMeshFileIn = aGenericName2.ToCString();
384 // 2. Fichier du maillage de sortie
385 aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str());
386 aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked();
387 if(aData->myMeshOutMed)
389 aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir.toUtf8().data());
390 aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toUtf8().data());
394 aData->myMeshFileOut = "";
396 aData->myPublish = myArgs->publishOut->isChecked();
398 // 3. Type de carte de tailles
399 aData->myUseLocalMap = myArgs->localButton->isChecked();
400 aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked();
401 aData->myUseConstantValue = myArgs->constantButton->isChecked();
403 if (aData->myUseConstantValue)
405 aData->myConstantValue = myArgs->dvalue->value();
409 aData->myConstantValue = 0.0;
412 if (aData->myUseBackgroundMap)
414 aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir.toUtf8().data());
415 aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toUtf8().data());
419 aData->myMeshFileBackground = "";
423 if ( ! aData->myUseConstantValue )
425 if ( strlen(myArgs->fieldNameCmb->currentText().toStdString().c_str()) == 0 )
427 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
428 QObject::tr("MG_ADAPT_MED_FILE_5") );
433 aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str());
434 aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked();
435 aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked();
436 aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked();
437 if (aData->myUseChosenTimeStep)
439 aData->myRank = myArgs->rankSpinBox->value();
440 aData->myTimeStep = myArgs->timeStep->value();
445 // 5. Options avancées
446 aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
447 aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked();
448 aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value();
449 aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked();
450 aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked();
451 model->setData(*aData);
460 bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const
465 \brief Show help page
467 void SMESHGUI_MgAdaptDlg::PushOnHelp()
469 // QString aHelpFile;
470 // if ( myTabWidget->currentIndex() == MinDistance ) {
471 // aHelpFile = "measurements.html#min-distance-anchor";
472 // } else if ( myTabWidget->currentIndex() == BoundingBox ) {
473 // aHelpFile = "measurements.html#bounding-box-anchor";
474 // } else if ( myTabWidget->currentWidget() == myAngle ) {
475 // aHelpFile = "measurements.html#angle-anchor";
477 // aHelpFile = "measurements.html#basic-properties-anchor";
480 // SMESH::ShowHelpFile( aHelpFile );
482 bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg)
484 if ( !QFileInfo( myAdvOpt->workingDirectoryLineEdit->text().trimmed() ).isWritable() )
486 SUIT_MessageBox::warning( this,
487 tr( "SMESH_WRN_WARNING" ),
488 tr( "NO_PERMISSION" ) );
493 myAdvOpt->myOptionTable->setFocus();
494 QApplication::instance()->processEvents();
497 bool isDefault, ok = true;
498 int iRow = 0, nbRows = myAdvOpt->myOptionTable->topLevelItemCount();
499 for ( ; iRow < nbRows; ++iRow )
501 QTreeWidgetItem* row = myAdvOpt->myOptionTable->topLevelItem( iRow );
502 myAdvOpt->GetOptionAndValue( row, name, value, isDefault );
504 if ( name.simplified().isEmpty() )
505 continue; // invalid custom option
507 if ( isDefault ) // not selected option
512 model->setOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
514 catch ( const SALOME::SALOME_Exception& ex )
516 msg = ex.details.text.in();
525 //=================================================================================
526 // function : SMESHGUI_MgAdaptArguments()
528 //=================================================================================
529 SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent )
533 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
535 myFileInDir = QDir::currentPath();
536 myFileOutDir = QDir::currentPath();
537 myFileSizeMapDir = QDir::currentPath();
541 myFileInDir = SUIT_FileDlg::getLastVisitedPath();
542 myFileOutDir = SUIT_FileDlg::getLastVisitedPath();
543 myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath();
549 aMeshIn = new QGroupBox( tr( "MeshIn" ), this );
550 aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn );
551 aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn );
552 aBrowserObject = new QLineEdit( aMeshIn );
553 selectMedFilebutton = new QPushButton("...", aMeshIn);
554 selectMedFileLineEdit = new QLineEdit( aMeshIn );
556 meshIn = new QGridLayout( aMeshIn );
558 meshIn->setMargin( MARGIN );
559 meshIn->setSpacing( SPACING );
560 meshIn->addWidget( aMedfile, 0, 0, 1,1 );
561 meshIn->addWidget( aBrowser, 0, 1,1,1);
562 meshIn->addWidget( aBrowserObject, 0, 2, 1, 1 );
563 meshIn->addWidget( selectMedFilebutton, 1, 0,1, 1);
564 meshIn->addWidget( selectMedFileLineEdit, 1, 1, 1, 1 );
565 hspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
567 meshInGroup = new QButtonGroup( this );
568 meshInGroup->addButton( aMedfile, 0 );
569 meshInGroup->addButton( aBrowser, 1 );
573 aMeshOut = new QGroupBox( tr( "MeshOut" ), this );
574 meshName = new QLabel(tr("MeshName"), aMeshOut);
575 secondHspacer = new QSpacerItem(100, 30);
576 meshNameLineEdit = new QLineEdit(aMeshOut) ;
577 medFileCheckBox = new QCheckBox(tr("MEDFile"), aMeshOut);
578 selectOutMedFilebutton = new QPushButton("...", aMeshOut);
579 thirdHspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
580 selectOutMedFileLineEdit = new QLineEdit(aMeshOut) ;
581 publishOut = new QCheckBox(tr("Publish_MG_ADAPT"), aMeshOut);
583 meshOut = new QGridLayout( aMeshOut );
585 meshOut->setMargin( MARGIN );
586 meshOut->setSpacing( SPACING );
587 meshOut->addWidget( meshName, 0, 0, 1,1 );
588 meshOut->addItem( secondHspacer, 0, 1, 1, 1 );
589 meshOut->addWidget( meshNameLineEdit, 0, 2,1,1);
590 meshOut->addWidget( medFileCheckBox, 1, 0,1,1 );
591 meshOut->addWidget( selectOutMedFilebutton, 1, 1,1,1 );
592 meshOut->addWidget( selectOutMedFileLineEdit, 1, 2,1,1);
593 meshOut->addWidget( publishOut, 2, 0,1,1 );
595 //size map definition
597 sizeMapDefinition = new QGroupBox(tr("SIZE_MAP_DEF"), this);
598 localButton = new QRadioButton(tr("LOCAL_MG_ADAPT"), sizeMapDefinition);
599 backgroundButton = new QRadioButton(tr("BACKGRND_MG_ADAPT"), sizeMapDefinition);
600 constantButton = new QRadioButton(tr("CNST_MG_ADAPT"), sizeMapDefinition);
601 medFileBackground = new QLabel(tr("MED_FILE_BCKG"), sizeMapDefinition);
602 selectMedFileBackgroundbutton = new QPushButton("...", sizeMapDefinition);
603 selectMedFileBackgroundLineEdit = new QLineEdit(sizeMapDefinition);
604 valueLabel = new QLabel(tr("VALUE_MG_ADAPT"), sizeMapDefinition);
605 dvalue = new QDoubleSpinBox(sizeMapDefinition);
606 sizeMapDefGroup = new QButtonGroup( this );
607 sizeMapDefGroup->addButton( localButton, 0 );
608 sizeMapDefGroup->addButton( backgroundButton, 1 );
609 sizeMapDefGroup->addButton( constantButton, 2 );
611 sizeMapDefGroupLayout = new QGridLayout(sizeMapDefinition);
612 sizeMapDefGroupLayout->addWidget(localButton, 0,0);
613 sizeMapDefGroupLayout->addWidget(backgroundButton, 0,1);
614 sizeMapDefGroupLayout->addWidget(constantButton, 0,2);
615 sizeMapDefGroupLayout->addWidget(medFileBackground, 1,0);
616 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundbutton, 1,1);
617 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundLineEdit, 1,2);
618 sizeMapDefGroupLayout->addWidget(valueLabel, 2,0);
619 sizeMapDefGroupLayout->addWidget(dvalue, 2,1);
622 sizeMapField = new QGroupBox(tr("SIZE_MAP_FIELD"), this);
623 fieldName = new QLabel(tr("MG_ADAPT_FIELD_NAME"), sizeMapField);
624 fieldNameCmb = new QComboBox(sizeMapField);
625 noTimeStep = new QRadioButton(tr("MG_ADAPT_NO_T_ST"), sizeMapField);
626 lastTimeStep = new QRadioButton(tr("MG_ADAPT_L_ST"), sizeMapField);
627 chosenTimeStep = new QRadioButton(tr("MG_ADAPT_CH_ST"), sizeMapField);
628 timeStepLabel = new QLabel(tr("MG_ADAPT_TSTP"), sizeMapField);
629 timeStep = new QSpinBox(sizeMapField);
630 timeStep->setMinimum(-1);
631 rankLabel = new QLabel(tr("MG_ADAPT_RANK"), sizeMapField);
632 rankSpinBox = new QSpinBox(sizeMapField);
633 rankSpinBox->setMinimum(-1);
635 timeStepGroup = new QButtonGroup(this);
636 timeStepGroup->addButton(noTimeStep, 0);
637 timeStepGroup->addButton(lastTimeStep, 1);
638 timeStepGroup->addButton(chosenTimeStep, 2);
640 sizeMapFieldGroupLayout = new QGridLayout(sizeMapField);
642 sizeMapFieldGroupLayout->addWidget(fieldName, 0,0);
643 sizeMapFieldGroupLayout->addWidget(fieldNameCmb, 0,1);
644 sizeMapFieldGroupLayout->addWidget(noTimeStep, 1,0);
645 sizeMapFieldGroupLayout->addWidget(lastTimeStep, 1,1);
646 sizeMapFieldGroupLayout->addWidget(chosenTimeStep, 1,2);
647 sizeMapFieldGroupLayout->addWidget(timeStepLabel, 2,0);
648 sizeMapFieldGroupLayout->addWidget(timeStep, 2,1);
649 sizeMapFieldGroupLayout->addWidget(rankLabel, 2,2);
650 sizeMapFieldGroupLayout->addWidget(rankSpinBox, 2,3);
652 QGridLayout* argumentsLayout = new QGridLayout( this );
653 argumentsLayout->setMargin( MARGIN );
654 argumentsLayout->setSpacing( SPACING );
656 argumentsLayout->addWidget( aMeshIn, 0, 0, 1, 3 );
657 argumentsLayout->addWidget( aMeshOut, 1, 0, 1, 3 );
658 argumentsLayout->addWidget( sizeMapDefinition, 2, 0, 1, 3 );
659 argumentsLayout->addWidget( sizeMapField, 3, 0, 1, 3 );
660 argumentsLayout->setColumnStretch( 1, 5 );
661 argumentsLayout->setRowStretch( 4, 5 );
664 setMode( Mesh, Local);
665 medFileCheckBox->setChecked(true);
666 visibleTimeStepRankLabel (false);
669 connect( meshInGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged( int ) ) );
670 connect( sizeMapDefGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( sizeMapDefChanged( int ) ) );
671 connect( selectMedFilebutton, SIGNAL( pressed( ) ), this, SLOT( onSelectMedFilebuttonClicked( ) ) );
672 connect( medFileCheckBox, SIGNAL (stateChanged(int)), this, SLOT(onMedFileCheckBox(int) ) );
673 connect( publishOut, SIGNAL (stateChanged(int)), this, SLOT(onPublishOut(int) ) );
674 connect( selectOutMedFilebutton, SIGNAL( pressed()), this, SLOT(onSelectOutMedFilebutton()));
675 connect( selectMedFileBackgroundbutton, SIGNAL(pressed()), this, SLOT(onSelectMedFileBackgroundbutton()) );
676 connect( timeStepGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( timeStepGroupChanged( int ) ) );
677 emit updateSelection();
680 //=================================================================================
681 // function : ~SMESHGUI_MgAdaptArguments()
682 // purpose : Destroys the object and frees any allocated resources
683 //=================================================================================
684 SMESHGUI_MgAdaptArguments::~SMESHGUI_MgAdaptArguments()
688 void SMESHGUI_MgAdaptArguments::onNoTimeStep(bool disableOther)
690 noTimeStep->setChecked(true);
692 visibleTimeStepRankLabel (false);
693 rankSpinBox->setValue(-2);
694 timeStep->setValue(-2);
696 lastTimeStep->setDisabled(disableOther);
697 chosenTimeStep->setDisabled(disableOther);
699 void SMESHGUI_MgAdaptArguments::onLastTimeStep(bool disableOther)
701 lastTimeStep->setChecked(true);
703 visibleTimeStepRankLabel (false);
704 rankSpinBox->setValue(-1);
705 timeStep->setValue(-1);
706 noTimeStep->setDisabled(disableOther);
708 void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool /*disableOther*/, int vmax)
710 chosenTimeStep->setChecked(true);
712 visibleTimeStepRankLabel (true);
713 rankSpinBox->setValue(-1);
714 timeStep->setValue(-1);
715 if (vmax) timeStep->setMaximum(vmax);
718 void SMESHGUI_MgAdaptArguments::visibleTimeStepRankLabel(bool visible)
720 rankLabel->setVisible(visible);
721 rankSpinBox->setVisible(visible);
723 timeStepLabel->setVisible(visible);
724 timeStep->setVisible(visible);
727 void SMESHGUI_MgAdaptArguments::onSelectOutMedFilebutton()
730 QString filtre = QString("Med") ;
731 filtre += QString(" files (*.") + QString("med") + QString(");;");
732 QString fileName = QFileDialog::getSaveFileName(this, tr("SAVE_MED"), QString(""), filtre);
733 QFileInfo myFileInfo(fileName);
734 selectOutMedFileLineEdit->setText(myFileInfo.fileName());
735 myFileOutDir = myFileInfo.path();
738 void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton()
740 QString fileName0 = selectMedFileBackgroundbutton->text().trimmed();
742 QString fileName = getMedFileName(false);
743 if (fileName != QString::null)
745 myFieldList = GetListeChamps(fileName);
746 if (myFieldList.empty())
748 fileName = fileName0;
749 fieldNameCmb->clear();
753 // fill field name Combobox
754 fieldNameCmb->clear();
755 std::map<QString, int>::const_iterator it;
756 for ( it=myFieldList.begin() ; it != myFieldList.end(); it++)
758 fieldNameCmb->insertItem(0,QString(it->first));
759 int typeStepInField = it->second > 2 ? 2 : it->second ;
760 timeStepGroupChanged(typeStepInField, false);
762 // Dimension du maillage de fonds
763 lireNomDimMaillage( fileName, meshDimBG );
769 fileName = fileName0;
770 fieldNameCmb->clear();
773 QFileInfo myFileInfo(fileName);
774 myFileSizeMapDir = myFileInfo.path();
775 selectMedFileBackgroundLineEdit->setText(myFileInfo.fileName());
778 void SMESHGUI_MgAdaptArguments::onMedFileCheckBox(int state)
780 if (state == Qt::Checked)
782 selectOutMedFilebutton->show();
783 selectOutMedFileLineEdit->show();
784 selectOutMedFilebutton->setEnabled(true);
785 selectOutMedFileLineEdit->setEnabled(true);
789 selectOutMedFilebutton->setEnabled(false);
790 selectOutMedFileLineEdit->setEnabled(false);
791 publishOut->setChecked(true);
794 void SMESHGUI_MgAdaptArguments::onPublishOut(int state)
796 if (state == Qt::Unchecked)
798 medFileCheckBox->setChecked(true);
802 void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked()
804 // bool keep = false;
805 QString fileName0 = selectMedFileLineEdit->text().trimmed();
807 QString fileName = getMedFileName(false);
808 if(fileName != QString::null)
810 QString aMeshName = lireNomDimMaillage(fileName.trimmed(), meshDim);
811 if (aMeshName.isEmpty() )
813 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
814 QObject::tr("MG_ADAPT_MED_FILE_2") );
815 fileName = fileName0;
819 meshNameLineEdit->setText(aMeshName);
821 // ADAPTATION_MODE aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; // and when dimesh 3 without 2D mesh?
822 // emit meshDimSignal(aMode);
830 QFileInfo myFileInfo(fileName);
831 myFileInDir = myFileInfo.path();
832 myFileOutDir = myFileInfo.path();
833 selectMedFileLineEdit->setText(myFileInfo.fileName());
834 QString outF = fileName == QString::null ? myFileInfo.fileName() :
835 QString( remove_extension(myFileInfo.fileName().toStdString() ).c_str() )+ QString(".adapt.med");
836 selectOutMedFileLineEdit->setText(outF);
837 onLocalSelected(myFileInfo.filePath());
841 void SMESHGUI_MgAdaptArguments::valueAdaptation()
843 ADAPTATION_MODE aMode ;
846 aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE;
850 aMode = ADAPTATION_MODE::BOTH;
852 emit meshDimSignal(aMode);
855 void SMESHGUI_MgAdaptArguments::onLocalSelected(QString filePath)
857 myFieldList = GetListeChamps(filePath, false);
858 if (myFieldList.empty())
860 if (localButton->isChecked())
862 fieldNameCmb->clear();
867 // fill field name Combobox
868 fieldNameCmb->clear();
869 std::map<QString, int>::const_iterator it;
870 for ( it = myFieldList.begin() ; it != myFieldList.end(); it++)
872 fieldNameCmb->insertItem(0,QString(it->first));
873 // Je ne comprends pas le rapport entre pas de temps et apparition d'un nouveau champ... GN
874 int typeStepInField = it->second > 2 ? 2 : it->second ;
875 // std::cout << "SMESHGUI_MgAdaptArguments::onLocalSelected typeStepInField : " << typeStepInField << std::endl;
876 timeStepGroupChanged(typeStepInField, false);
880 // =======================================================================
881 // Gestion les boutons qui permettent de
882 // 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun
883 // objet est selectionne dans l arbre d etude
884 // 2) retourne le nom du fichier asocie a l objet
885 // selectionne dans l arbre d etude
886 // =======================================================================
887 QString SMESHGUI_MgAdaptArguments::getMedFileName(bool /*avertir*/)
890 QString aFile = QString::null;
891 QString filtre = QString("Med") ;
892 filtre += QString(" files (*.") + QString("med") + QString(");;");
893 aFile = SUIT_FileDlg::getOpenFileName(0, QObject::tr("MG_ADAPT_SELECT_FILE_0"), QString(""), filtre );
898 void SMESHGUI_MgAdaptArguments::setMode(const Mode theMode, const SIZEMAP theSizeMap )
900 QRadioButton* aButton = qobject_cast<QRadioButton*>( meshInGroup->button( theMode ) );
901 QRadioButton* bButton = qobject_cast<QRadioButton*>( sizeMapDefGroup->button( theSizeMap ) );
904 aButton->setChecked( true );
905 modeChanged( theMode );
909 bButton->setChecked( true );
910 sizeMapDefChanged( theSizeMap );
914 void SMESHGUI_MgAdaptArguments::modeChanged( int theMode )
919 aBrowserObject->hide();
920 selectMedFileLineEdit->show();
921 selectMedFilebutton->show();
922 localButton->setEnabled(true);
926 selectMedFileLineEdit->hide();
927 selectMedFilebutton->hide();
928 localButton->setEnabled(false);
929 aBrowserObject->show();
930 sizeMapDefChanged(Background);
931 emit updateSelection();
935 void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int theSizeMap )
937 fieldNameCmb->clear();
938 if(theSizeMap == Local)
940 localButton->setEnabled(true);
941 localButton->setChecked(true);
942 medFileBackground->hide();
943 selectMedFileBackgroundbutton->hide();
944 selectMedFileBackgroundLineEdit->hide();
945 selectMedFileBackgroundLineEdit->clear();
949 sizeMapField->setEnabled(true);
950 if (!selectMedFileLineEdit->text().isEmpty())
952 QFileInfo myFileInfo(QDir(myFileInDir), selectMedFileLineEdit->text());
953 onLocalSelected(myFileInfo.filePath());
956 else if (theSizeMap == Background)
958 medFileBackground->show();
959 backgroundButton->setChecked(true);
960 selectMedFileBackgroundbutton->show();
961 selectMedFileBackgroundLineEdit->show();
964 sizeMapField->setEnabled(true);
968 medFileBackground->hide();
969 constantButton->setChecked(true);
970 selectMedFileBackgroundbutton->hide();
971 selectMedFileBackgroundLineEdit->clear();
972 selectMedFileBackgroundLineEdit->hide();
975 sizeMapField->setEnabled(false);
980 void SMESHGUI_MgAdaptArguments::timeStepGroupChanged(int timeStepType, bool disableOther, int vmax)
982 switch (timeStepType)
985 onNoTimeStep(disableOther);
988 onLastTimeStep(disableOther);
991 onChosenTimeStep(disableOther, vmax);
997 void SMESHGUI_MgAdaptArguments::clear()
999 selectMedFileLineEdit->clear();
1000 aBrowserObject->clear();
1002 meshNameLineEdit->clear();
1003 selectOutMedFileLineEdit->clear();
1005 // med_int SMESHGUI_MgAdaptArguments::getMeshDim() const
1009 QWidget* ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const
1011 bool editable = index.data( EDITABLE_ROLE ).toInt();
1012 return editable ? QItemDelegate::createEditor( parent, o, index ) : 0;
1015 //////////////////////////////////////////
1017 //////////////////////////////////////////
1019 MgAdaptAdvWidget::MgAdaptAdvWidget( QWidget* parent, std::vector <std::string>* options, Qt::WindowFlags f )
1020 : QWidget( parent, f ), myOptions(options)
1023 myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1024 myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) );
1026 for ( size_t i = 0, nb = myOptions->size(); i < nb; ++i )
1028 AddOption( (*myOptions)[i].c_str() );
1031 connect( myOptionTable, SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( itemChanged(QTreeWidgetItem *, int )));
1032 connect( addBtn, SIGNAL(clicked()), this, SLOT( onAddOption() ) );
1033 connect(workingDirectoryPushButton, SIGNAL(pressed()), this, SLOT(_onWorkingDirectoryPushButton()));
1036 MgAdaptAdvWidget::~MgAdaptAdvWidget()
1040 void MgAdaptAdvWidget::AddOption( const char* option, bool isCustom )
1042 QString name, value;
1043 bool isDefault = false;
1046 QStringList name_value_type = QString(option).split( ":", QString::KeepEmptyParts );
1047 if ( name_value_type.size() > 0 )
1048 name = name_value_type[0];
1049 if ( name_value_type.size() > 1 )
1050 value = name_value_type[1];
1051 if ( name_value_type.size() > 2 )
1052 isDefault = !name_value_type[2].toInt();
1054 QTreeWidget* table = myOptionTable;
1055 //table->setExpanded( true );
1057 QTreeWidgetItem* row;
1058 if (optionTreeWidgetItem.size())
1060 std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(name);
1061 if(it != optionTreeWidgetItem.end()) return; // option exist
1064 row = getNewQTreeWidgetItem(table, option, name, isCustom);
1069 row = getNewQTreeWidgetItem(table, option, name, isCustom);
1071 row->setText( 0, tr( name.toLatin1().constData() ));
1072 row->setText( 1, tr( value.toLatin1().constData() ));
1073 row->setCheckState( 0, isDefault ? Qt::Unchecked : Qt::Checked);
1074 row->setData( NAME_COL, PARAM_NAME, name );
1078 myOptionTable->scrollToItem( row );
1079 myOptionTable->setCurrentItem( row );
1080 myOptionTable->editItem( row, NAME_COL );
1084 QTreeWidgetItem* MgAdaptAdvWidget::getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom)
1086 QTreeWidgetItem* row = new QTreeWidgetItem( table );
1087 row->setData( NAME_COL, EDITABLE_ROLE, int( isCustom && !option ));
1088 row->setFlags( row->flags() | Qt::ItemIsEditable );
1089 optionTreeWidgetItem.insert(std::pair <QString, QTreeWidgetItem*> (name, row));
1094 void MgAdaptAdvWidget::onAddOption()
1096 AddOption( NULL, true );
1098 void MgAdaptAdvWidget::GetOptionAndValue( QTreeWidgetItem * tblRow,
1103 option = tblRow->data( NAME_COL, PARAM_NAME ).toString();
1104 value = tblRow->text( VALUE_COL );
1105 isDefault = ! tblRow->checkState( NAME_COL );
1109 void MgAdaptAdvWidget::itemChanged(QTreeWidgetItem* tblRow, int column)
1113 myOptionTable->blockSignals( true );
1115 tblRow->setData( VALUE_COL, EDITABLE_ROLE, int( tblRow->checkState( NAME_COL )));
1117 int c = tblRow->checkState( NAME_COL ) ? 0 : 150;
1118 tblRow->setForeground( VALUE_COL, QBrush( QColor( c, c, c )));
1120 if ( column == NAME_COL && tblRow->data( NAME_COL, EDITABLE_ROLE ).toInt() ) // custom table
1122 tblRow->setData( NAME_COL, PARAM_NAME, tblRow->text( NAME_COL ));
1125 myOptionTable->blockSignals( false );
1128 void MgAdaptAdvWidget::setupWidget()
1130 if (this->objectName().isEmpty())
1131 this->setObjectName(QString(tr("MG-ADAPT-ADV")));
1132 this->resize(337, 369);
1133 gridLayout_4 = new QGridLayout(this);
1134 gridLayout_4->setObjectName(QString("gridLayout_4"));
1135 myOptionTable = new MgAdaptAdvWidgetTreeWidget(this);
1137 font.setBold(false);
1139 QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem();
1140 __qtreewidgetitem->setFont(1, font);
1141 __qtreewidgetitem->setFont(0, font);
1142 __qtreewidgetitem->setText(1, tr("OPTION_VALUE_COLUMN"));
1143 __qtreewidgetitem->setText(0, tr("OPTION_NAME_COLUMN"));
1144 myOptionTable->setHeaderItem(__qtreewidgetitem);
1145 myOptionTable->setObjectName(QString("myOptionTable"));
1146 myOptionTable->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
1147 myOptionTable->setTabKeyNavigation(true);
1149 gridLayout_4->addWidget(myOptionTable, 0, 0, 1, 2);
1151 addBtn = new QPushButton(this);
1152 addBtn->setText(QApplication::translate("SMESH_AdvOptionsWdg", "ADD_OPTION_BTN", Q_NULLPTR));
1153 addBtn->setObjectName(QString("addBtn"));
1155 gridLayout_4->addWidget(addBtn, 1, 0, 1, 1);
1157 horizontalSpacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
1159 gridLayout_4->addItem(horizontalSpacer, 1, 1, 1, 1);
1161 logGroupBox = new QGroupBox(this);
1162 logGroupBox->setObjectName(QString("logGroupBox"));
1163 gridLayout_2 = new QGridLayout(logGroupBox);
1164 gridLayout_2->setObjectName(QString("gridLayout_2"));
1165 gridLayout = new QGridLayout();
1166 gridLayout->setObjectName(QString("gridLayout"));
1167 workingDirectoryLabel = new QLabel(logGroupBox);
1168 workingDirectoryLabel->setObjectName(QString("workingDirectoryLabel"));
1170 gridLayout->addWidget(workingDirectoryLabel, 0, 0, 1, 1);
1172 workingDirectoryLineEdit = new QLineEdit(logGroupBox);
1173 workingDirectoryLineEdit->setObjectName(QString("workingDirectoryLineEdit"));
1175 gridLayout->addWidget(workingDirectoryLineEdit, 0, 1, 1, 1);
1177 workingDirectoryPushButton = new QPushButton(logGroupBox);
1178 workingDirectoryPushButton->setObjectName(QString("workingDirectoryPushButton"));
1180 gridLayout->addWidget(workingDirectoryPushButton, 0, 2, 1, 1);
1182 verboseLevelLabel = new QLabel(logGroupBox);
1183 verboseLevelLabel->setObjectName(QString("verboseLevelLabel"));
1185 gridLayout->addWidget(verboseLevelLabel, 1, 0, 1, 1);
1187 verboseLevelSpin = new QSpinBox(logGroupBox);
1188 verboseLevelSpin->setObjectName(QString("verboseLevelSpin"));
1190 gridLayout->addWidget(verboseLevelSpin, 1, 1, 1, 1);
1193 gridLayout_2->addLayout(gridLayout, 0, 0, 1, 1);
1195 horizontalLayout = new QHBoxLayout();
1196 horizontalLayout->setObjectName(QString("horizontalLayout"));
1197 logInFileCheck = new QCheckBox(logGroupBox);
1198 logInFileCheck->setObjectName(QString("logInFileCheck"));
1199 logInFileCheck->setChecked(true);
1201 horizontalLayout->addWidget(logInFileCheck);
1203 removeLogOnSuccessCheck = new QCheckBox(logGroupBox);
1204 removeLogOnSuccessCheck->setObjectName(QString("removeLogOnSuccessCheck"));
1205 removeLogOnSuccessCheck->setChecked(true);
1207 horizontalLayout->addWidget(removeLogOnSuccessCheck);
1210 gridLayout_2->addLayout(horizontalLayout, 1, 0, 1, 1);
1212 keepWorkingFilesCheck = new QCheckBox(logGroupBox);
1213 keepWorkingFilesCheck->setObjectName(QString("keepWorkingFilesCheck"));
1214 keepWorkingFilesCheck->setAutoExclusive(false);
1216 gridLayout_2->addWidget(keepWorkingFilesCheck, 2, 0, 1, 1);
1219 gridLayout_4->addWidget(logGroupBox, 3, 0, 1, 2);
1222 void MgAdaptAdvWidget::_onWorkingDirectoryPushButton()
1224 QString aDirName=QFileDialog::getExistingDirectory ();
1225 if (!(aDirName.isEmpty()))workingDirectoryLineEdit->setText(aDirName);
1227 void MgAdaptAdvWidget::onMeshDimChanged(ADAPTATION_MODE aMode)
1229 /* default adaptation mode
1230 * assume that if meshDim == 2 and no 3D backgrounmesh-->adaptation surface
1231 * if meshDim == 3 and if there is not 2D mesh -->VOLUME
1235 QString adaptation("adaptation"), value;
1238 case ADAPTATION_MODE::SURFACE:
1241 setOptionValue(adaptation, value);
1244 case ADAPTATION_MODE::BOTH :
1247 setOptionValue(adaptation, value);
1250 case ADAPTATION_MODE::VOLUME :
1253 setOptionValue(adaptation, value);
1258 void MgAdaptAdvWidget::setOptionValue(QString& option, QString& value)
1260 std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(option);
1261 if (it != optionTreeWidgetItem.end())
1263 it->second->setText( 0, tr( option.toLatin1().constData() ));
1264 it->second->setText( 1, tr( value.toLatin1().constData() ));
1265 it->second->setCheckState( 0, Qt::Checked );
1266 it->second->setData( NAME_COL, PARAM_NAME, option );
1267 myOptionTable->editItem( it->second, NAME_COL );
1272 bool isEditable( const QModelIndex& index )
1274 return index.isValid() &&
1275 index.flags() & Qt::ItemIsEditable &&
1276 index.flags() & Qt::ItemIsEnabled &&
1277 ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 );
1281 MgAdaptAdvWidgetTreeWidget::MgAdaptAdvWidgetTreeWidget( QWidget* parent )
1282 : QTreeWidget( parent )
1286 QModelIndex MgAdaptAdvWidgetTreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers )
1288 QModelIndex current = currentIndex();
1289 int column = current.column();
1290 if ( action == MoveNext )
1292 if ( column < columnCount()-1 )
1294 QModelIndex next = current.sibling( current.row(), column+1 );
1295 if ( isEditable( next ) ) return next;
1299 QModelIndex next = current.sibling( current.row()+1, 0 );
1300 if ( isEditable( next ) ) return next;
1303 else if ( action == MovePrevious )
1305 if ( column == 0 ) {
1306 QModelIndex next = current.sibling( current.row()-1, columnCount()-1 );
1307 if ( isEditable( next ) ) return next;
1310 QModelIndex next = current.sibling( current.row(), column-1 );
1311 if ( isEditable( next ) ) return next;
1314 return QTreeWidget::moveCursor( action, modifiers );
1317 void MgAdaptAdvWidgetTreeWidget::keyPressEvent( QKeyEvent* e )
1323 QModelIndex index = currentIndex();
1324 if ( !isEditable( index ) ) {
1325 for ( int i = 0; i < columnCount(); i++ ) {
1326 QModelIndex sibling = index.sibling( index.row(), i );
1327 if ( isEditable( sibling ) ) {
1328 if ( !edit( sibling, EditKeyPressed, e ) ) e->ignore();
1337 QTreeWidget::keyPressEvent( e );