mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0031362: Inspectors - MessageView plugin for message alerts
- append new MessageView plugin to display content of Message_Report; - correct DumpJson of TDataStd array attributes to print Lower/Upper values; - correct remove level of Message_Report to store stop time during removing all levels; - append DumpJson for TFunction, TPrsStd attributes; - correct DumpJson of XCAFDoc tools due to simplify performance of it; - move AttributeInfo functionality from XDEDRAW into a static public method of XCAFDoc to call it outside; - remove obsolete pane classes in DFBrowser plugin, now we may use DumpJSon panel to visualize this content of attributes; - add new property panel in DFBrowser (synchronized with the same in other plugins); - add button to switch ON DumpJson in DFBrowser(OFF by default, for better performance), also there is a context menu item in tree view; - rename in DFBrowser "Property Panel" into "Property Panel (custom)"; - implement ViewControl_ColorSeletor and setting color in TreeModel_ItemProperties. Use only for light in VInspector now; - implement setting false for all created AIS_Shape presentation to don't modify source TopoDS_Shape; - remove not use VInspector_CallBack. It's possible using Message_Report/MessageView to track commands way; - remove History panel in VInspector as not used, MessageView will be better solution for this; - implement item and actions in VInspector for setting Lights in the view.
This commit is contained in:
193
tools/ViewControl/ViewControl_TableItemDelegate.cxx
Normal file
193
tools/ViewControl/ViewControl_TableItemDelegate.cxx
Normal file
@@ -0,0 +1,193 @@
|
||||
// Created on: 2021-04-27
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2021 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/ViewControl_TableItemDelegate.hxx>
|
||||
#include <inspector/ViewControl_ColorSelector.hxx>
|
||||
#include <inspector/ViewControl_TableModelValues.hxx>
|
||||
#include <inspector/ViewControl_EditType.hxx>
|
||||
#include <inspector/TreeModel_ItemProperties.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QFont>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDoubleValidator>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
ViewControl_TableItemDelegate::ViewControl_TableItemDelegate (QObject* theParent)
|
||||
: QItemDelegate (theParent), myModelValues (0)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createEditor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QWidget* ViewControl_TableItemDelegate::createEditor (QWidget* theParent,
|
||||
const QStyleOptionViewItem&,
|
||||
const QModelIndex& theIndex) const
|
||||
{
|
||||
if (!myModelValues)
|
||||
return 0;
|
||||
|
||||
int aRow = theIndex.row();
|
||||
int aColumn = theIndex.column();
|
||||
ViewControl_EditType anEditType = myModelValues->EditType (aRow, aColumn);
|
||||
|
||||
QWidget* anEditor = createEditorControl (theParent, anEditType);
|
||||
initEditorParameters (anEditor, anEditType, myModelValues, aRow, aColumn);
|
||||
return anEditor;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setEditorData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void ViewControl_TableItemDelegate::setEditorData (QWidget* theEditor, const QModelIndex& theIndex) const
|
||||
{
|
||||
if (!myModelValues)
|
||||
return;
|
||||
|
||||
int aRow = theIndex.row();
|
||||
int aColumn = theIndex.column();
|
||||
ViewControl_EditType anEditType = myModelValues->EditType (aRow, aColumn);
|
||||
|
||||
setEditorValue (theEditor, anEditType, theIndex.model()->data(theIndex));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setModelData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void ViewControl_TableItemDelegate::setModelData (QWidget* theEditor, QAbstractItemModel* theModel,
|
||||
const QModelIndex& theIndex) const
|
||||
{
|
||||
if (!myModelValues)
|
||||
return;
|
||||
|
||||
int aRow = theIndex.row();
|
||||
int aColumn = theIndex.column();
|
||||
ViewControl_EditType anEditType = myModelValues->EditType (aRow, aColumn);
|
||||
theModel->setData (theIndex, getEditorValue (theEditor, anEditType));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createEditorControl
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QWidget* ViewControl_TableItemDelegate::createEditorControl (QWidget* theParent, const ViewControl_EditType theEditType)
|
||||
{
|
||||
switch (theEditType)
|
||||
{
|
||||
case ViewControl_EditType_None: return 0;
|
||||
case ViewControl_EditType_Bool: return new QComboBox (theParent);
|
||||
case ViewControl_EditType_Color: return new ViewControl_ColorSelector (theParent);
|
||||
case ViewControl_EditType_Double:
|
||||
{
|
||||
QLineEdit* aLineEdit = new QLineEdit (theParent);
|
||||
aLineEdit->setValidator (new QDoubleValidator (theParent));
|
||||
return aLineEdit;
|
||||
}
|
||||
case ViewControl_EditType_Line: return new QLineEdit (theParent);
|
||||
case ViewControl_EditType_Spin:
|
||||
{
|
||||
QSpinBox* aSpinBox = new QSpinBox (theParent);
|
||||
aSpinBox->setRange (IntegerFirst(), IntegerLast());
|
||||
return aSpinBox;
|
||||
}
|
||||
case ViewControl_EditType_DoAction: return new QPushButton (theParent);
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initEditorParameters
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void ViewControl_TableItemDelegate::initEditorParameters (QWidget* theEditor,
|
||||
const ViewControl_EditType theEditType,
|
||||
ViewControl_TableModelValues*,
|
||||
const int, const int)
|
||||
{
|
||||
switch (theEditType)
|
||||
{
|
||||
case ViewControl_EditType_Bool:
|
||||
{
|
||||
(qobject_cast<QComboBox*> (theEditor))->insertItem(0, "true");
|
||||
(qobject_cast<QComboBox*> (theEditor))->insertItem(1, "false");
|
||||
break;
|
||||
}
|
||||
case ViewControl_EditType_Double:
|
||||
{
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setEditorValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void ViewControl_TableItemDelegate::setEditorValue (QWidget* theEditor, const ViewControl_EditType theEditType,
|
||||
const QVariant& theValue) const
|
||||
{
|
||||
switch (theEditType)
|
||||
{
|
||||
case ViewControl_EditType_None: break;
|
||||
case ViewControl_EditType_Bool: (qobject_cast<QComboBox*>(theEditor))->setCurrentIndex (theValue.toBool() ? 0 : 1); break;
|
||||
case ViewControl_EditType_Color:
|
||||
{
|
||||
if (!myModelValues)
|
||||
break;
|
||||
|
||||
const TCollection_AsciiString& aStreamValue = myModelValues->Properties()->StreamValue();
|
||||
(qobject_cast<ViewControl_ColorSelector*>(theEditor))->SetStreamValue (aStreamValue.ToCString());
|
||||
break;
|
||||
}
|
||||
case ViewControl_EditType_Double:
|
||||
case ViewControl_EditType_Line: (qobject_cast<QLineEdit*>(theEditor))->setText (theValue.toString()); break;
|
||||
case ViewControl_EditType_Spin: (qobject_cast<QSpinBox*>(theEditor))->setValue (theValue.toInt()); break;
|
||||
case ViewControl_EditType_DoAction: (qobject_cast<QPushButton*>(theEditor))->setText ("UnSelect"); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : getEditorValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
|
||||
QVariant ViewControl_TableItemDelegate::getEditorValue (QWidget* theEditor, const ViewControl_EditType theEditType)
|
||||
{
|
||||
switch (theEditType)
|
||||
{
|
||||
case ViewControl_EditType_None: return QVariant();
|
||||
case ViewControl_EditType_Bool: return (qobject_cast<QComboBox*>(theEditor))->currentIndex() == 0 ? true : false;
|
||||
case ViewControl_EditType_Color: return (qobject_cast<ViewControl_ColorSelector*>(theEditor))->GetStreamValue();
|
||||
case ViewControl_EditType_Double:
|
||||
case ViewControl_EditType_Line: return (qobject_cast<QLineEdit*>(theEditor))->text();
|
||||
case ViewControl_EditType_Spin: return (qobject_cast<QSpinBox*>(theEditor))->value();
|
||||
case ViewControl_EditType_DoAction: return QVariant ("Clicked");
|
||||
default: return QVariant();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user