1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0029674: Improvements in Inspector tool

- preferences for dock windows geometry, tree view columns and current view projection;
- ViewControl package for common functionality between plugins;
- processing Location and Orientation for external TopoDS_Shape object
- 'F5' key to update content of each plugin
- visibility column in tree view (used now only in ShapeView)
- properties child item for context (presents tree of current Filters of context)
This commit is contained in:
nds
2018-03-23 16:08:11 +03:00
committed by bugmaster
parent 6dfdbb7ab8
commit 6822a3bef1
135 changed files with 4187 additions and 1603 deletions

View File

@@ -2,3 +2,4 @@ TInspectorAPI_Communicator.cxx
TInspectorAPI_Communicator.hxx
TInspectorAPI_PluginParameters.cxx
TInspectorAPI_PluginParameters.hxx
TInspectorAPI_PreferencesDataMap.hxx

View File

@@ -50,6 +50,16 @@ public:
//! \param theParent a parent class
Standard_EXPORT virtual void SetParent (void* theParent) = 0;
//! Provide container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
Standard_EXPORT virtual void FillActionsMenu (void* theMenu) { (void)theMenu; }
//! Returns plugin preferences, empty implementation by default
virtual void GetPreferences (TInspectorAPI_PreferencesDataMap&) {}
//! Applies plugin preferences, empty implementation by default
virtual void SetPreferences (const TInspectorAPI_PreferencesDataMap&) {}
//! Calls update of the plugin's content
Standard_EXPORT virtual void UpdateContent() = 0;

View File

@@ -22,14 +22,6 @@ IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
#endif
// =======================================================================
// function : Constructor
// purpose :
// =======================================================================
TInspectorAPI_PluginParameters::TInspectorAPI_PluginParameters()
{
}
// =======================================================================
// function : SetParameters
// purpose :
@@ -51,8 +43,8 @@ void TInspectorAPI_PluginParameters::SetParameters (const TCollection_AsciiStrin
void TInspectorAPI_PluginParameters::AddFileName (const TCollection_AsciiString& thePluginName,
const TCollection_AsciiString& theFileName)
{
if (myFileNames.IsBound(thePluginName))
myFileNames.ChangeFind(thePluginName).Append (theFileName);
if (myFileNames.IsBound (thePluginName))
myFileNames.ChangeFind (thePluginName).Append (theFileName);
else
{
NCollection_List<TCollection_AsciiString> aNames;
@@ -103,7 +95,7 @@ void TInspectorAPI_PluginParameters::SetSelected (const TCollection_AsciiString&
// =======================================================================
bool TInspectorAPI_PluginParameters::FindParameters (const TCollection_AsciiString& thePluginName)
{
return myParameters.IsBound(thePluginName);
return myParameters.IsBound (thePluginName);
}
// =======================================================================
@@ -122,7 +114,7 @@ const NCollection_List<Handle(Standard_Transient)>& TInspectorAPI_PluginParamete
// =======================================================================
bool TInspectorAPI_PluginParameters::FindFileNames (const TCollection_AsciiString& thePluginName)
{
return myFileNames.IsBound(thePluginName);
return myFileNames.IsBound (thePluginName);
}
// =======================================================================
@@ -141,7 +133,7 @@ const NCollection_List<TCollection_AsciiString>& TInspectorAPI_PluginParameters:
// =======================================================================
bool TInspectorAPI_PluginParameters::FindSelectedNames (const TCollection_AsciiString& thePluginName)
{
return mySelectedItemNames.IsBound(thePluginName);
return mySelectedItemNames.IsBound (thePluginName);
}
// =======================================================================
@@ -163,3 +155,131 @@ Standard_Boolean TInspectorAPI_PluginParameters::GetSelectedObjects (const TColl
{
return mySelectedObjects.Find (thePluginName, theObjects);
}
// =======================================================================
// function : toString
// purpose :
// =======================================================================
TCollection_AsciiString toString (const TopLoc_Location& theLocation)
{
TCollection_AsciiString anInfo;
gp_Trsf aTrsf = theLocation.Transformation();
for (int aRowId = 1; aRowId <= 3; aRowId++)
{
if (!anInfo.IsEmpty())
anInfo += " ";
for (int aColumnId = 1; aColumnId <= 4; aColumnId++)
{
if (aColumnId > 1)
anInfo += ",";
anInfo += TCollection_AsciiString (aTrsf.Value (aRowId, aColumnId));
}
}
return anInfo;
}
// =======================================================================
// function : ParametersToString
// purpose :
// =======================================================================
TCollection_AsciiString TInspectorAPI_PluginParameters::ParametersToString (const TopoDS_Shape& theShape)
{
const TopLoc_Location& aLocation = theShape.Location();
TCollection_AsciiString aLocationStr = toString (aLocation);
TopAbs_Orientation anOrientation = theShape.Orientation();
Standard_SStream aSStream;
TopAbs::Print (anOrientation, aSStream);
return TCollection_AsciiString (aSStream.str().c_str()) + ":" + aLocationStr;
}
// =======================================================================
// function : fromString
// purpose :
// =======================================================================
TopLoc_Location fromString (const TCollection_AsciiString& theValue)
{
NCollection_Mat4<Standard_Real> aValues;
TCollection_AsciiString aCurrentString = theValue;
Standard_Integer aPosition = aCurrentString.Search (" ");
if (aPosition < 0)
return TopLoc_Location();
TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
Standard_Integer aRow = 0;
while (!aCurrentString.IsEmpty())
{
TCollection_AsciiString aValueString = aCurrentString;
aPosition = aValueString.Search (",");
if (aPosition < 0 )
break;
aCurrentString = aValueString.Split (aPosition);
Standard_Integer aColumn = 0;
while (!aValueString.IsEmpty())
{
aPosition = aCurrentString.Search (" ");
if (aPosition > 0)
aValueString.Split (aValueString.Length() - 1);
aValues.SetValue (aRow, aColumn, aValueString.RealValue());
aColumn++;
if (aCurrentString.IsEmpty())
break;
aValueString = aCurrentString;
aPosition = aValueString.Search (",");
if (aPosition < 0 )
{
aValueString = aCurrentString;
aCurrentString = TCollection_AsciiString();
}
else
aCurrentString = aValueString.Split (aPosition);
}
if (aTailString.IsEmpty())
break;
aCurrentString = aTailString;
aPosition = aCurrentString.Search (" ");
if (aPosition < 0 )
{
aCurrentString = aTailString;
aTailString = TCollection_AsciiString();
}
else
aTailString = aCurrentString.Split (aPosition);
aRow++;
}
//if (aValues.Rows() != 3 || aValues.Cols() != 4)
// return TopLoc_Location();
gp_Trsf aTrsf;
aTrsf.SetValues (aValues.GetValue (0, 0), aValues.GetValue (0, 1), aValues.GetValue (0, 2), aValues.GetValue (0, 3),
aValues.GetValue (1, 0), aValues.GetValue (1, 1), aValues.GetValue (1, 2), aValues.GetValue (1, 3),
aValues.GetValue (2, 0), aValues.GetValue (2, 1), aValues.GetValue (2, 2), aValues.GetValue (2, 3));
return TopLoc_Location (aTrsf);
}
// =======================================================================
// function : ParametersToShape
// purpose :
// =======================================================================
void TInspectorAPI_PluginParameters::ParametersToShape (const TCollection_AsciiString& theValue,
TopoDS_Shape& theShape)
{
int aSeparatorPos = theValue.Search (":");
TCollection_AsciiString anOrientationStr = theValue;
TCollection_AsciiString aLocationStr = anOrientationStr.Split (aSeparatorPos);
// orientation
if (anOrientationStr.Length() < 2)
return;
anOrientationStr.Split (anOrientationStr.Length() - 1);
TopAbs_Orientation anOrientation;
if (!TopAbs::ShapeOrientationFromString (anOrientationStr.ToCString(), anOrientation))
return;
// location
TopLoc_Location aLocation = fromString (aLocationStr);
theShape.Location (aLocation);
theShape.Orientation (anOrientation);
}

View File

@@ -21,7 +21,9 @@
#include <Standard_Version.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Shape.hxx>
#include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
class TInspectorAPI_PluginParameters;
DEFINE_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
@@ -36,7 +38,7 @@ class TInspectorAPI_PluginParameters : public Standard_Transient
public:
//! Constructs the container.
Standard_EXPORT TInspectorAPI_PluginParameters();
Standard_EXPORT TInspectorAPI_PluginParameters() {}
//! Destructor
Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() Standard_OVERRIDE {}
@@ -81,8 +83,7 @@ public:
//! Returns parameters set for the given plugin
//! \param thePluginName a plugin name
//! \return container of objects
Standard_EXPORT const NCollection_List<Handle(Standard_Transient)>& Parameters (
const TCollection_AsciiString& thePluginName);
Standard_EXPORT const NCollection_List<Handle(Standard_Transient)>& Parameters (const TCollection_AsciiString& thePluginName);
//! Returns true if there are file names set for the given plugin
//! \param thePluginName a plugin name
@@ -92,8 +93,7 @@ public:
//! Returns file names set for the given plugin
//! \param thePluginName a plugin name
//! \return container of names
Standard_EXPORT const NCollection_List<TCollection_AsciiString>& FileNames(
const TCollection_AsciiString& thePluginName);
Standard_EXPORT const NCollection_List<TCollection_AsciiString>& FileNames (const TCollection_AsciiString& thePluginName);
//! Returns true if there are file names set for the given plugin
//! \param thePluginName a plugin name
@@ -112,6 +112,36 @@ public:
Standard_EXPORT Standard_Boolean GetSelectedObjects (const TCollection_AsciiString& thePluginName,
NCollection_List<Handle(Standard_Transient)>& theObjects);
//! Sets path to a directory for temporary plugin files
//! \param thePath a path
virtual void SetTemporaryDirectory (const TCollection_AsciiString& thePath) { myTemporaryDirectory = thePath; }
//! Returns path to a directory for temporary plugin files
//! \return path
TCollection_AsciiString GetTemporaryDirectory() const { return myTemporaryDirectory; }
//! Returns plugin preferences
//! \param thePluginName a plugin name
Standard_EXPORT virtual void GetPreferences (const TCollection_AsciiString& thePluginName,
TInspectorAPI_PreferencesDataMap& theItem) = 0;
//! Stores plugin preferences
//! \param thePluginName a plugin name
//! \theItem container of plugin preferences values in form: <name, value>
Standard_EXPORT virtual void SetPreferences (const TCollection_AsciiString& thePluginName,
const TInspectorAPI_PreferencesDataMap& theItem) = 0;
//! Converts a Shape parameters excepting TShape into a string value
//! \param theShape processed shape
//! \return string instance
Standard_EXPORT static TCollection_AsciiString ParametersToString (const TopoDS_Shape& theShape);
//! Converts a Shape parameters exceptin TShape into a string value
//! \param theValue parameters string value (without TShape information)
//! \param theShape processed shape
Standard_EXPORT static void ParametersToShape (const TCollection_AsciiString& theValue, TopoDS_Shape& theShape);
#if OCC_VERSION_HEX <= 0x060901
DEFINE_STANDARD_RTTI (TInspectorAPI_PluginParameters)
#else
@@ -126,6 +156,8 @@ private:
NCollection_DataMap<TCollection_AsciiString, NCollection_List<TCollection_AsciiString> > mySelectedItemNames;
//! container of select objects
NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > mySelectedObjects;
//! temporary directory for saving plugin preferences
TCollection_AsciiString myTemporaryDirectory;
};
#endif

View File

@@ -0,0 +1,25 @@
// 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.
#ifndef TInspectorAPI_PreferencesDataMap_H
#define TInspectorAPI_PreferencesDataMap_H
#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
typedef NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> TInspectorAPI_PreferencesDataMap;
typedef NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>::Iterator TInspectorAPI_IteratorOfPreferencesDataMap;
#endif