From a569e198f64e277c8f5194c1549b8697693dead1 Mon Sep 17 00:00:00 2001 From: apo Date: Thu, 19 Jan 2006 06:22:45 +0000 Subject: [PATCH] Adjust to OCC_development_generic_2006 --- src/CAM/CAM_Application.cxx | 39 +++++++++------------- src/QDS/QDS_CheckBox.cxx | 28 +++++++++++++--- src/QDS/QDS_CheckBox.h | 1 + src/QDS/QDS_Datum.cxx | 16 +++++++++ src/QDS/QDS_Datum.h | 5 +++ src/QDS/QDS_LineEdit.h | 2 +- src/Qtx/QtxDblSpinBox.cxx | 8 +++-- src/Qtx/QtxDialog.cxx | 18 +++++++++- src/VTKViewer/VTKViewer_ConvexTool.cxx | 10 +++--- src/VTKViewer/VTKViewer_GeometryFilter.cxx | 22 +++++++++++- 10 files changed, 111 insertions(+), 38 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index eb7060abd..ef7cd09e4 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef WIN32 #include @@ -428,31 +429,23 @@ void CAM_Application::readModuleList() QStringList modList; - // parse command line arguments - int nbArgs = qApp->argc(); - char** CmdLine = qApp->argv(); - QString CmdStr; - for ( int i = 0; i < nbArgs; i++ ) - { - CmdStr.append(CmdLine[i]); - CmdStr.append(" "); - } - int startId = CmdStr.find("--modules ("); - if ( startId != -1 ) { // application launch with --modules option - startId = CmdStr.find("(", startId); - int stopId = CmdStr.find(" )", startId); - QString ModStr = CmdStr.mid( startId+1, stopId - (startId+1) ).stripWhiteSpace(); - int i = 0; - while ( i < ModStr.length() ) - { - int nextId = ModStr.find( ":", i ); - modList.append( ModStr.mid( i, nextId - i ).stripWhiteSpace() ); - i = nextId + 1; + QStringList args; + for (int i = 1; i < qApp->argc(); i++) + args.append( qApp->argv()[i] ); + + QRegExp rx("--modules\\s+\\(\\s*(.*)\\s*\\)"); + rx.setMinimal( true ); + if ( rx.search( args.join(" ") ) >= 0 && rx.capturedTexts().count() > 0 ) { + QString modules = rx.capturedTexts()[1]; + QStringList mods = QStringList::split(":",modules,false); + for ( uint i = 0; i < mods.count(); i++ ) { + if ( !mods[i].stripWhiteSpace().isEmpty() ) + modList.append( mods[i].stripWhiteSpace() ); } } - else { - QString modStr = resMgr->stringValue( "launch", "modules", QString::null ); - modList = QStringList::split( ",", modStr ); + if ( modList.isEmpty() ) { + QString mods = resMgr->stringValue( "launch", "modules", QString::null ); + modList = QStringList::split( ",", mods ); } for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it ) diff --git a/src/QDS/QDS_CheckBox.cxx b/src/QDS/QDS_CheckBox.cxx index 7f1924d97..f6a8bd450 100644 --- a/src/QDS/QDS_CheckBox.cxx +++ b/src/QDS/QDS_CheckBox.cxx @@ -23,7 +23,10 @@ QDS_CheckBox::~QDS_CheckBox() */ QString QDS_CheckBox::getString() const { - return checkBox() && checkBox()->isChecked() ? "1" : "0"; + QString val; + if ( checkBox() && checkBox()->state() != QButton::NoChange ) + val = checkBox()->isChecked() ? "1" : "0"; + return val; } /*! @@ -31,10 +34,20 @@ QString QDS_CheckBox::getString() const */ void QDS_CheckBox::setString( const QString& txt ) { - bool isOk; - int val = (int)txt.toDouble( &isOk ); - if ( checkBox() ) + if ( !checkBox() ) + return; + + if ( txt.isEmpty() ) + { + checkBox()->setTristate(); + checkBox()->setNoChange(); + } + else + { + bool isOk; + int val = (int)txt.toDouble( &isOk ); checkBox()->setChecked( isOk && val != 0 ); + } } /*! @@ -53,6 +66,7 @@ QWidget* QDS_CheckBox::createControl( QWidget* parent ) QCheckBox* cb = new QCheckBox( parent ); connect( cb, SIGNAL( stateChanged( int ) ), SLOT( onParamChanged() ) ); connect( cb, SIGNAL( toggled( bool ) ), SIGNAL( toggled( bool ) ) ); + connect( cb, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChanged( int ) ) ); return cb; } @@ -64,6 +78,12 @@ void QDS_CheckBox::onParamChanged() emit paramChanged(); } +void QDS_CheckBox::onStateChanged( int state ) +{ + if ( state != QButton::NoChange && checkBox() ) + checkBox()->setTristate( false ); +} + void QDS_CheckBox::setChecked( const bool theState ) { if ( checkBox() ) diff --git a/src/QDS/QDS_CheckBox.h b/src/QDS/QDS_CheckBox.h index 7c04edaad..e6d7c541d 100644 --- a/src/QDS/QDS_CheckBox.h +++ b/src/QDS/QDS_CheckBox.h @@ -21,6 +21,7 @@ signals: private slots: void onParamChanged(); + void onStateChanged( int ); protected: QCheckBox* checkBox() const; diff --git a/src/QDS/QDS_Datum.cxx b/src/QDS/QDS_Datum.cxx index f2a4919ba..f7a76b649 100644 --- a/src/QDS/QDS_Datum.cxx +++ b/src/QDS/QDS_Datum.cxx @@ -283,6 +283,14 @@ QString QDS_Datum::shortDescription() const return sdStr; } +QVariant QDS_Datum::value() const +{ + QVariant val; + if ( !isEmpty() ) + val = stringValue(); + return val; +} + QString QDS_Datum::stringValue() const { initDatum(); @@ -382,6 +390,14 @@ void QDS_Datum::clear() } } +void QDS_Datum::setValue( const QVariant& val ) +{ + if ( val.isValid() && val.canCast( QVariant::String ) ) + setStringValue( val.toString() ); + else + clear(); +} + void QDS_Datum::setStringValue( const QString& txt ) { initDatum(); diff --git a/src/QDS/QDS_Datum.h b/src/QDS/QDS_Datum.h index a3a056d7d..cd0bdd62d 100644 --- a/src/QDS/QDS_Datum.h +++ b/src/QDS/QDS_Datum.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -41,6 +42,8 @@ public: QString minimumValue() const; QString maximumValue() const; + virtual QVariant value() const; + virtual QString stringValue() const; virtual double doubleValue() const; virtual int integerValue() const; @@ -52,6 +55,8 @@ public: virtual void reset(); virtual void clear(); + virtual void setValue( const QVariant& ); + virtual void setStringValue( const QString& ); virtual void setDoubleValue( const double ); virtual void setIntegerValue( const int ); diff --git a/src/QDS/QDS_LineEdit.h b/src/QDS/QDS_LineEdit.h index 883d38cb7..ec9ad48a2 100644 --- a/src/QDS/QDS_LineEdit.h +++ b/src/QDS/QDS_LineEdit.h @@ -28,8 +28,8 @@ private slots: void onTextChanged( const QString& ); protected: - QLineEdit* lineEdit() const; virtual QWidget* createControl( QWidget* ); + QLineEdit* lineEdit() const; virtual QString getString() const; virtual void setString( const QString& ); diff --git a/src/Qtx/QtxDblSpinBox.cxx b/src/Qtx/QtxDblSpinBox.cxx index 081259255..b10c28bd6 100755 --- a/src/Qtx/QtxDblSpinBox.cxx +++ b/src/Qtx/QtxDblSpinBox.cxx @@ -25,6 +25,8 @@ #include #include +#include + /* Class: QtxDblSpinBox::Validator [internal] Descr: Validator for QtxDblSpinBox (getted from Trolltech Qt - SpinBoxValidator) @@ -93,10 +95,10 @@ myCleared( false ), myBlocked( false ), myPrecision( 0 ) { - myMin = QRangeControl::minValue(); - myMax = QRangeControl::maxValue(); + myMin = -DBL_MAX; + myMax = DBL_MAX; myStep = QRangeControl::lineStep(); - myValue = myMin; + myValue = 0; setValidator( new Validator( this, "double_spinbox_validator" ) ); rangeChange(); updateDisplay(); diff --git a/src/Qtx/QtxDialog.cxx b/src/Qtx/QtxDialog.cxx index bf827df57..347479e55 100755 --- a/src/Qtx/QtxDialog.cxx +++ b/src/Qtx/QtxDialog.cxx @@ -236,7 +236,7 @@ void QtxDialog::Area::layoutButtons() center.append( it.current() ); } - delete layout(); + delete layout(); QBoxLayout* buttonLayout = 0; if ( myOrientation == Qt::Vertical ) @@ -267,6 +267,22 @@ void QtxDialog::Area::layoutButtons() buttonLayout->addStretch( 1 ); } } + + QWidgetList wids; + if ( layout() ) + { + for ( QLayoutIterator it = layout()->iterator(); it.current(); ++it ) + { + if ( !it.current()->widget() ) + continue; + + if ( QApplication::reverseLayout() ) + wids.prepend( it.current()->widget() ); + else + wids.append( it.current()->widget() ); + } + } + Qtx::setTabOrder( wids ); } /*! diff --git a/src/VTKViewer/VTKViewer_ConvexTool.cxx b/src/VTKViewer/VTKViewer_ConvexTool.cxx index a4dded2cc..b79eb3f4e 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.cxx +++ b/src/VTKViewer/VTKViewer_ConvexTool.cxx @@ -66,8 +66,8 @@ static float FACE_ANGLE_TOLERANCE=1.5; static int MYDEBUG = 0; static int MYDEBUG_REMOVE = 0; #else - static int MYDEBUG = 0; - static int MYDEBUG_REMOVE = 0; + static int MYDEBUG = 1; + static int MYDEBUG_REMOVE = 1; #endif /*! \fn static void GetCenter(TInput* theGrid,TCell theptIds,float *center) @@ -519,7 +519,7 @@ static void GetAndRemoveIdsOnOneLine(vtkPoints* points, } static vtkConvexPointSet* RemoveAllUnneededPoints(vtkConvexPointSet* convex){ - vtkSmartPointer out = vtkConvexPointSet::New(); + vtkConvexPointSet* out = vtkConvexPointSet::New(); TUIDS two_points,input_points,out_two_points_ids,removed_points_ids,loc_removed_points_ids; vtkIdList* aPointIds = convex->GetPointIds(); @@ -624,7 +624,7 @@ static vtkConvexPointSet* RemoveAllUnneededPoints(vtkConvexPointSet* convex){ out->Modified(); out->Initialize(); - return out.GetPointer(); + return out; } void GetPolygonalFaces(vtkUnstructuredGrid* theGrid,int cellId,TCellArray &outputCellArray) @@ -632,7 +632,7 @@ void GetPolygonalFaces(vtkUnstructuredGrid* theGrid,int cellId,TCellArray &outpu if (theGrid->GetCellType(cellId) == VTK_CONVEX_POINT_SET){ // get vtkCell type = VTK_CONVEX_POINT_SET if(vtkConvexPointSet* convex_in = static_cast(theGrid->GetCell(cellId))){ - vtkConvexPointSet* convex = RemoveAllUnneededPoints(convex_in); + vtkSmartPointer convex = RemoveAllUnneededPoints(convex_in); TCellArray f2points; float convex_center[3]; // convex center point coorinat int aNbFaces = convex->GetNumberOfFaces(); diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.cxx b/src/VTKViewer/VTKViewer_GeometryFilter.cxx index d1baa5b11..ae9641d03 100755 --- a/src/VTKViewer/VTKViewer_GeometryFilter.cxx +++ b/src/VTKViewer/VTKViewer_GeometryFilter.cxx @@ -98,6 +98,7 @@ void VTKViewer_GeometryFilter::UnstructuredGridExecute() vtkCellArray *Connectivity = input->GetCells(); if (Connectivity == NULL) {return;} vtkIdType cellId; + vtkGenericCell *cell = vtkGenericCell::New(); int i; int allVisible; vtkIdType npts = 0; @@ -279,7 +280,25 @@ void VTKViewer_GeometryFilter::UnstructuredGridExecute() outputCD->CopyData(cd,cellId,newCellId); break; - case VTK_CONVEX_POINT_SET:{ + case VTK_CONVEX_POINT_SET: { + aCellType = VTK_TRIANGLE; + numFacePts = 3; + input->GetCell(cellId,cell); + for (int j=0; j < cell->GetNumberOfFaces(); j++){ + vtkCell *face = cell->GetFace(j); + input->GetCellNeighbors(cellId, face->PointIds, cellIds); + if ( true || cellIds->GetNumberOfIds() <= 0 || myShowInside ) { + aNewPts[0] = face->PointIds->GetId(0); + aNewPts[1] = face->PointIds->GetId(1); + aNewPts[2] = face->PointIds->GetId(2); + newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts); + if(myStoreMapping) + myVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd,cellId,newCellId); + } + } + break; + /* TCellArray tmpCellArray; try{ CONVEX_TOOL::GetPolygonalFaces(input,cellId,tmpCellArray); // "VTKViewer_ConvexTool.cxx" @@ -310,6 +329,7 @@ void VTKViewer_GeometryFilter::UnstructuredGridExecute() outputCD->CopyData(cd,cellId,newCellId); } break; + */ } case VTK_TETRA: { for (faceId = 0; faceId < 4; faceId++) -- 2.39.2