Exemplo n.º 1
0
void Data3DTreeDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
    const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
    const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));

    switch(pAbstractItem->type()) {
        case MetaTreeItemTypes::SurfaceColorGyri: {
            QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorGyri).value<QColor>();
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            pColorDialog->setCurrentColor(color);
            break;
        }

        case MetaTreeItemTypes::SurfaceColorSulci: {
            QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorSulci).value<QColor>();
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            pColorDialog->setCurrentColor(color);
            break;
        }

        case MetaTreeItemTypes::RTDataColormapType: {
            QString colormap = index.model()->data(index, MetaTreeItemRoles::RTDataColormapType).toString();
            QComboBox* pComboBox = static_cast<QComboBox*>(editor);
            pComboBox->setCurrentText(colormap);
            break;
        }

        case MetaTreeItemTypes::RTDataNormalizationValue: {
            Spline* pSpline = static_cast<Spline*>(editor);
            int width = pSpline->size().width();
            int height = pSpline->size().height();
            if (pSpline->size().width() < 200 && pSpline->size().height() < 200)
            {
                pSpline->resize(600,400);   //resize histogram to be readable with default size
            }
            else
            {
                width = pSpline->size().width();   //keeps the size of the histogram
                height = pSpline->size().height();
                pSpline->resize(width,height);
            }
            return;
        }

        case MetaTreeItemTypes::RTDataTimeInterval: {
            int value = index.model()->data(index, MetaTreeItemRoles::RTDataTimeInterval).toInt();
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
            pSpinBox->setValue(value);
            break;
        }

        case MetaTreeItemTypes::RTDataVisualizationType: {
            QString visType = index.model()->data(index, MetaTreeItemRoles::RTDataVisualizationType).toString();
            QComboBox* pComboBox = static_cast<QComboBox*>(editor);
            pComboBox->setCurrentText(visType);
            break;
        }

        case MetaTreeItemTypes::SurfaceColor: {
            QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColor).value<QColor>();
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            pColorDialog->setCurrentColor(color);
            break;
        }

        case MetaTreeItemTypes::PointColor: {
            QColor color = index.model()->data(index, MetaTreeItemRoles::PointColor).value<QColor>();
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            pColorDialog->setCurrentColor(color);
            break;
        }

        case MetaTreeItemTypes::RTDataNumberAverages: {
            int value = index.model()->data(index, MetaTreeItemRoles::RTDataNumberAverages).toInt();
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
            pSpinBox->setValue(value);
            break;
        }

        case MetaTreeItemTypes::SurfaceAlpha: {
            int value = index.model()->data(index, MetaTreeItemRoles::SurfaceAlpha).toDouble();
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
            pSpinBox->setValue(value);
            break;
        }

        case MetaTreeItemTypes::SurfaceTranslateX: {
            double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateX).toDouble();
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            pDoubleSpinBox->setValue(value);
            break;
        }

        case MetaTreeItemTypes::SurfaceTranslateY: {
            double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateY).toDouble();
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            pDoubleSpinBox->setValue(value);
            break;
        }

        case MetaTreeItemTypes::SurfaceTranslateZ: {
            double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateZ).toDouble();
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            pDoubleSpinBox->setValue(value);
            break;
        }        

        case MetaTreeItemTypes::NetworkThreshold: {
            Spline* pSpline = static_cast<Spline*>(editor);
            int width = pSpline->size().width();
            int height = pSpline->size().height();
            if (pSpline->size().width() < 200 && pSpline->size().height() < 200)   //pSpline initializes with size (137,15)
            {
                pSpline->resize(800,600);   //resize histogram to be readable with default size
            }
            else
            {
                width = pSpline->size().width();   //keeps the size of the histogram
                height = pSpline->size().height();
                pSpline->resize(width,height);
            }
            return;
        }

        default: // do nothing;
            break;
    }

    QItemDelegate::setEditorData(editor, index);
}