--- /dev/null
+// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "CurveCreator_TableView.h"
+
+#include <QTableWidget>
+#include <QTableWidgetItem>
+//#include <QDoubleSpinBox>
+#include <QtxDoubleSpinBox.h>
+
+const double DBL_MINIMUM = -10000000.;
+const double DBL_MAXIMUM = 10000000.;
+
+CurveCreator_TableItemDelegate::CurveCreator_TableItemDelegate( QObject* theParent )
+: QItemDelegate( theParent )
+{
+}
+
+/**
+ * Creates an editor for the cell
+ */
+QWidget* CurveCreator_TableItemDelegate::createEditor( QWidget* theParent,
+ const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex ) const
+{
+ QWidget* anEditor = 0;
+
+ int aColumnId = theIndex.column();
+ if ( aColumnId == 2 || aColumnId == 3 ) {
+ QDoubleSpinBox* aSpin = new QtxDoubleSpinBox( theParent );
+ aSpin->setDecimals( 6 );
+ aSpin->setRange( DBL_MINIMUM, DBL_MAXIMUM );
+ anEditor = aSpin;
+ }
+ else
+ anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex );
+
+ return anEditor;
+}
+
+void CurveCreator_TableItemDelegate::setEditorData( QWidget* theEditor,
+ const QModelIndex& theIndex ) const
+{
+ QTableWidget* aTableWidget = dynamic_cast<QTableWidget*>( parent() );
+ QTableWidgetItem* anItem = aTableWidget ? dynamic_cast<QTableWidgetItem*>
+ ( aTableWidget->item( theIndex.row(), theIndex.column() ) ) : 0;
+ int aColumnId = theIndex.column();
+ if ( anItem && ( aColumnId == 2 || aColumnId == 3 ) ) {
+ QDoubleSpinBox* aDblSpin = dynamic_cast<QDoubleSpinBox*>( theEditor );
+ double aValue = anItem->data( Qt::UserRole ).toDouble();
+ if ( aDblSpin ) {
+ aDblSpin->setValue( aValue );
+ }
+ }
+ else
+ QItemDelegate::setEditorData( theEditor, theIndex );
+}
+
+void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor,
+ QAbstractItemModel* theModel,
+ const QModelIndex& theIndex ) const
+{
+ QTableWidget* aTableWidget = dynamic_cast<QTableWidget*>( parent() );
+ QTableWidgetItem* anItem = aTableWidget ? dynamic_cast<QTableWidgetItem*>
+ ( aTableWidget->item( theIndex.row(), theIndex.column() ) ) : 0;
+
+ int aColumnId = theIndex.column();
+ if ( anItem && ( aColumnId == 2 || aColumnId == 3 ) ) {
+ QDoubleSpinBox* aDblSpin = dynamic_cast<QDoubleSpinBox*>( theEditor );
+ if ( aDblSpin ) {
+ double aValue = aDblSpin->value();
+ anItem->setData( Qt::UserRole, aValue );
+ }
+ }
+ else
+ QItemDelegate::setModelData( theEditor, theModel, theIndex );
+}
+
--- /dev/null
+// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef CURVECREATOR_TABLEVIEW_H
+#define CURVECREATOR_TABLEVIEW_H
+
+#include <QItemDelegate>
+
+class CurveCreator_TableItemDelegate : public QItemDelegate
+{
+public:
+ CurveCreator_TableItemDelegate( QObject* theParent );
+ ~CurveCreator_TableItemDelegate() {}
+
+ virtual QWidget* createEditor( QWidget* theParent,
+ const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex ) const;
+ virtual void setEditorData( QWidget* theEditor, const QModelIndex& theIndex ) const;
+ virtual void setModelData( QWidget* theEditor, QAbstractItemModel* theModel,
+ const QModelIndex& theIndex ) const;
+};
+
+#endif // CURVECREATOR_TABLEVIEW_H
//#include "CurveCreator_NewPointDlg.h"
#include "CurveCreator_NewSectionDlg.h"
#include "CurveCreator_Utils.h"
+#include "CurveCreator_TableView.h"
#include <SUIT_Session.h>
#include <SUIT_Desktop.h>
connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
myLocalPointView = new QTableWidget();
+ myLocalPointView->setItemDelegate( new CurveCreator_TableItemDelegate( myLocalPointView ) );
myLocalPointView->setVisible( false );
myLocalPointView->setColumnCount( 4 );
myLocalPointView->setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH );
SectionToPointList aSelPoints;
startCurveModification( aSelPoints );
- double aX = myLocalPointView->item( theRow, 2 )->text().toDouble();
- double anY = myLocalPointView->item( theRow, 3 )->text().toDouble();
+ double aX = myLocalPointView->item( theRow, 2 )->data( Qt::UserRole ).toDouble();
+ double anY = myLocalPointView->item( theRow, 3 )->data( Qt::UserRole ).toDouble();
std::deque<float> aChangedPos;
aChangedPos.push_back( aX );
aChangedPos.push_back( anY );