+
+void HYDROGUI_ProfileDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
+{
+ myEditorWidget->setEnabled( false );
+
+ myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
+ QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
+ anAddElementLayout->addWidget( theWidget );
+
+ theWidget->show();
+ myAddElementBox->show();
+}
+
+void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget )
+{
+ myEditorWidget->setEnabled( true );
+
+ QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
+ anAddElementLayout->removeWidget( theWidget );
+
+ theWidget->hide();
+ myAddElementBox->hide();
+}
+
+void HYDROGUI_ProfileDlg::ProfileNameChanged(QString text)
+{
+ myCurrentName = text;
+}
+
+void HYDROGUI_ProfileDlg::onProfileIndexChanged()
+{
+ int theIndex = GetProfileSelectionIndex();
+ if (theIndex > -1)
+ SwitchToProfile(theIndex);
+}
+
+int HYDROGUI_ProfileDlg::GetProfileSelectionIndex()
+{
+ if (!myProfilesPointer)
+ return -1;
+ QModelIndexList MI = myProfileNames->selectionModel()->selectedIndexes();
+ if (MI.size() != 1)
+ return -1;
+ return MI.first().row();
+}
+
+void HYDROGUI_ProfileDlg::BlockProfileNameSignals(bool state)
+{
+ myProfileNames->blockSignals(state);
+}
+
+void HYDROGUI_ProfileDlg::SwitchToProfile(int theIndex)
+{
+ myEditorWidget->setCurve(NULL);
+ myEditorWidget->reset();
+ myEditorWidget->setActionMode( CurveCreator_Widget::AdditionMode );
+ myEditorWidget->setSelectedSections(QList<int>());
+ setProfile( (*myProfilesPointer)[theIndex] );
+ for (int i = 0; i < myProfilesPointer->size(); i++)
+ {
+ HYDROGUI_CurveCreatorProfile* aCurve = (*myProfilesPointer)[i];
+ if (i == theIndex)
+ {
+ aCurve->myLineWidth = 3;
+ Handle(AIS_InteractiveObject) anAISObject = aCurve->getAISObject();
+ if (anAISObject)
+ anAISObject->SetWidth(3);
+ }
+ else
+ {
+ aCurve->myLineWidth = 1;
+ Handle(AIS_InteractiveObject) anAISObject = aCurve->getAISObject();
+ if (anAISObject)
+ anAISObject->SetWidth(1);
+ }
+ }
+
+ if( myProfilesPointer &&
+ myProfilesPointer->size()>0 &&
+ myProfilesPointer->at(0) &&
+ myProfilesPointer->at(0)->getDisplayer() )
+ myProfilesPointer->at(0)->getDisplayer()->Update();
+}
+
+void HYDROGUI_ProfileDlg::onAddBtnPressed(bool)
+{
+ emit AddProfiles();
+}
+
+void HYDROGUI_ProfileDlg::onRemoveBtnPressed(bool)
+{
+ int theIndex = GetProfileSelectionIndex();
+ if (theIndex > -1)
+ emit RemoveProfile(theIndex);
+}
+
+void HYDROGUI_ProfileDlg::onSetColorBtnPressed(bool)
+{
+ int theIndex = GetProfileSelectionIndex();
+ if (theIndex < 0)
+ return;
+
+ HYDROGUI_CurveCreatorProfile* aCurve = (*myProfilesPointer)[theIndex];
+
+ QColor aCurrentColor = HYDROData_Tool::toQtColor(/*aCurve->myCurveColor*/aCurve->getColorSection(0));
+ QColor newQCurCol = QColorDialog::getColor( aCurrentColor, this );
+ if( !newQCurCol.isValid() )
+ return;
+
+ Quantity_Color newOCCCol = HYDROData_Tool::toOccColor(newQCurCol);
+ aCurve->setColorSectionInternal(0, newOCCCol);
+ Handle(AIS_InteractiveObject) anAISObject = aCurve->getAISObject();
+ if (anAISObject)
+ {
+ //color points of shape in the same color as edges
+ Handle(Prs3d_PointAspect) anAspect = anAISObject->Attributes()->PointAspect();
+ anAspect->SetColor(newOCCCol);
+ anAISObject->Attributes()->SetPointAspect( anAspect );
+ }
+
+ QListWidgetItem* item = myProfileNames->item(theIndex);
+ QPixmap SPixmap(16, 16);
+ SPixmap.fill(newQCurCol);
+ QIcon SIcon(SPixmap);
+ item->setIcon( SIcon );
+
+ if( myProfilesPointer &&
+ myProfilesPointer->size()>0 &&
+ myProfilesPointer->at(0) &&
+ myProfilesPointer->at(0)->getDisplayer() )
+ myProfilesPointer->at(0)->getDisplayer()->Update();
+}
+
+void HYDROGUI_ProfileDlg::onProfileNameChanged(QListWidgetItem* item)
+{
+ int ind = GetProfileSelectionIndex();
+ if (ind > -1)
+ {
+ int count = myProfileNames->count();
+ QSet<QString> names;
+ for (int i = 0; i < count; i++)
+ {
+ QListWidgetItem* citem = myProfileNames->item(i);
+ if (item!=citem)
+ names << citem->text();
+ }
+ QString curText = item->text();
+ myProfileNames->blockSignals(true);
+ if (names.contains(curText))
+ {
+ QString mes = tr( "PROFILE_ALREADY_EXISTS" );
+ QString title = tr( "PROFILEDLG_WARNING" );
+#ifndef TEST_MODE
+ SUIT_MessageBox::warning( module()->getApp()->desktop(), title, mes );
+#endif
+ item->setText(myCurrentName);
+ }
+ myProfileNames->blockSignals(false);
+ }
+}
+/*
+void HYDROGUI_ProfileDlg::SetSingleProfileMode(bool SingleMode)
+{
+ mySingleProfileMode = SingleMode;
+}
+
+bool HYDROGUI_ProfileDlg::GetSingleProfileMode() const
+{
+ return mySingleProfileMode;
+}*/
+
+Handle(AIS_Trihedron) HYDROGUI_ProfileDlg::trihedron()
+{
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ Handle(AIS_Trihedron) aTrihedron =
+ HYDROGUI_AISTrihedron::createTrihedron( aResMgr->doubleValue( "3DViewer", "trihedron_size", viewer()->trihedronSize() ) );
+ return aTrihedron;
+}