From 11ec2af6a8049f50cdd7b8f53da49f813b5d2c8f Mon Sep 17 00:00:00 2001 From: adv Date: Mon, 23 Sep 2013 13:01:34 +0000 Subject: [PATCH] GUI updated to new format of domains. --- src/HYDROGUI/HYDROGUI_CalculationDlg.cxx | 40 +++--- src/HYDROGUI/HYDROGUI_CalculationDlg.h | 6 +- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 157 +++++++++------------- src/HYDROGUI/HYDROGUI_CalculationOp.h | 17 ++- src/HYDROGUI/HYDROGUI_DataModel.cxx | 17 +-- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 20 +-- 6 files changed, 110 insertions(+), 147 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 90869a48..57e38659 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -73,10 +73,10 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co myZones->setEditTriggers( QListWidget::NoEditTriggers ); myZones->setViewMode( QListWidget::ListMode ); - mySplittedZones = new QListWidget( aZonesGroup ); - mySplittedZones->setSelectionMode( QListWidget::SingleSelection ); - mySplittedZones->setEditTriggers( QListWidget::NoEditTriggers ); - mySplittedZones->setViewMode( QListWidget::ListMode ); + myRegions = new QListWidget( aZonesGroup ); + myRegions->setSelectionMode( QListWidget::SingleSelection ); + myRegions->setEditTriggers( QListWidget::NoEditTriggers ); + myRegions->setViewMode( QListWidget::ListMode ); mySplittedZonesPrefix = new QLineEdit( aZonesGroup ); @@ -87,9 +87,9 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co aZonesLayout->setSpacing( 5 ); aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REFERENCE_ZONES" ), aZonesGroup ), 0, 0, 1, 2 ); aZonesLayout->addWidget( myZones, 1, 0, 1, 2 ); - aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_SPLITTED_ZONES" ), aZonesGroup ), 2, 0, 1, 2 ); - aZonesLayout->addWidget( mySplittedZones, 3, 0, 1, 2 ); - aZonesLayout->addWidget( new QLabel( tr( "PREFIX_SPLITTED_ZONES" ), aZonesGroup ), 4, 0 ); + aZonesLayout->addWidget( new QLabel( tr( "CALCULATION_REGIONS" ), aZonesGroup ), 2, 0, 1, 2 ); + aZonesLayout->addWidget( myRegions, 3, 0, 1, 2 ); + aZonesLayout->addWidget( new QLabel( tr( "PREFIX_REGIONS" ), aZonesGroup ), 4, 0 ); aZonesLayout->addWidget( mySplittedZonesPrefix, 4, 1 ); aZonesLayout->addWidget( aSplitBtn, 5, 0, 1, 2 ); @@ -115,9 +115,9 @@ void HYDROGUI_CalculationDlg::reset() myBndPolyline->Clear(); myZones->clear(); - mySplittedZones->clear(); + myRegions->clear(); - setSplitZonesPrefix( tr( "DEFAULT_PREFIX_SPLITTED_ZONES" ) ); + setSplitZonesPrefix( tr( "DEFAULT_PREFIX_REGIONS" ) ); } void HYDROGUI_CalculationDlg::setObjectName( const QString& theName ) @@ -190,31 +190,31 @@ QStringList HYDROGUI_CalculationDlg::getSelectedZones() const return aResList; } -void HYDROGUI_CalculationDlg::setSplittedZones( const QStringList& theZones ) +void HYDROGUI_CalculationDlg::setRegions( const QStringList& theRegions ) { - mySplittedZones->clear(); + myRegions->clear(); - for ( int i = 0, n = theZones.length(); i < n; ++i ) + for ( int i = 0, n = theRegions.length(); i < n; ++i ) { - QString aZoneName = theZones.at( i ); + QString aRegionName = theRegions.at( i ); - QListWidgetItem* aListItem = new QListWidgetItem( aZoneName, mySplittedZones ); + QListWidgetItem* aListItem = new QListWidgetItem( aRegionName, myRegions ); aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); } } -QStringList HYDROGUI_CalculationDlg::getSplittedZones() const +QStringList HYDROGUI_CalculationDlg::getRegions() const { QStringList aResList; - for ( int i = 0, n = mySplittedZones->count(); i < n; ++i ) + for ( int i = 0, n = myRegions->count(); i < n; ++i ) { - QListWidgetItem* aListItem = mySplittedZones->item( i ); + QListWidgetItem* aListItem = myRegions->item( i ); if ( !aListItem ) continue; - QString aSplittedZoneName = aListItem->text(); - aResList.append( aSplittedZoneName ); + QString aRegionName = aListItem->text(); + aResList.append( aRegionName ); } return aResList; @@ -229,7 +229,7 @@ QString HYDROGUI_CalculationDlg::getSplitZonesPrefix() const { QString aPrefix = mySplittedZonesPrefix->text(); if ( aPrefix.isEmpty() ) - aPrefix = tr( "DEFAULT_PREFIX_SPLITTED_ZONES" ); + aPrefix = tr( "DEFAULT_PREFIX_REGIONS" ); return aPrefix; } diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 742bbca9..c63fffa5 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -50,8 +50,8 @@ public: void setSelectedZones( const QStringList& theZones ); QStringList getSelectedZones() const; - void setSplittedZones( const QStringList& theZones ); - QStringList getSplittedZones() const; + void setRegions( const QStringList& theRegions ); + QStringList getRegions() const; void setSplitZonesPrefix( const QString& theName ); QString getSplitZonesPrefix() const; @@ -66,7 +66,7 @@ private: HYDROGUI_ObjSelector* myBndPolyline; QListWidget* myZones; - QListWidget* mySplittedZones; + QListWidget* myRegions; QLineEdit* mySplittedZonesPrefix; }; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 71082b7e..3e1a5dc8 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -63,12 +64,12 @@ void HYDROGUI_CalculationOp::startOperation() if ( !aPanel ) return; - mySplittedZones.clear(); + myRegionsList.clear(); aPanel->reset(); QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" ); - QStringList aSelectedZones, aSplittedZones; + QStringList aSelectedZones, aRegions; myEditedObject.Nullify(); if ( myIsEdit ) @@ -101,37 +102,33 @@ void HYDROGUI_CalculationOp::startOperation() aSelectedZones.append( aRefZoneName ); } - HYDROData_SequenceOfObjects aSplitZones = myEditedObject->GetSplittedZones(); - anIter.Init( aSplitZones ); + HYDROData_SequenceOfObjects aDataRegions = myEditedObject->GetRegions(); + anIter.Init( aDataRegions ); for ( ; anIter.More(); anIter.Next() ) { - Handle(HYDROData_Zone) aSplitZone = - Handle(HYDROData_Zone)::DownCast( anIter.Value() ); - if ( aSplitZone.IsNull() ) + Handle(HYDROData_Region) aDataRegion = + Handle(HYDROData_Region)::DownCast( anIter.Value() ); + if ( aDataRegion.IsNull() ) continue; - QString aSplitZoneName = aSplitZone->GetName(); - if ( aSplitZoneName.isEmpty() ) + QString aRegionName = aDataRegion->GetName(); + if ( aRegionName.isEmpty() ) continue; - SplittedZone aSplittedZone; - aSplittedZone.SplitData.Path = aSplitZone->GetPainterPath(); - // aSplittedZone.SplitData.ZoneNames ??? - - aSplittedZone.FillingColor = aSplitZone->GetFillingColor(); - aSplittedZone.BorderColor = aSplitZone->GetBorderColor(); + Region aRegion; + // aRegion.SplitData.Path = aSplitZone->GetPainterPath(); + // aRegion.SplitData.ZoneNames ??? - aSplittedZone.ZoneName = aSplitZoneName; + aRegion.FillingColor = aDataRegion->GetFillingColor(); + aRegion.BorderColor = aDataRegion->GetBorderColor(); - Handle(HYDROData_Polyline) aZonePolyline = aSplitZone->GetPolyline(); - if ( !aZonePolyline.IsNull() ) - aSplittedZone.PolylineName = aZonePolyline->GetName(); + aRegion.RegionName = aRegionName; - aSplittedZone.DataZone = aSplitZone; + aRegion.DataRegion = aDataRegion; - mySplittedZones.append( aSplittedZone ); + myRegionsList.append( aRegion ); - aSplittedZones.append( aSplitZoneName ); + aRegions.append( aRegionName ); } } } @@ -158,7 +155,7 @@ void HYDROGUI_CalculationOp::startOperation() aPanel->setZones( aZones ); aPanel->setSelectedZones( aSelectedZones ); - aPanel->setSplittedZones( aSplittedZones ); + aPanel->setRegions( aRegions ); createPreview(); } @@ -234,66 +231,34 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, aCalculObj->SetZones( aRefZones ); - HYDROData_SequenceOfObjects aSplittedZones; + HYDROData_SequenceOfObjects aRegions; - SplittedZonesList::iterator anIter = mySplittedZones.begin(); - for ( ; anIter != mySplittedZones.end(); ++anIter ) + RegionsList::iterator anIter = myRegionsList.begin(); + for ( ; anIter != myRegionsList.end(); ++anIter ) { - const SplittedZone& aSplittedZone = *anIter; + const Region& aRegion = *anIter; - if ( !aSplittedZone.DataZone.IsNull() ) + if ( !aRegion.DataRegion.IsNull() ) { //No need to create new but use old zone - aSplittedZones.Append( aSplittedZone.DataZone ); + aRegions.Append( aRegion.DataRegion ); continue; } - Handle(HYDROData_Polyline) aPolyline = - Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) ); - Handle(HYDROData_Zone) aDataZone = - Handle(HYDROData_Zone)::DownCast( aDocument->CreateObject( KIND_ZONE ) ); - - if( aPolyline.IsNull() || aDataZone.IsNull() ) + Handle(HYDROData_Region) aDataRegion = + Handle(HYDROData_Region)::DownCast( aDocument->CreateObject( KIND_REGION ) ); + if( aDataRegion.IsNull() ) continue; - // Fill the polyline data - aPolyline->SetName( aSplittedZone.PolylineName ); - aPolyline->setDimension( 2 ); - - QList aPolylineData; - for( int i = 0, n = aSplittedZone.SplitData.Path.elementCount(); i < n; i++ ) - { - const QPainterPath::Element anElement = aSplittedZone.SplitData.Path.elementAt( i ); - switch( anElement.type ) - { - case QPainterPath::MoveToElement: - aPolylineData.append( PolylineSection() ); - break; - case QPainterPath::LineToElement: - if( !aPolylineData.isEmpty() ) - { - PolylineSection& aSection = aPolylineData.last(); - aSection.myCoords << anElement.x; - aSection.myCoords << anElement.y; - } - break; - case QPainterPath::CurveToElement: // currently not supported - default: - break; - } - } - aPolyline->setPolylineData( aPolylineData ); - // Fill the zone data - aDataZone->SetName( aSplittedZone.ZoneName ); - aDataZone->SetPolyline( aPolyline ); - aDataZone->SetBorderColor( aSplittedZone.BorderColor ); - aDataZone->SetFillingColor( aSplittedZone.FillingColor ); + aDataRegion->SetName( aRegion.RegionName ); + aDataRegion->SetBorderColor( aRegion.BorderColor ); + aDataRegion->SetFillingColor( aRegion.FillingColor ); - aSplittedZones.Append( aDataZone ); + aRegions.Append( aDataRegion ); } - aCalculObj->SetSplittedZones( aSplittedZones ); + aCalculObj->SetRegions( aRegions ); theUpdateFlags = UF_Model; @@ -302,7 +267,7 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, void HYDROGUI_CalculationOp::onSplitZones() { - mySplittedZones.clear(); + myRegionsList.clear(); HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -330,24 +295,22 @@ void HYDROGUI_CalculationOp::onSplitZones() HYDROGUI_SplitZonesTool::SplitDataListIterator anIter( aSplittedZones ); while( anIter.hasNext() ) { - SplittedZone aSplittedZone; - aSplittedZone.SplitData = anIter.next(); + Region aRegion; + aRegion.SplitData = anIter.next(); - aSplittedZone.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aSplittedZone.SplitData.ZoneNames ); - aSplittedZone.BorderColor = QColor( HYDROData_Zone::DefaultBorderColor() ); + aRegion.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aRegion.SplitData.ZoneNames ); + aRegion.BorderColor = QColor( HYDROData_Zone::DefaultBorderColor() ); - aSplittedZone.ZoneName = HYDROGUI_Tool::GenerateObjectName( module(), aSplitZonesPrefix + "Zone", aUsedNames ); - aSplittedZone.PolylineName = HYDROGUI_Tool::GenerateObjectName( module(), aSplitZonesPrefix + "Poly", aUsedNames ); + aRegion.RegionName = HYDROGUI_Tool::GenerateObjectName( module(), aSplitZonesPrefix, aUsedNames ); - aUsedNames.append( aSplittedZone.ZoneName ); - aUsedNames.append( aSplittedZone.PolylineName ); + aUsedNames.append( aRegion.RegionName ); - aResSplittedZones.append( aSplittedZone.ZoneName ); + aResSplittedZones.append( aRegion.RegionName ); - mySplittedZones.append( aSplittedZone ); + myRegionsList.append( aRegion ); } - aPanel->setSplittedZones( aResSplittedZones ); + aPanel->setRegions( aResSplittedZones ); createPreview(); @@ -360,7 +323,7 @@ void HYDROGUI_CalculationOp::createPreview() if ( !myActiveViewManager ) { - if ( mySplittedZones.isEmpty() ) + if ( myRegionsList.isEmpty() ) return; myActiveViewManager = anApp->activeViewManager(); @@ -388,18 +351,18 @@ void HYDROGUI_CalculationOp::createPreview() Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if ( !aCtx.IsNull() ) { - SplittedZonesList::iterator anIter = mySplittedZones.begin(); - for ( ; anIter != mySplittedZones.end(); ++anIter ) + RegionsList::iterator anIter = myRegionsList.begin(); + for ( ; anIter != myRegionsList.end(); ++anIter ) { - SplittedZone& aSplittedZone = *anIter; - if ( aSplittedZone.Shape ) - delete aSplittedZone.Shape; + Region& aRegion = *anIter; + if ( aRegion.Shape ) + delete aRegion.Shape; - aSplittedZone.Shape = new HYDROGUI_Shape( aCtx ); + aRegion.Shape = new HYDROGUI_Shape( aCtx ); - aSplittedZone.Shape->setFillingColor( aSplittedZone.FillingColor, false ); - aSplittedZone.Shape->setBorderColor( aSplittedZone.BorderColor, false ); - aSplittedZone.Shape->setPath( aSplittedZone.SplitData.Path, true ); + aRegion.Shape->setFillingColor( aRegion.FillingColor, false ); + aRegion.Shape->setBorderColor( aRegion.BorderColor, false ); + aRegion.Shape->setPath( aRegion.SplitData.Path, true ); } //Process the draw events for viewer @@ -417,14 +380,14 @@ void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager void HYDROGUI_CalculationOp::closePreview() { - SplittedZonesList::iterator anIter= mySplittedZones.begin(); - for ( ; anIter != mySplittedZones.end(); ++anIter ) + RegionsList::iterator anIter= myRegionsList.begin(); + for ( ; anIter != myRegionsList.end(); ++anIter ) { - SplittedZone& aSplittedZone = *anIter; - if ( aSplittedZone.Shape ) + Region& aRegion = *anIter; + if ( aRegion.Shape ) { - delete aSplittedZone.Shape; - aSplittedZone.Shape = NULL; + delete aRegion.Shape; + aRegion.Shape = NULL; } } diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index bc58e6f5..17cebaff 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -29,7 +29,7 @@ #include "HYDROGUI_Shape.h" #include -#include +#include class SUIT_ViewManager; class OCCViewer_ViewManager; @@ -38,23 +38,22 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation { Q_OBJECT - struct SplittedZone + struct Region { - QString ZoneName; - QString PolylineName; + QString RegionName; QColor FillingColor; QColor BorderColor; HYDROGUI_SplitZonesTool::SplitData SplitData; HYDROGUI_Shape* Shape; - Handle(HYDROData_Zone) DataZone; + Handle(HYDROData_Region) DataRegion; - SplittedZone() + Region() : Shape( NULL ), FillingColor( Qt::green ), BorderColor( Qt::transparent ) { } - ~SplittedZone() + ~Region() { if ( Shape ) { @@ -64,7 +63,7 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation } }; - typedef QList SplittedZonesList; + typedef QList RegionsList; public: HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit ); @@ -94,7 +93,7 @@ private: SUIT_ViewManager* myActiveViewManager; OCCViewer_ViewManager* myPreviewViewManager; - SplittedZonesList mySplittedZones; + RegionsList myRegionsList; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index ef136fff..ba159238 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -618,17 +619,17 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, createObject( aRefZonesSect, aRefZone, aGuiObj->entry(), false ); } - LightApp_DataObject* aSplittedZonesSect = - createObject( aGuiObj, tr( "CASE_SPLITTED_ZONES" ), aGuiObj->entry() ); + LightApp_DataObject* aCaseRegionsSect = + createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() ); - HYDROData_SequenceOfObjects aSplittedZones = aCaseObj->GetSplittedZones(); - anIter.Init( aSplittedZones ); + HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions(); + anIter.Init( aCaseRegions ); for ( ; anIter.More(); anIter.Next() ) { - Handle(HYDROData_Zone) aSplittedZone = - Handle(HYDROData_Zone)::DownCast( anIter.Value() ); - if( !aSplittedZone.IsNull() && !aSplittedZone->IsRemoved() ) - createObject( aSplittedZonesSect, aSplittedZone, aGuiObj->entry(), false ); + Handle(HYDROData_Region) aCaseRegion = + Handle(HYDROData_Region)::DownCast( anIter.Value() ); + if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() ) + createObject( aCaseRegionsSect, aCaseRegion, aGuiObj->entry(), false ); } } } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 9aee684a..d25a7c59 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -16,8 +16,8 @@ Reference zones - CASE_SPLITTED_ZONES - Splitted zones + CASE_REGIONS + Regions FILE_NOT_EXISTS_OR_CANT_BE_READ @@ -85,25 +85,25 @@ does not exist or you have not enough permissions to open it. Reference zones - CALCULATION_SPLITTED_ZONES - Splitted zones - - - PREFIX_SPLITTED_ZONES - Prefix of splitted zones + CALCULATION_REGIONS + Regions CALCULATION_ZONES Case zones - DEFAULT_PREFIX_SPLITTED_ZONES - Split + DEFAULT_PREFIX_REGIONS + Region NAME Name + + PREFIX_REGIONS + Prefix for regions + SPLIT_REFERENCE_ZONES Split zones -- 2.39.2