1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
// 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 ShapeView_Window_H
#define ShapeView_Window_H
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
#include <inspector/TInspectorAPI_PluginParameters.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QItemSelection>
#include <QList>
#include <QModelIndexList>
#include <QObject>
#include <QPoint>
#include <QString>
#include <QTreeView>
#include <Standard_WarningsRestore.hxx>
class View_Window;
class QAction;
class QMainWindow;
class QWidget;
//! \class ShapeView_Window
//! Window that unites all ShapeView controls.
class ShapeView_Window : public QObject
{
Q_OBJECT
public:
//! Constructor
Standard_EXPORT ShapeView_Window (QWidget* theParent);
//! Destructor
Standard_EXPORT virtual ~ShapeView_Window();
//! Provides the container with a parent where this container should be inserted.
//! If Qt implementation, it should be QWidget with QLayout set inside
//! \param theParent a parent class
Standard_EXPORT void SetParent (void* theParent);
//! Sets parameters container, it should be used when the plugin is initialized or in update content
//! \param theParameters a parameters container
void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
//! 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);
//! Returns plugin preferences: dock widgets state, tree view columns.
//! \param theItem container of preference elements
Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
//! Applies plugin preferences
//! \param theItem container of preference elements
Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
//! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
Standard_EXPORT void UpdateContent();
//! Returns main control
QMainWindow* GetMainWindow() const { return myMainWindow; }
//! Returns current tree view
QTreeView* GetTreeView() const { return myTreeView; }
//! Returns path to temporary directory
TCollection_AsciiString GetTemporaryDirectory() const { return myParameters->GetTemporaryDirectory(); }
//! Removes all shapes in tree view model, remove all stored BREP files
Standard_EXPORT void RemoveAllShapes();
protected:
//! Appends shape into tree view model
//! \param theShape a shape instance
Standard_EXPORT void addShape (const TopoDS_Shape& theShape);
private:
//! Fills controls of the plugin by parameters:
//! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
//! \param theParameters a parameters container
void Init (NCollection_List<Handle(Standard_Transient)>& theParameters);
//! Read Shape from the file name, add Shape into tree view
//! \param theFileName BREP file name
void OpenFile (const TCollection_AsciiString& theFileName);
protected slots:
//! Shows context menu for tree view selected item. It contains expand/collapse actions.
//! \param thePosition a clicked point
void onTreeViewContextMenuRequested (const QPoint& thePosition);
//! Updates visibility states by erase all in context
void onEraseAllPerformed();
//! Exports shape to BREP file and view result file
void onBREPDirectory();
//! Removes all shapes in tree view
void onClearView() { RemoveAllShapes(); }
//! Load BREP file and updates tree model to have shape of the file
void onLoadFile();
//! View BREP files of selected items if exist
void onBREPView();
//! Remove BREP views, close views
void onCloseAllBREPViews();
//! Remove all BREP Viewse excepting active
void onEditorDestroyed (QObject* theObject);
//! Convers file name to Ascii String and perform opeging file
//! \param theFileName a file name to be opened
void onOpenFile(const QString& theFileName) { OpenFile (TCollection_AsciiString (theFileName.toUtf8().data())); }
protected:
//! Views file name content in a text editor. It creates new Qt free control with content.
//! \param theFileName a file name
void viewFile (const QString& theFileName);
//! Removes all BREP files in tmp directory
void removeBREPFiles();
//! Creates new action and connect it to the given slot
//! \param theText an action text
//! \param theSlot a listener method
QAction* createAction (const QString& theText, const char* theSlot);
//! Key that uses to generate BREP file name
//! \return string value
static TCollection_AsciiString viewBREPPrefix() { return "ShapeView_Window"; }
//! Returns newxt temporary name using BREPPrefix and pointer information
//! \param thePointerInfo a pointer value
//! \return string value
TCollection_AsciiString getNextTmpName (const TCollection_AsciiString& thePointerInfo);
private:
QMainWindow* myMainWindow; //!< main control, parent for all ShapeView controls
View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
QTreeView* myTreeView; //!< tree view visualized shapes
int myNextPosition; //!< delta of moving control of view BREP file
QList<QWidget*> myBREPViews; //!< list of view BREP file controls
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
};
#endif
|