]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
LCM // Import/Export of SHP p.4
authorisn <isn@opencascade.com>
Mon, 2 Nov 2015 14:41:23 +0000 (17:41 +0300)
committerisn <isn@opencascade.com>
Mon, 2 Nov 2015 18:48:31 +0000 (21:48 +0300)
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Document.h
src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx
src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.h
src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
src/HYDROGUI/HYDROGUI_Wizard.cxx
src/HYDROGUI/HYDROGUI_Wizard.h

index 93457716225fdd41c6166418d181343bae9f0950..011808682c7ee7ac9010546e52b7a91ca4acfe71 100644 (file)
@@ -21,6 +21,8 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Tool.h>
 #include <HYDROData_InterpolatorsFactory.h>
+#include <HYDROData_StricklerTable.h>
+#include <HYDROData_LandCoverMap.h>
 
 #include <TDataStd_Real.hxx>
 #include <TDataStd_Integer.hxx>
@@ -33,6 +35,7 @@
 #include <QFile>
 #include <QStringList>
 #include <QTextStream>
+#include <QColor>
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Document,MMgt_TShared)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Document,MMgt_TShared)
@@ -868,3 +871,19 @@ NCollection_Sequence<TCollection_AsciiString> HYDROData_Document::GetInterpolato
 
   return aNames;
 }
+
+QColor HYDROData_Document::GetAssociatedColor(const QString& theStricklerType, 
+  const Handle(HYDROData_StricklerTable)& theTable)
+{
+  if( !theTable.IsNull() && theTable->HasType( theStricklerType ) )
+    return theTable->GetColor( theStricklerType );
+
+  HYDROData_Iterator anIt( this, KIND_STRICKLER_TABLE );
+  for( ; anIt.More(); anIt.Next() )
+  {
+    Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
+    if( aTable->HasType( theStricklerType ) )
+      return aTable->GetColor( theStricklerType );
+  }
+  return QColor();
+}
\ No newline at end of file
index 6f3c82290ac73cc38fe756f4be00667bc68b58d8..910e318fdacc4622e9e8fb555bb1290a58e00134 100644 (file)
@@ -24,6 +24,8 @@
 
 class HYDROData_InterpolatorsFactory;
 class HYDROData_IProfilesInterpolator;
+class Handle(HYDROData_StricklerTable);
+class Handle(HYDROData_LandCoverMap);
 
 class QFile;
 class gp_Pnt2d;
@@ -223,6 +225,9 @@ public:
   //! Sets default strickler coefficient
   HYDRODATA_EXPORT void SetDefaultStricklerCoefficient( double ) const;
 
+  HYDRODATA_EXPORT QColor HYDROData_Document::GetAssociatedColor(const QString& theStricklerType, 
+  const Handle(HYDROData_StricklerTable)& theTable);
+
 protected:
   friend class HYDROData_Iterator;
   friend class test_HYDROData_Document;
index 40add2d825d6d226635243fc0383b7eda33f5c56..6b96578ccf18eaf9cc33234c64f1d0eb697a0d81 100644 (file)
@@ -35,6 +35,9 @@
 #include <QHeaderView>
 #include <QComboBox>
 #include <QStackedWidget>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+#include <QSignalMapper>
 
 HYDROGUI_ImportLandCoverMapDlg::HYDROGUI_ImportLandCoverMapDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_Wizard( theModule, theTitle )
@@ -67,7 +70,7 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
   aFileNameLayout->addWidget( aFileNameLabel );
   aFileNameLayout->addWidget( myFileName );
   aFileNameLayout->addWidget( aBrowseBtn );
-
+    
   myObjectNameGroup = new QGroupBox( tr( "LANDCOVERMAP_NAME" ) );
 
   QLabel* aLandcoverNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
@@ -90,11 +93,15 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
   aPolygonsLayout->addWidget( myPolygons );
   aPolygonsGroup->setLayout( aPolygonsLayout );
 
-  // Layout
   QVBoxLayout* aPageLayout = new QVBoxLayout;
+  myAttrCheckBox = new QCheckBox( "Use dBase attributes as a Strickler Types" ); //TODO replace with tr()
+  myAttrCheckBox->setChecked(true);
+
+  // Layout
   aPageLayout->setMargin( 5 );
   aPageLayout->setSpacing( 5 );
   aPageLayout->addWidget( myFileNameGroup );
+  aPageLayout->addWidget( myAttrCheckBox );
   aPageLayout->addWidget( myObjectNameGroup );
   aPageLayout->addWidget( aPolygonsGroup );
   aPage->setLayout( aPageLayout );
@@ -102,6 +109,7 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
   // Conections
   connect( myPolygons, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
   connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); 
+  connect( myAttrCheckBox, SIGNAL(clicked(bool)), this, SLOT(onAttrCBChecked(bool)));
 
   return aPage;
 }
@@ -110,17 +118,10 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage2() {
   QWizardPage* aPage = new QWizardPage( mainFrame() );
   QFrame* aFrame = new QFrame( aPage );
 
-  myAttrNameGroup = new QGroupBox( "Available attributes" );
-  QCheckBox* anAttrCheckBox = new QCheckBox( "Use dBase attributes as a Strickler Types", myAttrNameGroup );
-
-  QBoxLayout* aFileNameLayout = new QHBoxLayout( myAttrNameGroup );
-  aFileNameLayout->setMargin( 5 );
-  aFileNameLayout->setSpacing( 5 );
-  aFileNameLayout->addWidget( anAttrCheckBox );
-
-
-  myDBFAttr = new QListWidget( aPage );
+  myAvAttrLabel = new QLabel();
+  myAvAttrLabel->setText("Available attributes");
+  
+  myDBFAttr = new QListWidget( );
   myDBFAttr->setSelectionMode( QListWidget::SingleSelection );
   myDBFAttr->setEditTriggers( QListWidget::NoEditTriggers );
   myDBFAttr->setViewMode( QListWidget::ListMode );
@@ -130,9 +131,10 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage2() {
   QVBoxLayout* aPageLayout = new QVBoxLayout;
   aPageLayout->setMargin( 5 );
   aPageLayout->setSpacing( 5 );
-  aPageLayout->addWidget( myAttrNameGroup );
+  aPageLayout->addWidget( myAvAttrLabel );
   aPageLayout->addWidget( myDBFAttr );
   aPage->setLayout( aPageLayout );
+
   return aPage;
 }
 
@@ -259,14 +261,24 @@ QString HYDROGUI_ImportLandCoverMapDlg::getFileName() const
 }
 
 
-void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstColumn, const QStringList& theSecondColumn)
+void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstColumn, 
+                                                   const QStringList& theSecondColumn,
+                                                   const QVector<QColor> theColors)
 {
   int FCSize = theFirstColumn.size();
   int SCSize = theSecondColumn.size();
-  myTableW->setRowCount(FCSize);
-  myTableW->setColumnCount(2);
 
+  myStrColors = theColors;
+
+  myTableW->setRowCount(FCSize);
+  myTableW->setColumnCount(3);
+  QTableWidgetItem* Header_1 = new QTableWidgetItem(QString("Attribute"), QTableWidgetItem::Type);
+  QTableWidgetItem* Header_2 = new QTableWidgetItem(QString("Strickler Type"), QTableWidgetItem::Type);
+  QTableWidgetItem* Header_3 = new QTableWidgetItem(QString("Color"), QTableWidgetItem::Type);
+  myTableW->setHorizontalHeaderItem(0, Header_1);
+  myTableW->setHorizontalHeaderItem(1, Header_2);
+  myTableW->setHorizontalHeaderItem(2, Header_3);
+  //
   for (int i = 0; i < FCSize; i++)
   {
     QTableWidgetItem* aTWI = new QTableWidgetItem();
@@ -274,13 +286,25 @@ void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstCo
     aTWI->setFlags(Qt::ItemIsUserCheckable);
     myTableW->setItem(i, 0, aTWI);
   }
-  
+  //
+  QSignalMapper* signalMap = new QSignalMapper();
   for (int i = 0; i < FCSize; i++)
   {
     QComboBox* aCB = new QComboBox();
+    connect(aCB, SIGNAL(currentIndexChanged(int)), signalMap, SLOT(map()));
+    signalMap->setMapping(aCB, i);
     aCB->addItems(theSecondColumn);
     myTableW->setCellWidget(i, 1, aCB);
   }
+  connect(signalMap, SIGNAL(mapped(int)), this, SLOT(OnComboBoxColorChanged(int)));
+  //
+  for (int i = 0; i < FCSize; i++)
+  {
+    myTableW->setItem(i, 2, new QTableWidgetItem);
+    //take the first color from array; this color corresponds to the first item in the combo box
+    myTableW->item(i, 2)->setBackground(myStrColors[0]);
+  }
+
 }
 
 QString HYDROGUI_ImportLandCoverMapDlg::getSelectedFieldName() const
@@ -302,12 +326,20 @@ bool HYDROGUI_ImportLandCoverMapDlg::acceptCurrent() const
     case 0:
     {
       if (!myFirstPageState)
+      {
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "File isn't chosen");
+        return false;
+      }
+      if (myPolygons->selectedItems().empty())
+      {
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "Polygons isn't selected");
         return false;
+      }
       break;
     }
     case 1:
     {
-      if (this->myDBFAttr->selectedItems().empty())
+      if (myDBFAttr->selectedItems().empty())
         return false;
       break;
     }
@@ -346,4 +378,24 @@ QVector<int> HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonIndices() const
   }
 
   return aSelectedIndices;
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::onAttrCBChecked( bool theState )
+{
+  if (theState)
+    SetButtonsState ( false );
+  else
+    SetButtonsState ( true );
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::getAttrCheckBoxState() const
+{
+  return myAttrCheckBox->isChecked();
+}
+
+void HYDROGUI_ImportLandCoverMapDlg::OnComboBoxColorChanged(int theInd)
+{
+  QComboBox* CB = qobject_cast<QComboBox *> (myTableW->cellWidget(theInd, 1));
+  int CurIndOfCB = CB->currentIndex();
+  myTableW->item(theInd, 2)->setBackground(myStrColors[CurIndOfCB]);
 }
\ No newline at end of file
index 6030b8adf3765603bf661c743fa9f3dc11359cc1..68cbaa6a87dc51fd260a4a93d277b0937b2fdf15 100644 (file)
@@ -29,6 +29,7 @@ class QGroupBox;
 class QComboBox;
 class QLabel;
 class QTableWidget;
+class QCheckBox;
 
 
 class HYDROGUI_ImportLandCoverMapDlg : public HYDROGUI_Wizard
@@ -48,7 +49,9 @@ public:
 
   void                  setAttributeNames( const QStringList& theAttrNames );
 
-  void                  FillCorrTable(const QStringList& theFirstColumn, const QStringList& theSecondColumn);
+  void                  FillCorrTable(const QStringList& theFirstColumn, 
+                                      const QStringList& theSecondColumn,
+                                      const QVector<QColor> theColors);
 
   QStringList           getSelectedPolygonNames() const;
   QString               getSelectedFieldName() const;
@@ -60,7 +63,7 @@ public:
   QString               getFileName() const;
 
   void                  setFirstPageState(bool bState);
-  //void                  setThirdPageState(bool bState);
+  bool                  getAttrCheckBoxState() const;
   void                  GetAttribute2StricklerCorr(QStringList& AttrValues, QStringList& ST);
   QVector<int>          getSelectedPolygonIndices() const;
 
@@ -71,6 +74,8 @@ signals:
 protected slots:
   void                  onBrowse();
   void                  onItemSelectionChanged();
+  void                  onAttrCBChecked(bool theState);
+  void                  OnComboBoxColorChanged(int theInd);
 
 protected:
   bool                  acceptCurrent() const;
@@ -85,23 +90,22 @@ private:
   QLineEdit*            myFileName; 
   QGroupBox*            myFileNameGroup;
   QListWidget*          myPolygons;    
-
   QGroupBox*            myObjectNameGroup;
   QLineEdit*            myObjectName;
+  QCheckBox*            myAttrCheckBox;
 
-  //second page
-  QGroupBox*            myAttrNameGroup;
+  //Second page
   QListWidget*          myDBFAttr; 
-  QGroupBox*            myCorrNameGroup;
+  QLabel*               myAvAttrLabel;
 
-  //third page
+  //Third page
   QLabel*               myCLabel;
   QTableWidget*         myTableW;
 
-  //State of pages
+  //State of the first page
   bool                  myFirstPageState;
-  //bool                  myThirdPageState;
 
+  QVector<QColor>       myStrColors;
 };
 
 #endif
index e8303bac36a5df471c005c7fa7e9918e55f1ef38..d410018fb9d69426e6c65c38e2c31dd94ee5b922 100644 (file)
 
 #include <HYDROData_LandCoverMap.h>
 
-
-//TODO deny to create null-LCM (selected poltgons on the first page = 0)
-//TODO erase onBack/onFinish if not needed...
-
+//TODO add definitions into TS file
 HYDROGUI_ImportLandCoverMapOp::HYDROGUI_ImportLandCoverMapOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule )
 {
@@ -219,12 +216,8 @@ HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverMapOp::createInputPanel() const
   HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportLandCoverMapDlg( module(), getName() );
 
   connect( aPanel, SIGNAL( FileSelected( const QString& ) ), SLOT( onFileSelected() ) );
-
   connect( aPanel, SIGNAL( selectionChanged( const QStringList& ) ), this, SLOT( onSelectionChanged( const QStringList& ) ) );
-
   connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
-  connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onBack( const int ) ) );
-  connect( aPanel, SIGNAL( Finish( const int ) ), SLOT( onFinish( const int ) ) );
     
   return aPanel;
 }
@@ -233,28 +226,15 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
                                                 QString& theErrorMsg,
                                                 QStringList& theBrowseObjectsEntries )
 {
-  //TODO rewrite this!
+
   HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
   if ( !aPanel ) {
     return false;
   }
 
   Handle(HYDROData_LandCoverMap) aLCM =  Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) );
-   
   HYDROData_MapOfFaceToStricklerType aMapFace2ST;
 
-  /*QStringList aSelectedPolygons = aPanel->getSelectedPolygonNames();
-  aPanel->removePolygonNames( aSelectedPolygons );
-    
-  foreach ( QString aName, aSelectedPolygons )
-  {
-    TopoDS_Shape aShape = myPolygonName2PrsShape.value( aName )->getTopoShape();
-    if ( aShape.IsNull() ) 
-      continue;
-    aMapFace2ST.Add( TopoDS::Face( aShape ), "TODO temp" ); //TODO get from tableW
-    HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aName );
-    delete aShapeToDelete;
-  }*/
   QStringList aAttrV_T;
   QStringList aSTL;
   aPanel->GetAttribute2StricklerCorr(aAttrV_T, aSTL);
@@ -265,24 +245,30 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
     TopoDS_Shape aShape = myPolygonFaces(Ind + 1);
     if ( aShape.IsNull() ) 
       continue;
-    HYDROData_ShapeFile::DBF_AttrValue aV = myAttrV[Ind];
-    int StricklerTypesInd = aAttrV_T.indexOf(QString(aV.myStrVal));
-      QString aST = aSTL.at(StricklerTypesInd);
+    QString aST = "";
+    if (aPanel->getAttrCheckBoxState())
+    {
+      HYDROData_ShapeFile::DBF_AttrValue aV = myAttrV[Ind];
+      int StricklerTypesInd = aAttrV_T.indexOf(QString(aV.myStrVal));
+      aST = aSTL.at(StricklerTypesInd);
+    }
+    // else => ST is empty
     aMapFace2ST.Add( TopoDS::Face( aShape ), aST ); //TODO get from tableW
-    //HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aName );
-    //delete aShapeToDelete;
   }
 
   //
   aLCM->StoreLandCovers(aMapFace2ST);
 
+  QString ObjName;
+  if ( !aPanel->getFileName().isEmpty() )
+    ObjName = aPanel->getObjectName();
+
   if( !aLCM.IsNull() ) 
   {
-    aLCM->SetName( "temp_name" );
-    aLCM->SetColor( QColor(0,100,100) );
+    aLCM->SetName( ObjName );
+    aLCM->SetColor( Qt::gray );
     aLCM->Show();
     module()->setIsToUpdate( aLCM );
-    
   }
   
   module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
@@ -312,14 +298,8 @@ void HYDROGUI_ImportLandCoverMapOp::onSelectionChanged( const QStringList& theSe
 
       bool isSelected = theSelectedNames.contains( aName );
       if ( ( isSelected && !aCtx->IsSelected( anObject) ) ||
-           ( !isSelected && aCtx->IsSelected( anObject) ) ) {
+           ( !isSelected && aCtx->IsSelected( anObject) ) )
         aCtx->AddOrRemoveSelected( anObject, Standard_False );
-      }
-      /*if (isSelected)
-      {
-        HYDROGUI_Shape* aHydroSh = myPolygonName2PrsShape.value( aName );
-        aHydroSh->setFillingColor(QColor(0,255,255), true, true);
-      }*/
     }
     aCtx->UpdateCurrentViewer();
   }
@@ -328,7 +308,6 @@ void HYDROGUI_ImportLandCoverMapOp::onSelectionChanged( const QStringList& theSe
 
 void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged()
 {
-  // Get panel
   HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
   if ( !aPanel ) {
     return;
@@ -347,9 +326,8 @@ void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged()
     QStringList aSelectedNames;
     foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
       bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() );
-      if ( isSelected ) {
+      if ( isSelected )
         aSelectedNames << aName;
-      }
     }
     aPanel->setSelectedPolygonNames( aSelectedNames );
   }
@@ -378,10 +356,8 @@ void HYDROGUI_ImportLandCoverMapOp::abortOperation()
   HYDROGUI_Operation::abortOperation();
 }
 
-//TODO take "Use dbf attrs as ST.." into account
 void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex )
 {  
-  //TODO add acceptor
   HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
   if ( !aPanel )
     return;
@@ -434,19 +410,24 @@ void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex )
         }
       }
     }
-    aPanel->FillCorrTable(mySetOfAttrValues.toList(), aSTSet.toList());
+    QList<QString> SetOfAttrValuesList = mySetOfAttrValues.toList();
+    QList<QString> aSTSetList = aSTSet.toList();
+    QVector<QColor> STColors;
+    STColors.reserve(aSTSetList.size());
+    foreach (QString str, aSTSetList)
+    {
+      QColor col = aDoc->GetAssociatedColor(str, NULL);
+      STColors.append (col);
+    }
+
+    aPanel->FillCorrTable(SetOfAttrValuesList, aSTSetList, STColors);
   }
 
 }
 
-void HYDROGUI_ImportLandCoverMapOp::onBack( const int theIndex )
-{
-
-}
 
 void HYDROGUI_ImportLandCoverMapOp::onApply()
 {
-
   QApplication::setOverrideCursor( Qt::WaitCursor );
   int anUpdateFlags = 0;
   QString anErrorMsg;
@@ -459,6 +440,7 @@ void HYDROGUI_ImportLandCoverMapOp::onApply()
   }
   catch (...)
   {
+    SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "LCM_IMPORT_ERROR" ), "Cant import choosed polygons");
     aResult = false;
   }
   
index 1a525fc9b61cc6e5c4613b759c2e4d2da2944a37..d342380d15a73a39b8d2c5834d220f5e4047a35d 100644 (file)
@@ -58,8 +58,6 @@ protected slots:
   void onSelectionChanged( const QStringList& theSelectedNames );
   void onViewerSelectionChanged ();
   void onNext( const int theIndex );
-  void onBack( const int theIndex );
-
 
 private:
   QMap<QString, HYDROGUI_Shape*> myPolygonName2PrsShape;
index 6f654a6d1888563bfb0dad24030c19489d644d02..5e8a17f696910f1d83e181a2a12360e4faae775a 100644 (file)
@@ -116,24 +116,12 @@ Quantity_Color HYDROGUI_LandCoverMapPrs::GetColor( const QString& theStricklerTy
       return Quantity_Color();
   }
 
-  if( !myTable.IsNull() && myTable->HasType( theStricklerType ) )
-  {
-    QColor aColor = myTable->GetColor( theStricklerType );
-    return HYDROData_Tool::toOccColor( aColor );
-  }
+  QColor aColor = HYDROData_Document::Document( myLCMap->Label())->GetAssociatedColor(theStricklerType, myTable);
 
-  HYDROData_Iterator anIt( HYDROData_Document::Document( myLCMap->Label() ), KIND_STRICKLER_TABLE );
-  for( ; anIt.More(); anIt.Next() )
-  {
-    Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
-    if( aTable->HasType( theStricklerType ) )
-    {
-      QColor aColor = aTable->GetColor( theStricklerType );
-      return HYDROData_Tool::toOccColor( aColor );
-    }
-  }
-
-  return Quantity_Color();
+  if (aColor.isValid())
+    return HYDROData_Tool::toOccColor(aColor);
+  else
+    return Quantity_Color();
 }
 
 void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
index fd393ae53870eab2bcc655a17e83c4ed76a3e878..7ad59940233f81c734ac11014124b0197d77cbe9 100644 (file)
@@ -69,8 +69,9 @@ int HYDROGUI_Wizard::addPage( QWizardPage* thePage )
 {
   if ( myWizard->count() > 0 )
   {
-    myNext->setVisible( true );
-    myFinish->setVisible( false );
+    SetButtonsState(false);
+    /*myNext->setVisible( true );
+    myFinish->setVisible( false );*/
   }
   return myWizard->addWidget( thePage );
 }
@@ -85,11 +86,12 @@ void HYDROGUI_Wizard::onNext()
 
   myBack->setEnabled( true );
   int aCurIdx = myWizard->currentIndex();
-  if ( aCurIdx == ( myWizard->count() - 2 ) )
+  if ( IsLastPage() )
   {
     // Go to the last page
-    myNext->setVisible( false );
-    myFinish->setVisible( true );
+    SetButtonsState( true );
+    /*myNext->setVisible( false );
+    myFinish->setVisible( true );*/
   }
   myWizard->setCurrentIndex( aCurIdx + 1 );
 
@@ -103,14 +105,16 @@ void HYDROGUI_Wizard::onBack()
 
   if ( myWizard->count() > 1 )
   {
-    myNext->setVisible( true );
-    myFinish->setVisible( false );
+    /*myNext->setVisible( true );
+    myFinish->setVisible( false );*/
+    SetButtonsState( false );
   }
   else
   {
     // Wizard has a single page - show finish
-    myNext->setVisible( false );
-    myFinish->setVisible( true );
+    SetButtonsState( true );
+    /*myNext->setVisible( false );
+    myFinish->setVisible( true );*/
   }
 
   int aCurIdx = myWizard->currentIndex();
@@ -129,8 +133,9 @@ void HYDROGUI_Wizard::onBack()
 void HYDROGUI_Wizard::onFirstPage()
 {
   if ( myWizard->count() > 1 ) {
-    myNext->setVisible( true );
-    myFinish->setVisible( false );
+    /*myNext->setVisible( true );
+    myFinish->setVisible( false );*/
+    SetButtonsState( false );
     myWizard->setCurrentIndex( 0 );
     myBack->setEnabled( false );
     emit Back( myWizard->currentIndex() );
@@ -163,4 +168,26 @@ QAbstractButton* HYDROGUI_Wizard::button( QWizard::WizardButton theBtnId ) const
       aRes = myHelp;
   }
   return aRes;
+}
+
+bool HYDROGUI_Wizard::IsLastPage()
+{
+  if ( myWizard->currentIndex() == ( myWizard->count() - 2 ))
+    return true;
+  else
+    return false;
+}
+
+void HYDROGUI_Wizard::SetButtonsState (bool IsLastPage)
+{
+  if (!IsLastPage)
+  {
+    myNext->setVisible( true );
+    myFinish->setVisible( false );
+  }
+  else
+  {
+    myNext->setVisible( false );
+    myFinish->setVisible( true );
+  }
 }
\ No newline at end of file
index c0a8855143d1c14d024a8636a432c552262b02df..8269950c1624932052583bbfdc8e8c11d39301e2 100644 (file)
@@ -56,6 +56,10 @@ protected:
   // Reimplement this method in your subclass to verify user input data.
   virtual bool    acceptCurrent() const;
 
+  virtual bool    IsLastPage();
+
+  void            SetButtonsState (bool IsLastPage);
+
 private:
   QStackedWidget* myWizard;
   QPushButton*    myNext;