From: admin Date: Thu, 29 Jan 2004 13:14:03 +0000 (+0000) Subject: This commit was generated by cvs2git to create branch 'br_mt'. X-Git-Tag: mergefrom_trunk_01Feb04~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5c3fd203f5e3eb6c7c4fdbd610d4d7423ef67b3c;p=modules%2Fvisu.git This commit was generated by cvs2git to create branch 'br_mt'. Cherrypick from master 2004-01-29 13:14:02 UTC smh 'MPV: Merge V1_2d': src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx src/CONVERTOR/VISU_ExtractUnstructuredGrid.hxx src/VISUGUI/VisuGUI_EditContainerDlg.cxx src/VISUGUI/VisuGUI_EditContainerDlg.h --- diff --git a/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx new file mode 100644 index 00000000..a8ba1e37 --- /dev/null +++ b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.cxx @@ -0,0 +1,101 @@ +// VISU CONVERTOR : +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File: VISU_ExtractUnstructuredGrid.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_ExtractUnstructuredGrid.hxx" +#include "VISU_ConvertorUtils.hxx" + +#include +#include +#include +#include + +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +vtkStandardNewMacro(VISU_ExtractUnstructuredGrid); + +VISU_ExtractUnstructuredGrid::VISU_ExtractUnstructuredGrid(){} + +VISU_ExtractUnstructuredGrid::~VISU_ExtractUnstructuredGrid(){} + +void VISU_ExtractUnstructuredGrid::RemoveCell(vtkIdType theCellId){ + myRemovedCellIds.insert(theCellId); + Modified(); +} + +void VISU_ExtractUnstructuredGrid::RemoveCellsWithType(vtkIdType theCellType){ + myRemovedCellTypes.insert(theCellType); + Modified(); +} + +namespace{ + inline void InsertCell(vtkUnstructuredGrid *theInput, + vtkUnstructuredGrid *theOutput, + vtkIdType theCellId, vtkIdList *theCellIds) + { + theCellIds->Reset(); + vtkCell *aCell = theInput->GetCell(theCellId); + vtkIdType aNbIds = aCell->PointIds->GetNumberOfIds(); + for(vtkIdType i = 0; i < aNbIds; i++) + theCellIds->InsertNextId(aCell->GetPointIds()->GetId(i)); + theOutput->InsertNextCell(theInput->GetCellType(theCellId), theCellIds); + } +} + +void VISU_ExtractUnstructuredGrid::Execute(){ + vtkUnstructuredGrid *anInput = this->GetInput(), *anOutput = this->GetOutput(); + vtkIdType aNbCells = anInput->GetNumberOfCells(); + anOutput->Allocate(aNbCells); + if(MYDEBUG) MESSAGE("Execute - anInput->GetNumberOfCells() = "<GetNumberOfCells()); + vtkIdList *aCellIds = vtkIdList::New(); + if(MYDEBUG) + MESSAGE("Execute - myRemovedCellIds.empty() = "<GetNumberOfCells() = "<GetNumberOfCells()); +} diff --git a/src/CONVERTOR/VISU_ExtractUnstructuredGrid.hxx b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.hxx new file mode 100644 index 00000000..28396748 --- /dev/null +++ b/src/CONVERTOR/VISU_ExtractUnstructuredGrid.hxx @@ -0,0 +1,70 @@ +// VISU CONVERTOR : +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File : VISU_ExtractUnstructuredGrid.hxx +// Author : Alexey PETROV +// Module : VISU + +#ifndef VISU_ExtractUnstructuredGrid_HeaderFile +#define VISU_ExtractUnstructuredGrid_HeaderFile + +#include + +#include + +class VISU_ExtractUnstructuredGrid : public vtkUnstructuredGridToUnstructuredGridFilter{ +public: + vtkTypeMacro(VISU_ExtractUnstructuredGrid,vtkUnstructuredGridToUnstructuredGridFilter); + + // Description: + // Construct with all types of clipping turned off. + static VISU_ExtractUnstructuredGrid *New(); + + // Description: + // Remove the cell from the output + void RemoveCell(vtkIdType theCellId); + int IsRemoveCells() { return !myRemovedCellIds.empty();} + + // Remove every cells with the type from the output + void RemoveCellsWithType(vtkIdType theCellType); + int IsRemoveCellsWithType() { return !myRemovedCellTypes.empty();} + + // Do the filter do some real work + int IsRemoving() { return IsRemoveCells() || IsRemoveCellsWithType();} + +protected: + VISU_ExtractUnstructuredGrid(); + ~VISU_ExtractUnstructuredGrid(); + + void Execute(); + + std::set myRemovedCellIds; + std::set myRemovedCellTypes; + +private: + VISU_ExtractUnstructuredGrid(const VISU_ExtractUnstructuredGrid&); // Not implemented. + void operator=(const VISU_ExtractUnstructuredGrid&); // Not implemented. +}; + +#endif + + diff --git a/src/VISUGUI/VisuGUI_EditContainerDlg.cxx b/src/VISUGUI/VisuGUI_EditContainerDlg.cxx new file mode 100644 index 00000000..58212511 --- /dev/null +++ b/src/VISUGUI/VisuGUI_EditContainerDlg.cxx @@ -0,0 +1,426 @@ +using namespace std; + +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_EditContainerDlg.cxx +// Author : VSV +// Module : VISU + + +#include "VisuGUI_EditContainerDlg.h" +#include "VisuGUI.h" +#include "VISU_Table_i.hh" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +#include +#include +#include + + +#include CORBA_SERVER_HEADER(VISU_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +extern VisuGUI *visuGUI; + + + +/* XPM */ +static const char * left_xpm[] = { +"24 24 61 1", +" c None", +". c #323232", +"+ c #010101", +"@ c #4A4A4A", +"# c #040404", +"$ c #979797", +"% c #7B7B7B", +"& c #939393", +"* c #EEEEEE", +"= c #686868", +"- c #030303", +"; c #9C9C9C", +"> c #FFFFFF", +", c #B1B1B1", +"' c #5E5E5E", +") c #060606", +"! c #C1C1C1", +"~ c #626262", +"{ c #000000", +"] c #989898", +"^ c #A1A1A1", +"/ c #A5A5A5", +"( c #909090", +"_ c #868686", +": c #616161", +"< c #959595", +"[ c #919191", +"} c #848484", +"| c #606060", +"1 c #0B0B0B", +"2 c #545454", +"3 c #727272", +"4 c #A2A2A2", +"5 c #969696", +"6 c #838383", +"7 c #5F5F5F", +"8 c #101010", +"9 c #434343", +"0 c #6B6B6B", +"a c #858585", +"b c #8E8E8E", +"c c #373737", +"d c #696969", +"e c #8D8D8D", +"f c #B5B5B5", +"g c #111111", +"h c #393939", +"i c #898989", +"j c #B0B0B0", +"k c #191919", +"l c #3A3A3A", +"m c #646464", +"n c #535353", +"o c #050505", +"p c #353535", +"q c #585858", +"r c #4C4C4C", +"s c #0D0D0D", +"t c #3E3E3E", +"u c #020202", +"v c #0A0A0A", +" ", +" ", +" .+ .+ ", +" .@# .@# ", +" .$%# .$%# ", +" .&*=- .&*=- ", +" .;>,') .;>,') ", +" .;>!;~{ .;>!;~{ ", +" .]>!^&~{ .]>!^&~{ ", +" ./>!/(_:{ ./>!/(_:{ ", +" .<*!^[}}|{.<*!^[}}|{ ", +" 123}45667{123}45667{ ", +" 890a45b7{ 890a45b7{ ", +" 8cdef5'{ 8cdef5'{ ", +" gh0ij7k gh0ij7k ", +" 8lm0no 8lm0no ", +" 8pqr- 8pqr- ", +" sht- sht- ", +" 1.u 1.u ", +" v{ v{ ", +" ", +" ", +" ", +" "}; + +static QPixmap MYLeftPix(left_xpm); + + +static const char * right_xpm[] = { +"24 24 43 1", +" g None", +". g #323232", +"+ g #5D5D5D", +"@ g #000000", +"# g #C4C4C4", +"$ g #313131", +"% g #C5C5C5", +"& g #E4E4E4", +"* g #2D2D2D", +"= g #B7B7B7", +"- g #EFEFEF", +"; g #DCDCDC", +"> g #282828", +", g #AFAFAF", +"' g #E0E0E0", +") g #242424", +"! g #C7C7C7", +"~ g #9A9A9A", +"{ g #8E8E8E", +"] g #1F1F1F", +"^ g #A5A5A5", +"/ g #989898", +"( g #888888", +"_ g #1B1B1B", +": g #ADADAD", +"< g #858585", +"[ g #838383", +"} g #868686", +"| g #929292", +"1 g #C1C1C1", +"2 g #161616", +"3 g #909090", +"4 g #747474", +"5 g #3A3A3A", +"6 g #121212", +"7 g #0D0D0D", +"8 g #7A7A7A", +"9 g #8A8A8A", +"0 g #090909", +"a g #040404", +"b g #707070", +"c g #6E6E6E", +"d g #3F3F3F", +" ", +" ", +" .. .. ", +" .+@ .+@ ", +" .#+@ .#+@ ", +" $%&+@ $%&+@ ", +" *=-;+@ *=-;+@ ", +" >,'=;+@ >,'=;+@ ", +" ),!~{;+@ ),!~{;+@ ", +" ]^!/({;+@ ]^!/({;+@ ", +" _~:<[}|1+@_~:<[}|1+@ ", +" 23~[[{:45@23~[[{:45@ ", +" 6setFrameStyle(QFrame::Box | QFrame::Sunken); + + QGridLayout* aControlLay = new QGridLayout(aControlFrame); + aControlLay->setSpacing( 6 ); + aControlLay->setMargin( 11 ); + aControlLay->addRowSpacing( 1, 30 ); + aControlLay->addRowSpacing( 4, 30 ); + aControlLay->setRowStretch( 1, 1 ); + aControlLay->setRowStretch( 4, 1 ); + aControlLay->addColSpacing( 0, 180 ); + aControlLay->addColSpacing( 2, 180 ); + + QLabel* aSelectLbl = new QLabel(tr("Study"), aControlFrame); + aControlLay->addWidget(aSelectLbl, 0, 0); + + myStudyLst = new QListView(aControlFrame); + myStudyLst->setSelectionMode(QListView::Extended); + myStudyLst->addColumn(tr("Table"), 80); + myStudyLst->addColumn(tr("Curve"), 50); + myStudyLst->addColumn(tr(""), 0); + myStudyLst->setAllColumnsShowFocus(true); + myStudyLst->setMinimumHeight(130); + connect(myStudyLst, SIGNAL( selectionChanged()), this, SLOT( onLeftSelected() )); + aControlLay->addMultiCellWidget(myStudyLst, 1, 4, 0, 0); + + myRightBtn = new QToolButton(aControlFrame); + myRightBtn->setIconSet(MYRightPix); + myRightBtn->setEnabled(false); + connect(myRightBtn, SIGNAL( clicked()), this, SLOT( onRightClicked() )); + aControlLay->addWidget(myRightBtn, 2, 1); + + myLeftBtn = new QToolButton(aControlFrame); + myLeftBtn->setIconSet(MYLeftPix); + myLeftBtn->setEnabled(false); + connect(myLeftBtn, SIGNAL( clicked()), this, SLOT( onLeftClicked() )); + aControlLay->addWidget(myLeftBtn, 3, 1); + + QLabel* aForceLbl = new QLabel(tr("Container"), aControlFrame); + aControlLay->addWidget(aForceLbl, 0, 2); + + myContainerLst = new QListView(aControlFrame); + myContainerLst->setSelectionMode(QListView::Extended); + myContainerLst->addColumn(tr("Table"), 80); + myContainerLst->addColumn(tr("Curve"), 50); + myContainerLst->addColumn(tr(""), 0); + myContainerLst->setMinimumWidth(130); + connect(myContainerLst, SIGNAL( selectionChanged()), this, SLOT( onRightSelected() )); + aControlLay->addMultiCellWidget(myContainerLst, 1, 4, 2, 2); + + TopLayout->addWidget( aControlFrame ); + + // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( GroupButtons ); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + + +void VisuGUI_EditContainerDlg::initFromPrsObject(VISU::Container_i* theContainer) { + SALOMEDS::Study_var aStudy = visuGUI->GetStudyDocument(); + SALOMEDS::SComponent_var aVisuSO = aStudy->FindComponent("VISU"); + if (aVisuSO->_is_nil()) { + return; + } + QValueList aStudyCurves; + QValueList aContainerCurves; + // Find curves in container + for (int i = 1; i <= theContainer->GetNbCurves(); i++) { + VISU::Curve_i* aCurve = theContainer->GetCurve(i); + if (aCurve == NULL) continue; + CurveStruct aEntry; + aEntry.CurveName = aCurve->GetTitle(); + aEntry.CurveEntry = aCurve->GetEntry(); + SALOMEDS::SObject_var aTableSO = aStudy->FindObjectID(aCurve->GetTableID()); + if (CORBA::is_nil(aTableSO)) continue; + aEntry.TableName = getSObjectName(aTableSO); + aContainerCurves.append(aEntry); + new QListViewItem(myContainerLst, aEntry.TableName, aEntry.CurveName, aEntry.CurveEntry); + } + // Find curves in study + SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aVisuSO ); + for (aIter->InitEx(true); aIter->More(); aIter->Next()) { + SALOMEDS::SObject_var aSObject = aIter->Value(); + CORBA::Object_var anObject = VISU::SObjectToObject(aSObject); + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj)) { + if (aVisuObj->GetType() == VISU::TCURVE) { + SALOMEDS::SObject_var aTableSO = aSObject->GetFather(); + CurveStruct aEntry; + aEntry.TableName = getSObjectName(aTableSO); + aEntry.CurveName = getSObjectName(aSObject); + aEntry.CurveEntry = aSObject->GetID(); + aStudyCurves.append(aEntry); + } + } + } + //Show Curves which are not in Curve + QValueList::iterator it; + QValueList::iterator it2; + bool isExist = false; + for (it = aStudyCurves.begin(); it != aStudyCurves.end(); ++it ) { + for (it2 = aContainerCurves.begin(); it2 != aContainerCurves.end(); ++it2 ) { + if (isExist = ((*it).CurveEntry == (*it2).CurveEntry)) + break; + } + if (!isExist) + new QListViewItem(myStudyLst, (*it).TableName, (*it).CurveName, (*it).CurveEntry); + } +} + + +void VisuGUI_EditContainerDlg::storeToPrsObject(VISU::Container_i* theContainer) { + theContainer->Clear(); + + SALOMEDS::Study_var aStudy = visuGUI->GetStudyDocument(); + QListViewItem* anItem = myContainerLst->firstChild(); + while (anItem) { + SALOMEDS::SObject_var aCurveSO = aStudy->FindObjectID(anItem->text(2)); + if (!aCurveSO->_is_nil()) { + CORBA::Object_var aObject = VISU::SObjectToObject(aCurveSO); + if (!CORBA::is_nil(aObject)) { + VISU::Curve_i* aCurve = dynamic_cast( VISU::GetServant(aObject).in() ); + if (aCurve) theContainer->AddCurve(aCurve->_this()); + } + } + anItem = anItem->nextSibling(); + } +} + + +QString VisuGUI_EditContainerDlg::getSObjectName(SALOMEDS::SObject_var theSObject) { + if (theSObject->_is_nil()) return QString(""); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( theSObject->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow( anAttr ); + return QString(strdup( aName->Value() )); + } + return QString(""); +} + + +void VisuGUI_EditContainerDlg::onLeftClicked() { + QListViewItem* anItem = myContainerLst->firstChild(); + while (anItem) { + if (anItem->isSelected()) { + QListViewItem* anTmpItem = anItem; + anItem = anTmpItem->nextSibling(); + myContainerLst->takeItem(anTmpItem); + myStudyLst->insertItem(anTmpItem); + } else { + anItem = anItem->nextSibling(); + } + } +} + + +void VisuGUI_EditContainerDlg::onRightClicked() { + QListViewItem* anItem = myStudyLst->firstChild(); + while (anItem) { + if (anItem->isSelected()) { + QListViewItem* anTmpItem = anItem; + anItem = anTmpItem->nextSibling(); + myStudyLst->takeItem(anTmpItem); + myContainerLst->insertItem(anTmpItem); + } else { + anItem = anItem->nextSibling(); + } + } +} + + +void VisuGUI_EditContainerDlg::onLeftSelected() { + QListViewItem* anItem = myStudyLst->firstChild(); + bool isSelected = false; + while (anItem) { + if (anItem->isSelected()) { + isSelected = true; + break; + } + anItem = anItem->nextSibling(); + } + myRightBtn->setEnabled(isSelected); +} + + +void VisuGUI_EditContainerDlg::onRightSelected() { + QListViewItem* anItem = myContainerLst->firstChild(); + bool isSelected = false; + while (anItem) { + if (anItem->isSelected()) { + isSelected = true; + break; + } + anItem = anItem->nextSibling(); + } + myLeftBtn->setEnabled(isSelected); +} diff --git a/src/VISUGUI/VisuGUI_EditContainerDlg.h b/src/VISUGUI/VisuGUI_EditContainerDlg.h new file mode 100644 index 00000000..de66d29c --- /dev/null +++ b/src/VISUGUI/VisuGUI_EditContainerDlg.h @@ -0,0 +1,64 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_EditContainerDlg.h +// Author : VSV +// Module : VISU + +#ifndef VISUGUI_EDITCONTAINER_H +#define VISUGUI_EDITCONTAINER_H + +#include +#include +#include +#include + + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + + +namespace VISU{ + class Container_i; +} + + +struct CurveStruct { + QString TableName; + QString CurveName; + QString CurveEntry; +}; + + +class VisuGUI_EditContainerDlg: public QDialog +{ + Q_OBJECT + +public: + VisuGUI_EditContainerDlg(); + ~VisuGUI_EditContainerDlg() {}; + + void initFromPrsObject(VISU::Container_i* theContainer); + void storeToPrsObject(VISU::Container_i* theContainer); + +private slots: + void onLeftClicked(); + void onRightClicked(); + void onLeftSelected(); + void onRightSelected(); + +private: + QString getSObjectName(SALOMEDS::SObject_var theSObject); + + QListView* myStudyLst; + QListView* myContainerLst; + QToolButton* myLeftBtn; + QToolButton* myRightBtn; +}; + + +#endif // VISUGUI_EDITCONTAINER_H +