mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0027398: Integrate Qt Browser Widget to Open CASCADE Technology
The following implementation has been made: - CMake procedure is extended to compile Qt tools. This is optional and is handled by USE_QT_TOOLS option(OFF by default) - It is possible to build Qt tools using Qt5 or Qt4, it is settled with USE_QT4 option. - Sample of DFBrowser tool is available in samples/tools/TInspectorEXE. It is build with tools, executable is placed in binaries. To start the sample, use dfbrowser.bat command. - DFBrowser tool may be started from DRAW
This commit is contained in:
151
tools/DFBrowser/DFBrowser_ItemBase.cxx
Normal file
151
tools/DFBrowser/DFBrowser_ItemBase.cxx
Normal file
@@ -0,0 +1,151 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 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 <DFBrowser_ItemBase.hxx>
|
||||
|
||||
#include <DFBrowser_Item.hxx>
|
||||
#include <DFBrowser_Module.hxx>
|
||||
#include <DFBrowser_Tools.hxx>
|
||||
|
||||
#include <DFBrowserPane_AttributePane.hxx>
|
||||
#include <DFBrowserPane_ItemRole.hxx>
|
||||
#include <DFBrowserPane_Tools.hxx>
|
||||
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
|
||||
#include <QColor>
|
||||
#include <QIcon>
|
||||
#include <QVariant>
|
||||
|
||||
//#define REQUIRE_OCAF_REVIEW:20
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
DFBrowser_ItemBase::DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: TreeModel_ItemBase (theParent, theRow, theColumn), myModule (0), myIsUseAdditionalInfo (true)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : reset
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_ItemBase::Reset()
|
||||
{
|
||||
setLabel (TDF_Label());
|
||||
TreeModel_ItemBase::Reset();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetLabel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TDF_Label DFBrowser_ItemBase::GetLabel() const
|
||||
{
|
||||
initItem();
|
||||
return myLabel;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : data
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant DFBrowser_ItemBase::data (const QModelIndex& theIndex, int theRole) const
|
||||
{
|
||||
int aRole = theRole;
|
||||
if (Column() == 0 && useAdditionalInfo())
|
||||
{
|
||||
switch (theRole)
|
||||
{
|
||||
case Qt::DisplayRole: { aRole = DFBrowserPane_ItemRole_DisplayExtended; break; }
|
||||
case Qt::ToolTipRole: { aRole = DFBrowserPane_ItemRole_ToolTipExtended; break; }
|
||||
}
|
||||
}
|
||||
return TreeModel_ItemBase::data (theIndex, aRole);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initRowCount
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
int DFBrowser_ItemBase::initRowCount() const
|
||||
{
|
||||
TDF_Label aLabel = GetLabel();
|
||||
if (aLabel.IsNull())
|
||||
return 0;
|
||||
|
||||
return aLabel.NbChildren() + aLabel.NbAttributes();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant DFBrowser_ItemBase::initValue (const int theItemRole) const
|
||||
{
|
||||
switch (theItemRole)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
case Qt::ToolTipRole:
|
||||
return DFBrowser_Tools::GetLabelInfo (myLabel, false);
|
||||
case DFBrowserPane_ItemRole_DisplayExtended:
|
||||
case DFBrowserPane_ItemRole_ToolTipExtended:
|
||||
return DFBrowser_Tools::GetLabelInfo (myLabel, true);
|
||||
case Qt::ForegroundRole:
|
||||
{
|
||||
QVariant aValue = QColor (Qt::black);
|
||||
if (DFBrowser_Tools::IsEmptyLabel(GetLabel()))
|
||||
aValue = QColor (Qt::lightGray);
|
||||
else
|
||||
{ //! TEMPORARY HERE : should be moved in the pane of TDataStd_Name kind of attribute
|
||||
Handle(TDataStd_Name) aName;
|
||||
if (useAdditionalInfo() && myLabel.FindAttribute (TDataStd_Name::GetID(), aName))
|
||||
aValue = QColor (Qt::darkGreen);
|
||||
}
|
||||
return aValue;
|
||||
}
|
||||
case Qt::DecorationRole: return DFBrowser_Tools::GetLabelIcon (myLabel);
|
||||
default: break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createChild
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr DFBrowser_ItemBase::createChild (int theRow, int theColumn)
|
||||
{
|
||||
TreeModel_ItemBasePtr anItem = DFBrowser_Item::CreateItem (currentItem(), theRow, theColumn);
|
||||
DFBrowser_ItemBasePtr aBaseItem = itemDynamicCast<DFBrowser_ItemBase> (anItem);
|
||||
aBaseItem->SetModule (GetModule());
|
||||
|
||||
return anItem;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetUseAdditionalInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool DFBrowser_ItemBase::SetUseAdditionalInfo (const bool theValue)
|
||||
{
|
||||
bool aPreviousValue = myIsUseAdditionalInfo;
|
||||
myIsUseAdditionalInfo = theValue;
|
||||
return aPreviousValue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user