#include <qlabel.h>
#include <qfont.h>
#include <qapplication.h>
+#include <qregexp.h>
#ifdef WIN32
#include <windows.h>
QStringList modList;
- // parse command line arguments
- int nbArgs = qApp->argc();
- char** CmdLine = qApp->argv();
- QString CmdStr;
- for ( int i = 0; i < nbArgs; i++ )
- {
- CmdStr.append(CmdLine[i]);
- CmdStr.append(" ");
- }
- int startId = CmdStr.find("--modules (");
- if ( startId != -1 ) { // application launch with --modules option
- startId = CmdStr.find("(", startId);
- int stopId = CmdStr.find(" )", startId);
- QString ModStr = CmdStr.mid( startId+1, stopId - (startId+1) ).stripWhiteSpace();
- int i = 0;
- while ( i < ModStr.length() )
- {
- int nextId = ModStr.find( ":", i );
- modList.append( ModStr.mid( i, nextId - i ).stripWhiteSpace() );
- i = nextId + 1;
+ QStringList args;
+ for (int i = 1; i < qApp->argc(); i++)
+ args.append( qApp->argv()[i] );
+
+ QRegExp rx("--modules\\s+\\(\\s*(.*)\\s*\\)");
+ rx.setMinimal( true );
+ if ( rx.search( args.join(" ") ) >= 0 && rx.capturedTexts().count() > 0 ) {
+ QString modules = rx.capturedTexts()[1];
+ QStringList mods = QStringList::split(":",modules,false);
+ for ( uint i = 0; i < mods.count(); i++ ) {
+ if ( !mods[i].stripWhiteSpace().isEmpty() )
+ modList.append( mods[i].stripWhiteSpace() );
}
}
- else {
- QString modStr = resMgr->stringValue( "launch", "modules", QString::null );
- modList = QStringList::split( ",", modStr );
+ if ( modList.isEmpty() ) {
+ QString mods = resMgr->stringValue( "launch", "modules", QString::null );
+ modList = QStringList::split( ",", mods );
}
for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
#include "LightApp_Application.h"
#include "LightApp_DataModel.h"
+#include "LightApp_DataObject.h"
#include "LightApp_Study.h"
#include "LightApp_Preferences.h"
#include "LightApp_Selection.h"
/*!Update object browser.
* For updating model or whole object browser use update() method can be used.
*/
-void LightApp_Module::updateObjBrowser( bool updateDataModel, SUIT_DataObject* root )
-{
- if( updateDataModel )
- if( CAM_DataModel* aDataModel = dataModel() )
- if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
- aModel->update( 0, dynamic_cast<LightApp_Study*>( getApp()->activeStudy() ) );
- getApp()->objectBrowser()->updateTree( root );
+void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel,
+ SUIT_DataObject* theDataObject )
+{
+ SUIT_DataObject* aDataObject = theDataObject;
+ if( theIsUpdateDataModel ){
+ if( CAM_DataModel* aDataModel = dataModel() ){
+ if ( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) ) {
+ SUIT_DataObject* aParent = NULL;
+ if(theDataObject && theDataObject != aDataModel->root())
+ aParent = theDataObject->parent();
+
+ LightApp_DataObject* anObject = dynamic_cast<LightApp_DataObject*>(theDataObject);
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(getApp()->activeStudy());
+ aModel->update( anObject, aStudy );
+
+ if(aParent && aParent->childPos(anObject) < 0)
+ aDataObject = dynamic_cast<LightApp_DataObject*>(aParent);
+ }
+ }
+ }
+ getApp()->objectBrowser()->updateTree( aDataObject );
}
/*!NOT IMPLEMENTED*/
return 0;
}
-/*!
- * \brief Virtual public
- *
- * This method is called just before the study document is saved, so the module has a possibility
- * to store visual parameters in AttributeParameter attribue(s)
- */
-void LightApp_Module::storeVisualParameters(int savePoint) {}
-
-/*!
- * \brief Virtual public
- *
- * This method is called after the study document is opened, so the module has a possibility to restore
- * visual parameters
- */
-void LightApp_Module::restoreVisualParameters(int savePoint) {}
-
-
void LightApp_Module::onShowHide()
{
if( !sender()->inherits( "QAction" ) || !popupMgr() )
virtual LightApp_Displayer* displayer();
- virtual void storeVisualParameters(int savePoint);
- virtual void restoreVisualParameters(int savePoint);
-
public slots:
virtual bool activateModule( SUIT_Study* );
virtual bool deactivateModule( SUIT_Study* );
if ( myBrowser ) {
connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
}
+
+ setModified();
}
/*!
if ( !myBrowser )
return;
- QMap<QString, LightApp_DataObject*> themap;
- fillEntries( themap );
+ if( myEntries.count() == 0 ||
+ myModifiedTime < myBrowser->getModifiedTime() )
+ fillEntries( myEntries );
DataObjectList objList;
for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it )
{
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
- if ( owner && themap.contains( owner->entry() ) )
- objList.append( themap[owner->entry()] );
+ if ( owner && myEntries.contains( owner->entry() ) )
+ objList.append( myEntries[owner->entry()] );
}
myBrowser->setSelected( objList );
if ( obj )
entires.insert( obj->entry(), obj );
}
+
+ setModified();
+}
+
+/*!Update modified time.*/
+void LightApp_OBSelector::setModified()
+{
+ myModifiedTime = clock();
}
/*!Return "ObjectBrowser"*/
virtual QString type() const { return "ObjectBrowser"; }
+ void setModified();
+ unsigned long getModifiedTime() { return myModifiedTime; }
+
private slots:
void onSelectionChanged();
private:
OB_Browser* myBrowser;
SUIT_DataOwnerPtrList mySelectedList;
+
+ QMap<QString, LightApp_DataObject*> myEntries;
+
+ unsigned long myModifiedTime;
};
#endif
#include "LightApp_Preferences.h"
-#include <qvbox.h>
+#include "QtxResourceMgr.h"
+
+#include <qbutton.h>
#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qvbox.h>
/*!
Constructor.
connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+
+ QButton* defBtn = userButton( insertButton( tr( "DEFAULT_BTN_TEXT" ) ) );
+ if ( defBtn )
+ connect( defBtn, SIGNAL( clicked() ), this, SLOT( onDefault() ) );
}
/*!
myPrefs->toBackup();
mySaved = true;
}
+
+/*! Restore default preferences*/
+void LightApp_PreferencesDlg::onDefault()
+{
+ if( QMessageBox::Ok == QMessageBox::information( this, tr( "WARNING" ), tr( "DEFAULT_QUESTION" ), QMessageBox::Ok, QMessageBox::Cancel ) )
+ {
+ if ( myPrefs && myPrefs->resourceMgr() )
+ {
+ bool prev = myPrefs->resourceMgr()->ignoreUserValues();
+ myPrefs->resourceMgr()->setIgnoreUserValues( true );
+ myPrefs->retrieve();
+ myPrefs->resourceMgr()->setIgnoreUserValues( prev );
+ }
+ }
+}
private slots:
void onHelp();
void onApply();
+ void onDefault();
private:
LightApp_Preferences* myPrefs;
//================================================================
bool LightApp_Study::isComponent( const QString& entry ) const
{
+ if( !root() )
+ return false;
+
+ DataObjectList ch;
+ root()->children( ch );
+ DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( *anIt );
+ if( obj && obj->entry()==entry )
+ return true;
+ }
return false;
}
#include "LightApp_VTKSelector.h"
#include "LightApp_DataOwner.h"
-#include "SVTK_ViewModel.h"
+#include "SVTK_ViewModelBase.h"
#include "SVTK_Selector.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_Functor.h"
*/
LightApp_SVTKDataOwner
::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
- const TColStd_IndexedMapOfInteger& theIds,
- Selection_Mode theMode,
- SALOME_Actor* theActor):
+ const TColStd_IndexedMapOfInteger& theIds,
+ Selection_Mode theMode,
+ SALOME_Actor* theActor):
LightApp_DataOwner( theIO ),
mySelectionMode(theMode),
myActor(theActor)
Constructor.
*/
LightApp_VTKSelector
-::LightApp_VTKSelector( SVTK_Viewer* viewer,
- SUIT_SelectionMgr* mgr ):
+::LightApp_VTKSelector( SVTK_ViewModelBase* viewer,
+ SUIT_SelectionMgr* mgr ):
SUIT_Selector( mgr, viewer ),
myViewer( viewer )
{
/*!
Gets viewer.
*/
-SVTK_Viewer*
+SVTK_ViewModelBase*
LightApp_VTKSelector
::viewer() const
{
}
/*!
- Gets type of vtk viewer.
+ Gets type of salome vtk viewer.
*/
QString
LightApp_VTKSelector
::type() const
{
- return SVTK_Viewer::Type();
+ return myViewer->getType();
}
/*!
TColStd_IndexedMapOfInteger anIds;
aSelector->GetIndex(anIO,anIds);
SALOME_Actor* anActor = aSelector->GetActor(anIO);
- if( !anActor )
- anActor = VTK::Find<SALOME_Actor>(aView->getRenderer()->GetActors(),VTK::TIsSameIObject<SALOME_Actor>(anIO));
-
+ if( !anActor ){
+ using namespace SVTK;
+ anActor = Find<SALOME_Actor>(aView->getRenderer()->GetActors(),TIsSameIObject<SALOME_Actor>(anIO));
+ }
aList.append(new LightApp_SVTKDataOwner(anIO,anIds,aMode,anActor));
}
}
#include "SALOME_InteractiveObject.hxx"
class SALOME_Actor;
-class SVTK_Viewer;
+class SVTK_ViewModelBase;
/*!
Provide salome vtk data owner list.
Q_OBJECT;
public:
- LightApp_VTKSelector( SVTK_Viewer*, SUIT_SelectionMgr* );
+ LightApp_VTKSelector( SVTK_ViewModelBase*, SUIT_SelectionMgr* );
virtual ~LightApp_VTKSelector();
- SVTK_Viewer* viewer() const;
+ SVTK_ViewModelBase* viewer() const;
virtual QString type() const;
virtual void setSelection( const SUIT_DataOwnerPtrList& );
private:
- SVTK_Viewer* myViewer;
+ SVTK_ViewModelBase* myViewer;
};
#endif
EXPORT_HEADERS = SALOME_InteractiveObject.hxx \
Handle_SALOME_InteractiveObject.hxx \
- SALOME_Actor.h \
SALOME_GLOwner.h \
SALOME_AISShape.hxx \
Handle_SALOME_AISShape.hxx \
LIB = libSalomeObject.la
LIB_SRC = SALOME_InteractiveObject.cxx \
- SALOME_Actor.cxx \
SALOME_GLOwner.cxx \
SALOME_AISShape.cxx\
SALOME_AISObject.cxx\
+++ /dev/null
-// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SALOME_Actor.cxx
-// Author : Nicolas REJNERI
-// Module : SALOME
-// $Header$
-
-/*!
- \class SALOME_Actor SALOME_Actor.h
- \brief Abstract class of SALOME Objects in VTK.
-*/
-
-
-#include "SALOME_Actor.h"
-
-#include "VTKViewer_Transform.h"
-#include "VTKViewer_TransformFilter.h"
-#include "VTKViewer_PassThroughFilter.h"
-#include "VTKViewer_GeometryFilter.h"
-
-// SALOME Includes
-//#include "utilities.h"
-
-// VTK Includes
-#include <vtkCell.h>
-#include <vtkRenderer.h>
-#include <vtkPolyData.h>
-#include <vtkObjectFactory.h>
-#include <vtkDataSetMapper.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkProperty.h>
-
-//using namespace std;
-
-
-#if defined __GNUC__
- #if __GNUC__ == 2
- #define __GNUC_2__
- #endif
-#endif
-
-int SALOME_POINT_SIZE = 3;
-
-
-vtkStandardNewMacro(SALOME_Actor);
-
-
-SALOME_Actor::SALOME_Actor(){
- myIsHighlighted = myIsPreselected = false;
-
- myRepresentation = 1;
- myDisplayMode = myRepresentation - 1;
-
- myProperty = vtkProperty::New();
- PreviewProperty = NULL;
-
- myIsInfinite = false;
-
- myIsResolveCoincidentTopology = true;
-
- vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
- myPolygonOffsetUnits);
- myStoreMapping = false;
- myGeomFilter = VTKViewer_GeometryFilter::New();
-
- myTransformFilter = VTKViewer_TransformFilter::New();
-
- for(int i = 0; i < 6; i++)
- myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
-}
-
-
-SALOME_Actor::~SALOME_Actor(){
- SetPreviewProperty(NULL);
-
- myGeomFilter->UnRegisterAllOutputs();
- myGeomFilter->Delete();
-
- myTransformFilter->UnRegisterAllOutputs();
- myTransformFilter->Delete();
-
- for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
- if(myPassFilter[i]){
- myPassFilter[i]->UnRegisterAllOutputs();
- myPassFilter[i]->Delete();
- }
- }
-
- myProperty->Delete();
-}
-
-
-void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){
- theRenderer->AddActor(this);
-}
-
-void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){
- theRenderer->RemoveActor(this);
-}
-
-
-void SALOME_Actor::SetTransform(VTKViewer_Transform* theTransform){
- myTransformFilter->SetTransform(theTransform);
-}
-
-
-void SALOME_Actor::SetMapper(vtkMapper* theMapper){
- InitPipeLine(theMapper);
-}
-
-void SALOME_Actor::InitPipeLine(vtkMapper* theMapper){
- if(theMapper){
- int anId = 0;
- myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
- myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 1
- myGeomFilter->SetStoreMapping( myStoreMapping );
- myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 2
- myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() );
- myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 3
- myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
-
- anId++; // 4
- myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
- myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 5
- if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper)){
- aMapper->SetInput(myPassFilter[anId]->GetOutput());
- }else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper)){
- aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput());
- }
- }
- vtkLODActor::SetMapper(theMapper);
-}
-
-
-void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper* m){
- if(myIsResolveCoincidentTopology){
- int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
- float aFactor, aUnit;
- vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
-
- vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
- vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
- myPolygonOffsetUnits);
- vtkLODActor::Render(ren,m);
-
- vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
- vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
- }else{
- vtkLODActor::Render(ren,m);
- }
-}
-
-
-void SALOME_Actor::SetResolveCoincidentTopology(bool theIsResolve) {
- myIsResolveCoincidentTopology = theIsResolve;
-}
-
-void SALOME_Actor::SetPolygonOffsetParameters(float factor, float units){
- myPolygonOffsetFactor = factor;
- myPolygonOffsetUnits = units;
-}
-
-void SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units){
- factor = myPolygonOffsetFactor;
- units = myPolygonOffsetUnits;
-}
-
-
-vtkDataSet* SALOME_Actor::GetInput(){
- return myPassFilter.front()->GetOutput();
-}
-
-
-unsigned long int SALOME_Actor::GetMTime(){
- unsigned long mTime = this->Superclass::GetMTime();
- unsigned long time = myTransformFilter->GetMTime();
- mTime = ( time > mTime ? time : mTime );
- if(vtkDataSet *aDataSet = myPassFilter[0]->GetInput()){
- time = aDataSet->GetMTime();
- mTime = ( time > mTime ? time : mTime );
- }
- return mTime;
-}
-
-
-void SALOME_Actor::SetRepresentation(int theMode) {
- switch(myRepresentation){
- case VTK_POINTS :
- case VTK_SURFACE :
- myProperty->DeepCopy(GetProperty());
- }
- switch(theMode){
- case VTK_POINTS :
- case VTK_SURFACE :
- GetProperty()->DeepCopy(myProperty);
- break;
- default:
- GetProperty()->SetAmbient(1.0);
- GetProperty()->SetDiffuse(0.0);
- GetProperty()->SetSpecular(0.0);
- }
- switch(theMode){
- case 3 :
- myGeomFilter->SetInside(true);
- GetProperty()->SetRepresentation(1);
- break;
- case VTK_POINTS :
- GetProperty()->SetPointSize(SALOME_POINT_SIZE);
- default :
- GetProperty()->SetRepresentation(theMode);
- myGeomFilter->SetInside(false);
- }
- myRepresentation = theMode;
-}
-
-int SALOME_Actor::GetRepresentation(){
- return myRepresentation;
-}
-
-
-vtkCell* SALOME_Actor::GetElemCell(int theObjID){
- return GetInput()->GetCell(theObjID);
-}
-
-
-float* SALOME_Actor::GetNodeCoord(int theObjID){
- return GetInput()->GetPoint(theObjID);
-}
-
-
-//=================================================================================
-// function : GetObjDimension
-// purpose : Return object dimension.
-// Virtual method shoulb be redifined by derived classes
-//=================================================================================
-int SALOME_Actor::GetObjDimension( const int theObjId )
-{
- if ( vtkCell* aCell = GetElemCell(theObjId) )
- return aCell->GetCellDimension();
- return 0;
-}
-
-
-bool SALOME_Actor::IsInfinitive(){
- return myIsInfinite;
-}
-
-
-void SALOME_Actor::SetOpacity(float theOpacity){
- myOpacity = theOpacity;
- GetProperty()->SetOpacity(theOpacity);
-}
-
-float SALOME_Actor::GetOpacity(){
- return myOpacity;
-}
-
-
-void SALOME_Actor::SetColor(float r,float g,float b){
- GetProperty()->SetColor(r,g,b);
-}
-
-void SALOME_Actor::GetColor(float& r,float& g,float& b){
- float aColor[3];
- GetProperty()->GetColor(aColor);
- r = aColor[0];
- g = aColor[1];
- b = aColor[2];
-}
-
-
-int SALOME_Actor::getDisplayMode(){
- return myDisplayMode;
-}
-
-void SALOME_Actor::setDisplayMode(int theMode){
- SetRepresentation(theMode+1);
- myDisplayMode = GetRepresentation() - 1;
-}
+++ /dev/null
-// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SALOME_Actor.h
-// Author : Nicolas REJNERI
-// Module : SALOME
-// $Header$
-
-#ifndef SALOME_ACTOR_H
-#define SALOME_ACTOR_H
-
-#include "SALOME_InteractiveObject.hxx" // INCLUDES "using namespace std"
-#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include "Handle_SALOME_InteractiveObject.hxx"
-#endif
-
-#include <vtkLODActor.h> // INCLUDES "stdio.h"
-#include <vtkProperty.h>
-
-// to overcome the conflict between std::ostream and io::ostream
-// the following variable must be defined:
-// VTK_USE_ANSI_STDLIB
-
-#include <vector>
-
-class vtkCell;
-class vtkDataSet;
-class vtkPolyData;
-class vtkCamera;
-class vtkProperty;
-
-class VTKViewer_Transform;
-class VTKViewer_GeometryFilter;
-class VTKViewer_TransformFilter;
-class VTKViewer_PassThroughFilter;
-
-extern int SALOME_POINT_SIZE;
-
-#ifdef WNT
-#define SALOME_OBJECT_EXPORT __declspec (dllexport)
-#else
-#define SALOME_OBJECT_EXPORT
-#endif
-
-#include <VTKViewer_Actor.h>
-
-class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor {
- public:
- static SALOME_Actor* New();
-
- vtkTypeMacro(SALOME_Actor,vtkLODActor);
-
- virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
- virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; }
- virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
-
- virtual const char* getName() { return myName.c_str(); }
- virtual void setName(const char* theName){
- if(hasIO()) myIO->setName(theName);
- myName = theName;
- }
-
- // To generate highlight automaticaly
- virtual bool hasHighlight() { return false; }
- virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
- virtual bool isHighlighted() { return myIsHighlighted; }
-
- virtual void SetOpacity(float theOpacity);
- virtual float GetOpacity();
-
- virtual void SetColor(float r,float g,float b);
- virtual void GetColor(float& r,float& g,float& b);
- void SetColor(const float theRGB[3]){
- SetColor(theRGB[0],theRGB[1],theRGB[2]);
- }
-
- vtkSetObjectMacro(PreviewProperty,vtkProperty);
-
- virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
-
-
- // Used to obtain all dependent actors
- virtual void GetChildActors(vtkActorCollection*) {};
-
- virtual void AddToRender(vtkRenderer* theRenderer);
- virtual void RemoveFromRender(vtkRenderer* theRenderer);
-
-
- // For selection mapping purpose
- virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
- virtual float* GetNodeCoord(int theObjID);
-
- virtual int GetElemObjId(int theVtkID) { return theVtkID;}
- virtual vtkCell* GetElemCell(int theObjID);
-
- virtual int GetObjDimension( const int theObjId );
-
- virtual void SetMapper(vtkMapper* theMapper);
- virtual vtkDataSet* GetInput();
-
-
- virtual void SetTransform(VTKViewer_Transform* theTransform);
- virtual unsigned long int GetMTime();
-
- virtual void SetRepresentation(int theMode);
- virtual int GetRepresentation();
-
- virtual int getDisplayMode();
- virtual void setDisplayMode(int theMode);
-
- // Infinitive means actor without size (point for example),
- // which is not taken into account in calculation of boundaries of the scene
- void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
- virtual bool IsInfinitive();
-
- void SetResolveCoincidentTopology(bool theIsResolve);
- void SetPolygonOffsetParameters(float factor, float units);
- void GetPolygonOffsetParameters(float& factor, float& units);
-
- virtual void Render(vtkRenderer *, vtkMapper *);
-
- virtual float GetShrinkFactor() { return 1.0;}
-
- virtual bool IsShrunkable() { return false;}
- virtual bool IsShrunk() { return false;}
-
- virtual void SetShrink() {}
- virtual void UnShrink() {}
-
- virtual bool IsSetCamera() const { return false; }
- virtual bool IsResizable() const { return false; }
- virtual void SetSize( const float ) {}
- virtual void SetCamera( vtkCamera* ) {}
-
- protected:
- bool myIsResolveCoincidentTopology;
- float myPolygonOffsetFactor;
- float myPolygonOffsetUnits;
-
- Handle(SALOME_InteractiveObject) myIO;
- std::string myName;
-
- vtkProperty *PreviewProperty;
- bool myIsPreselected;
-
- float myOpacity;
- bool myIsHighlighted;
- int myDisplayMode;
- bool myIsInfinite;
-
- bool myStoreMapping;
- VTKViewer_GeometryFilter *myGeomFilter;
- VTKViewer_TransformFilter *myTransformFilter;
- std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
-
- int myRepresentation;
- vtkProperty *myProperty;
-
- void InitPipeLine(vtkMapper* theMapper);
-
- SALOME_Actor();
- ~SALOME_Actor();
-};
-
-
-#endif // SALOME_ACTOR_H
-
#include "OB_ListItem.h"
#include "OB_ListView.h"
+#include <SUIT_DataObjectIterator.h>
+#include <SUIT_TreeSync.h>
+
#include <qcursor.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwmatrix.h>
#include <qlistview.h>
#include <qpopupmenu.h>
+#include <qdatetime.h>
+
+#include <time.h>
/*!
Class: OB_Browser::ToolTip
tip( aRect, aText );
}
+
+typedef SUIT_DataObject* ObjPtr;
+typedef OB_ListItem* ItemPtr;
+/*!
+ Class: OB_BrowserSync
+ Descr: Auxiliary class for synchronizing tree of SUIT_DataObjects and list view items
+*/
+
+class OB_BrowserSync
+{
+public:
+ OB_BrowserSync( OB_Browser* );
+ bool isEqual( const ObjPtr&, const ItemPtr& ) const;
+ ObjPtr nullSrc() const;
+ ItemPtr nullTrg() const;
+ ItemPtr createItem( const ObjPtr&, const ItemPtr&, const ItemPtr&, const bool ) const;
+ void updateItem( const ItemPtr& ) const;
+ void deleteItemWithChildren( const ItemPtr& ) const;
+ void children( const ObjPtr&, QValueList<ObjPtr>& ) const;
+ void children( const ItemPtr&, QValueList<ItemPtr>& ) const;
+ ItemPtr parent( const ItemPtr& ) const;
+private:
+ bool needUpdate( const ItemPtr& ) const;
+ OB_Browser* myBrowser;
+};
+
+
+OB_BrowserSync::OB_BrowserSync( OB_Browser* ob )
+: myBrowser( ob )
+{
+}
+
+bool OB_BrowserSync::needUpdate( const ItemPtr& item ) const
+{
+ bool update = false;
+ if ( item ) {
+ SUIT_DataObject* obj = item->dataObject();
+ if ( obj ) {
+ // 1. check text
+ update = ( item->text( 0 ) != obj->name() );
+ if ( !update ) {
+ // 2. check pixmap (compare serialNumber()-s)
+ QPixmap objPix = obj->icon();
+ const QPixmap* itemPix = item->pixmap( 0 );
+ update = ( objPix.isNull() && ( itemPix && !itemPix->isNull() ) ) ||
+ ( !objPix.isNull() && ( !itemPix || itemPix->isNull() ) );
+ if ( !update && !objPix.isNull() && itemPix && !itemPix->isNull() ) {
+ int aIconW = objPix.width();
+ if( aIconW > 20 ) {
+ QWMatrix aM;
+ double aScale = 20.0 / aIconW;
+ aM.scale( aScale, aScale );
+ objPix = objPix.xForm( aM );
+ }
+ update = ( objPix.serialNumber() != itemPix->serialNumber() );
+ }
+ }
+ }
+ }
+ return update;
+}
+
+void OB_BrowserSync::updateItem( const ItemPtr& p ) const
+{
+ if ( p && needUpdate( p ) ) {
+ // printf( "--- needUpdate for %s = true ---\n", p->text( 0 ).latin1() );
+ p->update();
+ }
+}
+
+ItemPtr OB_BrowserSync::createItem( const ObjPtr& src,
+ const ItemPtr& parent, const ItemPtr& after,
+ const bool asFirst ) const
+{
+ ItemPtr i = myBrowser ? dynamic_cast<ItemPtr>( myBrowser->createItem( src, parent, after, asFirst ) ) : 0;
+ if( i )
+ i->setOpen( src->isOpen() );
+ return i;
+}
+
+void OB_BrowserSync::deleteItemWithChildren( const ItemPtr& i ) const
+{
+ if( myBrowser && myBrowser->myItems.contains( i->dataObject() ) )
+ {
+ myBrowser->removeReferences( i );
+ delete i;
+ }
+}
+
+bool OB_BrowserSync::isEqual( const ObjPtr& p, const ItemPtr& q ) const
+{
+ return ( !p && !q ) || ( p && q && q->dataObject()==p );
+}
+
+ObjPtr OB_BrowserSync::nullSrc() const
+{
+ return 0;
+}
+
+ItemPtr OB_BrowserSync::nullTrg() const
+{
+ return 0;
+}
+
+void OB_BrowserSync::children( const ObjPtr& p, QValueList<ObjPtr>& ch ) const
+{
+ DataObjectList l;
+ if( p )
+ {
+ p->children( l );
+ ch.clear();
+ for( SUIT_DataObject* o = l.first(); o; o = l.next() )
+ ch.append( o );
+ }
+}
+
+void OB_BrowserSync::children( const ItemPtr& p, QValueList<ItemPtr>& ch ) const
+{
+ for( QListViewItem* item = p->firstChild(); item; item = item->nextSibling() )
+ {
+ ItemPtr p = dynamic_cast<ItemPtr>( item );
+ if( p )
+ ch.append( p );
+ }
+}
+
+ItemPtr OB_BrowserSync::parent( const ItemPtr& p ) const
+{
+ return p ? dynamic_cast<ItemPtr>( p->parent() ) : 0;
+}
+
+
/*!
Class: OB_Browser
Descr: Hierarchical tree object browser.
this, SLOT( onDoubleClicked( QListViewItem* ) ) );
setRootObject( root );
+
+ setModified();
}
OB_Browser::~OB_Browser()
autoOpenBranches();
+ setModified();
+
if ( selNum != numberOfSelected() )
emit selectionChanged();
}
void OB_Browser::updateTree( SUIT_DataObject* obj, const bool autoOpen )
{
+// QTime t1 = QTime::currentTime();
+
if ( !obj && !(obj = getRootObject()) )
return;
if( autoOpen )
autoOpenBranches();
+ setModified();
+
if ( selNum != numberOfSelected() )
emit selectionChanged();
+
+// QTime t2 = QTime::currentTime();
+// qDebug( QString( "update tree time = %1 msecs" ).arg( t1.msecsTo( t2 ) ) );
}
void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg )
autoOpenBranches();
+ setModified();
+
if ( selNum != numberOfSelected() )
emit selectionChanged();
}
-void OB_Browser::updateView( const SUIT_DataObject* theStartObj )
+void OB_Browser::updateView( SUIT_DataObject* startObj )
{
QListView* lv = listView();
if ( !lv )
return;
- if ( !theStartObj || theStartObj->root() != getRootObject() )
+ if ( !startObj || startObj->root() != getRootObject() )
return;
- QListViewItem* after = 0;
- QListViewItem* parent = 0;
- QListViewItem* startItem = listViewItem( theStartObj );
-
- if ( theStartObj->parent() )
- parent = listViewItem( theStartObj->parent() );
-
- QListViewItem* prv = 0;
- QListViewItem* cur = parent ? parent->firstChild() : lv->firstChild();
- while ( !after && cur )
+ if( startObj==myRoot )
{
- if ( cur == startItem )
- after = prv;
+ DataObjectList ch;
+ myRoot->children( ch );
- prv = cur;
- cur = cur->nextSibling();
- }
-
- QPtrList<QListViewItem> delList;
- if ( !startItem && theStartObj == getRootObject() )
- {
- for ( QListViewItem* item = lv->firstChild(); item; item = item->nextSibling() )
- delList.append( item );
- }
- else
- delList.append( startItem );
+ ItemMap exist;
+ QListViewItem* st = lv->firstChild();
+ for( ; st; st = st->nextSibling() )
+ {
+ OB_ListItem* ob_item = dynamic_cast<OB_ListItem*>( st );
+ exist.insert( ob_item->dataObject(), ob_item );
+ }
- for ( QPtrListIterator<QListViewItem> it( delList ); it.current(); ++it )
- {
- removeReferences( it.current() );
- delete it.current();
- }
+ SUIT_DataObject* local_root = ch.first();
+ for( ; local_root; local_root = ch.next() )
+ {
+ OB_BrowserSync sync( this );
+ OB_ListItem* local_item = dynamic_cast<OB_ListItem*>( listViewItem( local_root ) );
+
+ // QString srcName = ( local_root && !local_root->name().isNull() ) ? local_root->name() : "";
+ // QString trgName = ( local_item && !local_item->text(0).isNull() ) ? local_item->text(0) : "";
+ // printf( "--- OB_Browser::updateView() calls synchronize()_1: src = %s, trg = %s ---\n", srcName.latin1(), trgName.latin1() );
+
+ synchronize<ObjPtr,ItemPtr,OB_BrowserSync>( local_root, local_item, sync );
+ exist[local_root] = 0;
+ }
- // for myRoot object, if myShowRoot==false, then creating multiple top-level QListViewItem-s
- // (which will correspond to myRoot's children = Modules).
- if ( rootIsDecorated() && theStartObj == myRoot )
- {
- DataObjectList lst;
- theStartObj->children( lst );
- DataObjectListIterator it ( lst );
- // iterating backward to preserve the order of elements in the tree
- for ( it.toLast(); it.current(); --it )
- createTree( it.current(), 0, 0 );
+ ItemMap::const_iterator anIt = exist.begin(), aLast = exist.end();
+ for( ; anIt!=aLast; anIt++ )
+ if( anIt.data() )
+ {
+ removeReferences( anIt.data() );
+ OB_ListItem* item = dynamic_cast<OB_ListItem*>( anIt.data() );
+ if( item && myItems.contains( item->dataObject() ) )
+ delete anIt.data();
+ }
}
else
- createTree( theStartObj, parent, after ? after : parent );
-}
-
-QListViewItem* OB_Browser::createTree( const SUIT_DataObject* obj,
- QListViewItem* parent, QListViewItem* after )
-{
- if ( !obj )
- return 0;
-
- QListViewItem* item = createItem( obj, parent, after );
-
- DataObjectList lst;
- obj->children( lst );
- for ( DataObjectListIterator it ( lst ); it.current(); ++it )
- createTree( it.current(), item );
+ {
+ OB_BrowserSync sync( this );
+ OB_ListItem* startItem = dynamic_cast<OB_ListItem*>( listViewItem( startObj ) );
- if ( item )
- item->setOpen( obj->isOpen() );
+ // QString srcName = ( startObj && !startObj->name().isNull() ) ? startObj->name() : "";
+ // QString trgName = ( startItem && !startItem->text(0).isNull() ) ? startItem->text(0) : "";
+ // printf( "--- OB_Browser::updateView() calls synchronize()_2: src = %s, trg = %s ---\n", srcName.latin1(), trgName.latin1() );
- return item;
+ synchronize<ObjPtr,ItemPtr,OB_BrowserSync>( startObj, startItem, sync );
+ }
}
-QListViewItem* OB_Browser::createItem( const SUIT_DataObject* o,
- QListViewItem* parent, QListViewItem* after )
+QListViewItem* OB_Browser::createItem( const SUIT_DataObject* o, QListViewItem* parent,
+ QListViewItem* after, const bool asFirstChild )
{
QListView* lv = listView();
after = after->nextSibling();
}
- if ( after )
+ if ( after && !asFirstChild )
{
if ( type == -1 )
item = new OB_ListItem( obj, parent, after );
myItems.insert( obj, item );
obj->connect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
-
updateText( item );
return item;
return;
}
- if ( !autoUpd )
+ if( !autoUpd )
return;
if ( isAutoUpdate() )
SUIT_DataObject* pObj = item && item->parent() ? dataObject( item->parent() ) : 0;
updateTree( pObj, false );
}
- else
- delete item;
+
+ delete item;
}
void OB_Browser::autoOpenBranches()
if ( item )
emit doubleClicked( dataObject( item ) );
}
+
+void OB_Browser::setModified()
+{
+ myModifiedTime = clock();
+}
+
class QToolTip;
class OB_Filter;
class OB_ListView;
+class OB_ListItem;
class OB_EXPORT OB_Browser : public QFrame, public SUIT_PopupClient
{
virtual void contextMenuPopup( QPopupMenu* );
+ void setModified();
+ unsigned long getModifiedTime() { return myModifiedTime; }
+
signals:
void selectionChanged();
void doubleClicked( SUIT_DataObject* );
protected:
void adjustWidth( QListViewItem* );
- virtual void updateView( const SUIT_DataObject* theStartObj = 0 );
+ virtual void updateView( SUIT_DataObject* = 0 );
virtual void updateText();
virtual void keyPressEvent( QKeyEvent* );
DataObjectKey objectKey( QListViewItem* ) const;
DataObjectKey objectKey( SUIT_DataObject* ) const;
- QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0 );
- QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0 );
+ QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
+ QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
SUIT_DataObject* storeState( DataObjectMap&, DataObjectMap&,
DataObjectKeyMap&, DataObjectKeyMap&, DataObjectKey& ) const;
const DataObjectKeyMap&, const DataObjectKeyMap&, const DataObjectKey& );
private:
+ friend class OB_BrowserSync;
+
OB_ListView* myView;
SUIT_DataObject* myRoot;
ItemMap myItems;
int myAutoOpenLevel;
friend class OB_Browser::ToolTip;
+
+ unsigned long myModifiedTime;
};
#endif
*/
template<class T>
-ListItemF<T>::ListItemF( T& theT, SUIT_DataObject* obj ) :
+ListItemF<T>::ListItemF( T* theT, SUIT_DataObject* obj ) :
myT( theT ),
myObject( obj )
{
}
- p->fillRect( 0, 0, w, myT.height(), cg.brush( QColorGroup::Base ) );
+ p->fillRect( 0, 0, w, myT->height(), cg.brush( QColorGroup::Base ) );
//int itemW = myT.width( p->fontMetrics(), myT.listView(), c );
//myT.paintCell( p, colorGrp, c, itemW, align );
void ListItemF<T>::paintFoc( QPainter* p, QColorGroup& cg, const QRect& r )
{
QRect rect = r;
- rect.setWidth( myT.width( p->fontMetrics(), myT.listView(), 0 ) );
+ rect.setWidth( myT->width( p->fontMetrics(), myT->listView(), 0 ) );
//myT.paintFocus( p, cg, rect );
}
template<class T>
void ListItemF<T>::setSel( bool s )
{
- QListView* lv = myT.listView();
+ QListView* lv = myT->listView();
if ( s && lv && lv->inherits( "OB_ListView" ) )
{
OB_ListView* objlv = (OB_ListView*)lv;
- s = s && objlv->isOk( &myT );
+ s = s && objlv->isOk( myT );
}
//myT.setSelected( s );
if ( !obj )
return;
- myT.setText( 0, obj->name() );
+ QString n = obj->name();
+ if( myT->text( 0 )!=n )
+ myT->setText( 0, n );
- int aIconW = obj->icon().width();
- if ( aIconW > 0 )
+ QPixmap p = obj->icon();
+ int aIconW = p.width();
+ if( aIconW > 0 )
{
- if ( aIconW > 20 )
+ if( aIconW > 20 )
{
QWMatrix aM;
double aScale = 20.0 / aIconW;
aM.scale( aScale, aScale );
- myT.setPixmap( 0, obj->icon().xForm( aM ) );
+ myT->setPixmap( 0, p.xForm( aM ) );
}
else
- myT.setPixmap( 0, obj->icon() );
+ myT->setPixmap( 0, p );
}
- myT.setDragEnabled( obj->isDragable() );
- myT.setDropEnabled( true );
+ myT->setDragEnabled( obj->isDragable() );
+ myT->setDropEnabled( true );
}
/*!
*/
OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent )
-: ListItemF<QListViewItem>( *this, obj ),
+: ListItemF<QListViewItem>( this, obj ),
QListViewItem(parent)
{
- update();
+ update();
}
OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent )
-: ListItemF<QListViewItem>( *this, obj),
+: ListItemF<QListViewItem>( this, obj ),
QListViewItem(parent)
{
- update();
+ update();
}
OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after )
-: ListItemF<QListViewItem>( *this, obj),
+: ListItemF<QListViewItem>( this, obj),
QListViewItem(parent, after )
{
- update();
+ update();
}
OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after )
-: ListItemF<QListViewItem>( *this,obj),
+: ListItemF<QListViewItem>( this,obj),
QListViewItem(parent, after )
{
- update();
+ update();
}
OB_ListItem::~OB_ListItem()
void OB_ListItem::setSelected( bool s )
{
- setSel( s );
- QListViewItem::setSelected( s );
+ setSel( s );
+ QListViewItem::setSelected( s );
}
void OB_ListItem::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r )
*/
OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, Type type )
-: ListItemF<QCheckListItem>( *this, obj),
+: ListItemF<QCheckListItem>( this, obj),
QCheckListItem( parent, "", type )
{
- update();
+ update();
}
OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, Type type )
-: ListItemF<QCheckListItem>( *this, obj),
+: ListItemF<QCheckListItem>( this, obj),
QCheckListItem( parent, "", type )
{
- update();
+ update();
}
OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, Type type )
-: ListItemF<QCheckListItem>( *this, obj),
+: ListItemF<QCheckListItem>( this, obj),
#if defined(QT_VERSION) && QT_VERSION >= 0x030101
QCheckListItem( parent, after, "", type )
#else
QCheckListItem( parent, "", type )
#endif
{
- update();
+ update();
}
OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, Type type )
-: ListItemF<QCheckListItem>( *this, obj),
+: ListItemF<QCheckListItem>( this, obj),
#if defined(QT_VERSION) && QT_VERSION >= 0x030101
QCheckListItem( parent, after, "", type )
#else
QCheckListItem( parent, "", type )
#endif
{
- update();
+ update();
}
OB_CheckListItem::~OB_CheckListItem()
template<class T> class ListItemF
{
public:
- ListItemF(T&, SUIT_DataObject* );
+ ListItemF( T*, SUIT_DataObject* );
/*ListItem( SUIT_DataObject*, QListView* );
ListItem( SUIT_DataObject*, QListViewItem* );
ListItem( SUIT_DataObject*, QListView*, QListViewItem* );
void paintFoc( QPainter* p, QColorGroup& cg, const QRect& r );
void paintC( QPainter* p, QColorGroup& cg, int c, int w, int align );
-protected:
+//protected:
void update();
protected:
SUIT_DataObject* myObject;
- T& myT;
+ T* myT;
};
/*
{
}
+/*!
+ Sets the state "NoChange" for checkbox.
+*/
+void QDS_CheckBox::clear()
+{
+ setStringValue( "-1" );
+}
+
/*!
Returns string from QCheckBox widget.
*/
QString QDS_CheckBox::getString() const
{
- return checkBox() && checkBox()->isChecked() ? "1" : "0";
+ QString val;
+ if ( checkBox() && checkBox()->state() != QButton::NoChange )
+ val = checkBox()->isChecked() ? "1" : "0";
+ return val;
}
/*!
*/
void QDS_CheckBox::setString( const QString& txt )
{
+ if ( !checkBox() )
+ return;
+
bool isOk;
int val = (int)txt.toDouble( &isOk );
- if ( checkBox() )
+ if ( isOk && val < 0 )
+ {
+ checkBox()->setTristate();
+ checkBox()->setNoChange();
+ }
+ else
checkBox()->setChecked( isOk && val != 0 );
}
QCheckBox* cb = new QCheckBox( parent );
connect( cb, SIGNAL( stateChanged( int ) ), SLOT( onParamChanged() ) );
connect( cb, SIGNAL( toggled( bool ) ), SIGNAL( toggled( bool ) ) );
+ connect( cb, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChanged( int ) ) );
return cb;
}
emit paramChanged();
}
+void QDS_CheckBox::onStateChanged( int state )
+{
+ if ( state != QButton::NoChange && checkBox() )
+ checkBox()->setTristate( false );
+}
+
void QDS_CheckBox::setChecked( const bool theState )
{
if ( checkBox() )
bool isChecked() const;
void setChecked( const bool );
+ virtual void clear();
+
signals:
void toggled( bool );
private slots:
void onParamChanged();
+ void onStateChanged( int );
protected:
QCheckBox* checkBox() const;
*/
double QDS_ComboBox::doubleValue() const
{
+ initDatum();
+
QComboBox* cb = comboBox();
QString cur = getString();
if ( cb && cb->count() > 0 && cb->currentItem() >= 0 )
*/
void QDS_ComboBox::setIntegerValue( const int id )
{
+ initDatum();
+
if ( myValue.contains( id ) )
setString( myValue[id] );
else
*/
void QDS_ComboBox::setDoubleValue( const double val )
{
+ initDatum();
+
int id = (int)val;
if ( myValue.contains( id ) )
setString( myValue[id] );
*/
void QDS_ComboBox::setState( const bool on, const QValueList<int>& ids, const bool append )
{
+ initDatum();
+
if ( ids.isEmpty() && append )
return;
*/
void QDS_ComboBox::setValues( const QValueList<int>& ids, const QStringList& names )
{
+ initDatum();
+
if ( ids.count() != names.count() )
return;
*/
void QDS_ComboBox::setValues( const QStringList& names )
{
+ initDatum();
+
QValueList< int > ids;
for ( int i = 0, n = names.count(); i < n; i++ )
ids.append( i );
return sdStr;
}
+QVariant QDS_Datum::value() const
+{
+ QVariant val;
+ if ( !isEmpty() )
+ val = stringValue();
+ return val;
+}
+
QString QDS_Datum::stringValue() const
{
initDatum();
}
}
+void QDS_Datum::setValue( const QVariant& val )
+{
+ if ( val.isValid() && val.canCast( QVariant::String ) )
+ setStringValue( val.toString() );
+ else
+ clear();
+}
+
void QDS_Datum::setStringValue( const QString& txt )
{
initDatum();
#include <qobject.h>
#include <qstring.h>
+#include <qvariant.h>
#include <qguardedptr.h>
#include <DDS_DicItem.h>
QString minimumValue() const;
QString maximumValue() const;
+ virtual QVariant value() const;
+
virtual QString stringValue() const;
virtual double doubleValue() const;
virtual int integerValue() const;
virtual void reset();
virtual void clear();
+ virtual void setValue( const QVariant& );
+
virtual void setStringValue( const QString& );
virtual void setDoubleValue( const double );
virtual void setIntegerValue( const int );
virtual void unitSystemChanged( const QString& );
+ void initDatum() const;
+
private:
void initialize();
- void initDatum() const;
Wrapper* wrapper( QWidget* ) const;
Wrapper* wrapper( const int ) const;
void onTextChanged( const QString& );
protected:
- QLineEdit* lineEdit() const;
virtual QWidget* createControl( QWidget* );
+ QLineEdit* lineEdit() const;
virtual QString getString() const;
virtual void setString( const QString& );
--- /dev/null
+#include "QDS_RadioBox.h"
+
+#include <DDS_Dictionary.h>
+
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_HArray1OfExtendedString.hxx>
+
+#include <qobjectlist.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+
+/*!
+ Constructor.
+*/
+QDS_RadioBox::QDS_RadioBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
+: QDS_Datum( id, parent, flags & ~( Label | Units ), comp )
+{
+}
+
+/*!
+ Destructor.
+*/
+QDS_RadioBox::~QDS_RadioBox()
+{
+}
+
+/*!
+ Returns number of items in ComboBox. If total is 'false' then only
+ visible items are taken into account otherwise all items.
+*/
+int QDS_RadioBox::count( bool total ) const
+{
+ if ( total )
+ return myValue.count();
+ else
+ {
+ QPtrList<QRadioButton> bList;
+ buttons( bList );
+ return bList.count();
+ }
+}
+
+/*!
+ Returns list of ids. If total is 'false' then only visible items
+ are taken into account otherwise all items.
+*/
+void QDS_RadioBox::values( QValueList<int>& ids, bool total ) const
+{
+ ids.clear();
+ for ( QIntList::const_iterator it = myDataIds.begin(); it != myDataIds.end(); ++it )
+ if ( total || ( myState.contains( *it ) && myState[*it] ) )
+ ids.append( *it );
+}
+
+/*!
+ Returns visible state of identificator.
+*/
+bool QDS_RadioBox::state( const int id ) const
+{
+ bool state = false;
+ if ( myState.contains( id ) )
+ state = myState[id];
+ return state;
+}
+
+/*!
+ Sets the visible state of identificator. If 'id' is -1 then specified
+ state will be set to all ids.
+*/
+void QDS_RadioBox::setState( const bool on, const int id, const bool append )
+{
+ QValueList<int> lst;
+ if ( id < 0 )
+ {
+ for ( IdStateMap::Iterator it = myState.begin(); it != myState.end(); ++it )
+ lst.append( it.key() );
+ }
+ else
+ lst.append( id );
+
+ setState( on, lst, append );
+}
+
+/*!
+ Sets the visible state of identificator from the specified list.
+*/
+void QDS_RadioBox::setState( const bool on, const QValueList<int>& ids, const bool append )
+{
+ if ( ids.isEmpty() && append )
+ return;
+
+ bool changed = false;
+
+ QMap<int, int> aMap;
+ for ( uint i = 0; i < ids.count(); i++ )
+ aMap.insert( *ids.at( i ), 0 );
+
+ for ( IdStateMap::Iterator it = myState.begin(); it != myState.end(); ++it )
+ {
+ if ( aMap.contains( it.key() ) )
+ {
+ if ( it.data() != on )
+ {
+ it.data() = on;
+ changed = true;
+ }
+ }
+ else if ( !append && it.data() == on )
+ {
+ it.data() = !on;
+ changed = true;
+ }
+ }
+ if ( changed )
+ updateRadioBox();
+}
+
+/*!
+ Sets the user items into the combo box.
+*/
+void QDS_RadioBox::setValues( const QValueList<int>& ids, const QStringList& names )
+{
+ if ( ids.count() != names.count() )
+ return;
+
+ myUserIds = ids;
+ myUserNames = names;
+}
+
+/*!
+ This is an overloaded member function, provided for convenience.
+ It behaves essentially like the above function. It creates
+ QValueList (0, 1, 2 ... ) and call previous method
+*/
+void QDS_RadioBox::setValues( const QStringList& names )
+{
+ QValueList< int > ids;
+ for ( int i = 0, n = names.count(); i < n; i++ )
+ ids.append( i );
+ setValues( ids, names );
+}
+
+/*!
+ Returns string from control.
+*/
+QString QDS_RadioBox::getString() const
+{
+ QString res;
+ QButtonGroup* bg = buttonGroup();
+ if ( bg )
+ {
+ int id = bg->selectedId();
+ if ( id != -1 )
+ res = QString::number( id );
+ }
+ return res;
+}
+
+/*!
+ Sets the string into control.
+*/
+void QDS_RadioBox::setString( const QString& txt )
+{
+ QButtonGroup* bg = buttonGroup();
+ if ( !bg )
+ return;
+
+ int oldId = bg->selectedId();
+
+ if ( txt.isEmpty() )
+ {
+ QPtrList<QRadioButton> bList;
+ buttons( bList );
+ for ( QPtrListIterator<QRadioButton> it( bList ); it.current(); ++it )
+ it.current()->setChecked( false );
+ }
+ else
+ {
+ bool ok;
+ int id = txt.toInt( &ok );
+ if ( !ok )
+ id = -1;
+
+ bool block = signalsBlocked();
+ blockSignals( true );
+ bg->setButton( id );
+ blockSignals( block );
+ }
+
+ int newId = bg->selectedId();
+
+ if ( oldId != newId )
+ {
+ onParamChanged();
+ QString str = getString();
+ emit activated( newId );
+ emit paramChanged();
+ emit paramChanged( str );
+ }
+}
+
+/*!
+ Returns pointer to QButtonGroup widget.
+*/
+QButtonGroup* QDS_RadioBox::buttonGroup() const
+{
+ return ::qt_cast<QButtonGroup*>( controlWidget() );
+}
+
+/*!
+ Create QComboBox widget as control subwidget.
+*/
+QWidget* QDS_RadioBox::createControl( QWidget* parent )
+{
+ QButtonGroup* bg = new QButtonGroup( 1, Qt::Vertical, "", parent );
+ bg->setExclusive( true );
+ bg->setRadioButtonExclusive( true );
+ return bg;
+}
+
+void QDS_RadioBox::unitSystemChanged( const QString& system )
+{
+ QDS_Datum::unitSystemChanged( system );
+
+ Handle(TColStd_HArray1OfInteger) anIds;
+ Handle(TColStd_HArray1OfExtendedString) aValues, anIcons;
+
+ Handle(DDS_DicItem) aDicItem = dicItem();
+ if ( !aDicItem.IsNull() )
+ aDicItem->GetListOfValues( aValues, anIds, anIcons );
+
+ myValue.clear();
+ myDataIds.clear();
+
+ QMap<int, QString> userMap;
+ QIntList::iterator iIt = myUserIds.begin();
+ QStringList::iterator sIt = myUserNames.begin();
+ for ( ; iIt != myUserIds.end() && sIt != myUserNames.end(); ++iIt, ++sIt )
+ userMap.insert( *iIt, *sIt );
+
+ if ( !anIds.IsNull() && !aValues.IsNull() &&
+ anIds->Length() == aValues->Length() )
+ {
+ for ( int i = anIds->Lower(); i <= anIds->Upper(); i++ )
+ {
+ QString aValue;
+ int id = anIds->Value( i );
+ if ( userMap.contains( id ) )
+ aValue = userMap[id];
+ else
+ aValue = toQString( aValues->Value( i ) );
+
+ myDataIds.append( id );
+ myValue.insert( id, aValue );
+ myState.insert( id, true );
+ }
+ }
+
+ for ( iIt = myUserIds.begin(); iIt != myUserIds.end(); ++iIt )
+ {
+ int id = *iIt;
+ if ( !myValue.contains( id ) )
+ {
+ myDataIds.append( id );
+ myValue.insert( id, userMap[id] );
+ }
+ }
+
+ QIntList del, add;
+ for ( IdStateMap::Iterator it1 = myState.begin(); it1 != myState.end(); ++it1 )
+ if ( !myValue.contains( it1.key() ) )
+ del.append( it1.key() );
+
+ for ( IdValueMap::Iterator it2 = myValue.begin(); it2 != myValue.end(); ++it2 )
+ if ( !myState.contains( it2.key() ) )
+ add.append( it2.key() );
+
+ for ( QIntList::iterator iter1 = del.begin(); iter1 != del.end(); ++iter1 )
+ myState.remove( *iter1 );
+
+ for ( QIntList::iterator iter2 = add.begin(); iter2 != add.end(); ++iter2 )
+ myState.insert( *iter2, true );
+
+ QButtonGroup* bg = buttonGroup();
+ if ( bg )
+ bg->setTitle( label() );
+
+ updateRadioBox();
+}
+
+/*!
+ Notify about state changed in line edit of RadioBox.
+*/
+void QDS_RadioBox::onToggled( bool on )
+{
+ if ( !on )
+ return;
+
+ onParamChanged();
+ emit paramChanged();
+ QString str = getString();
+ emit paramChanged( str );
+}
+
+/*!
+ Updates RadioBox after have change of visible state or items have been inserted / removed.
+*/
+void QDS_RadioBox::updateRadioBox()
+{
+ QButtonGroup* bg = buttonGroup();
+ if ( !bg )
+ return;
+
+ int curId = bg->selectedId();
+
+ QPtrList<QRadioButton> bList;
+ buttons( bList );
+ for ( QPtrListIterator<QRadioButton> itr( bList ); itr.current(); ++itr )
+ delete itr.current();
+
+ for ( QIntList::const_iterator it = myDataIds.begin(); it != myDataIds.end(); ++it )
+ {
+ int id = *it;
+ if ( !myValue.contains( id ) || !myState.contains( id ) || !myState[id] )
+ continue;
+
+ QRadioButton* rb = new QRadioButton( myValue[id], bg );
+ bg->insert( rb, id );
+
+ connect( rb, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) );
+ }
+
+ if ( curId != -1 )
+ {
+ int id = curId;
+ if ( !bg->find( id ) )
+ {
+ QPtrList<QRadioButton> bList;
+ buttons( bList );
+ if ( !bList.isEmpty() )
+ id = bg->id( bList.getFirst() );
+ }
+
+ bool block = signalsBlocked();
+ blockSignals( true );
+ bg->setButton( id );
+ blockSignals( block );
+ }
+
+ if ( curId != bg->selectedId() )
+ {
+ onParamChanged();
+ emit paramChanged();
+ emit paramChanged( getString() );
+ }
+}
+
+void QDS_RadioBox::buttons( QPtrList<QRadioButton>& lst ) const
+{
+ lst.setAutoDelete( false );
+ lst.clear();
+
+ QButtonGroup* bg = buttonGroup();
+ if ( !bg )
+ return;
+
+ QObjectList* objs = bg->queryList( "QRadioButton" );
+ if ( objs )
+ {
+ for ( QObjectListIt it( *objs ); it.current(); ++it )
+ {
+ QRadioButton* rb = ::qt_cast<QRadioButton*>( it.current() );
+ if ( rb )
+ lst.append( rb );
+ }
+ }
+ delete objs;
+}
--- /dev/null
+#ifndef QDS_RADIOBOX_H
+#define QDS_RADIOBOX_H
+
+#include "QDS_Datum.h"
+
+#include <Qtx.h>
+
+#include <qmap.h>
+#include <qpixmap.h>
+#include <qstringlist.h>
+
+#ifdef WNT
+#pragma warning( disable:4251 )
+#endif
+
+class QButtonGroup;
+class QRadioButton;
+
+class QDS_EXPORT QDS_RadioBox : public QDS_Datum
+{
+ Q_OBJECT
+
+public:
+ QDS_RadioBox( const QString&, QWidget* = 0, const int = All, const QString& = QString::null );
+ virtual ~QDS_RadioBox();
+
+ int count( bool = false ) const;
+ void values( QValueList<int>&, bool = false ) const;
+
+ int columns() const;
+ void setColumns( const int );
+
+ bool state( const int ) const;
+ void setState( const bool, const int, const bool = true );
+ void setState( const bool, const QValueList<int>&, const bool = true );
+ void setValues( const QValueList<int>&, const QStringList& );
+ void setValues( const QStringList& );
+
+signals:
+ void activated( int );
+
+protected slots:
+ virtual void onToggled( bool );
+
+protected:
+ QButtonGroup* buttonGroup() const;
+ virtual QWidget* createControl( QWidget* );
+ void buttons( QPtrList<QRadioButton>& ) const;
+
+ virtual QString getString() const;
+ virtual void setString( const QString& );
+
+ virtual void unitSystemChanged( const QString& );
+
+private:
+ void updateRadioBox();
+
+private:
+ typedef QMap<int, QString> IdValueMap;
+ typedef QMap<int, bool> IdStateMap;
+
+private:
+ IdValueMap myValue;
+ IdStateMap myState;
+
+ QIntList myDataIds;
+ QIntList myUserIds;
+ QStringList myUserNames;
+};
+
+#ifdef WNT
+#pragma warning( default:4251 )
+#endif
+
+#endif
Level: Internal
*/
-QtxResourceMgr::Resources::Resources( const QString& fileName )
-: myFileName( fileName )
+QtxResourceMgr::Resources::Resources( const QtxResourceMgr* mgr, const QString& fileName )
+: myFileName( fileName ),
+ myMgr( const_cast<QtxResourceMgr*>( mgr ) )
{
}
return filePath;
}
+QtxResourceMgr* QtxResourceMgr::Resources::resMgr() const
+{
+ return myMgr;
+}
+
QtxResourceMgr::Section& QtxResourceMgr::Resources::section( const QString& sn )
{
if ( !mySections.contains( sn ) )
path = Qtx::addSlash( path ) + name;
}
}
- return QDir::convertSeparators( path );
+ if( !path.isEmpty() )
+ {
+ QString fname = QDir::convertSeparators( path );
+ QFileInfo inf( fname );
+ fname = inf.absFilePath();
+ return fname;
+ }
+ return QString();
}
QPixmap QtxResourceMgr::Resources::loadPixmap( const QString& sect, const QString& prefix, const QString& name ) const
{
- return QPixmap( fileName( sect, prefix, name ) );
+ QString fname = fileName( sect, prefix, name );
+ bool toCache = resMgr() ? resMgr()->isPixmapCached() : false;
+ QPixmap p;
+ if( toCache && myPixmapCache.contains( fname ) )
+ p = myPixmapCache[fname];
+ else
+ {
+ p.load( fname );
+ if( toCache )
+ ( ( QMap<QString,QPixmap>& )myPixmapCache ).insert( fname, p );
+ }
+ return p;
}
QTranslator* QtxResourceMgr::Resources::loadTranslator( const QString& sect, const QString& prefix, const QString& name ) const
function userFileName(). Any resource looking firstly in the user home resources then
resource directories used in the specified order. All setted resources always stored into
the resource file at the user home. Only user home resource file is saved.
+ If you want to ignore of loading of Local User Preferences, you needs setup setIngoreUserValues()
+ as true.
*/
QtxResourceMgr::QtxResourceMgr( const QString& appName, const QString& resVarTemplate )
: myAppName( appName ),
-myCheckExist( true )
+ myCheckExist( true ),
+ myIsPixmapCached( true ),
+ myIsIgnoreUserValues( false )
{
QString envVar = !resVarTemplate.isEmpty() ? resVarTemplate : QString( "%1Resources" );
if ( envVar.contains( "%1" ) )
QtxResourceMgr* that = (QtxResourceMgr*)this;
if ( !userFileName( appName() ).isEmpty() )
- that->myResources.append( new Resources( userFileName( appName() ) ) );
+ that->myResources.append( new Resources( this, userFileName( appName() ) ) );
for ( QStringList::const_iterator it = myDirList.begin(); it != myDirList.end(); ++it )
{
QString path = Qtx::addSlash( *it ) + globalFileName( appName() );
- that->myResources.append( new Resources( path ) );
+ that->myResources.append( new Resources( this, path ) );
}
if ( autoLoad )
that->load();
}
+/*!
+ \brief Return true if all loaded pixmaps are stored in internal map; by default: true
+*/
+bool QtxResourceMgr::isPixmapCached() const
+{
+ return myIsPixmapCached;
+}
+
+/*!
+ \brief Set true, if it is necessary to store all loaded pixmap in internal map
+ (it accelerates following calls of loadPixmap)
+*/
+void QtxResourceMgr::setIsPixmapCached( const bool on )
+{
+ myIsPixmapCached = on;
+}
+
/*!
\brief Removes all resources from the manager.
*/
it.current()->clear();
}
+void QtxResourceMgr::setIgnoreUserValues( const bool val )
+{
+ myIsIgnoreUserValues = val;
+}
+
+bool QtxResourceMgr::ignoreUserValues() const
+{
+ return myIsIgnoreUserValues;
+}
+
/*!
\brief Get the resource value as integer. Returns 'true' if it successfull otherwise
returns 'false'.
initialize();
bool ok = false;
- for ( ResListIterator it( myResources ); it.current() && !ok; ++it )
+
+ ResListIterator it( myResources );
+ if ( ignoreUserValues() )
+ ++it;
+
+ for ( ; it.current() && !ok; ++it )
{
ok = it.current()->hasValue( sect, name );
if ( ok )
bool checkExisting() const;
virtual void setCheckExisting( const bool );
+ bool isPixmapCached() const;
+ void setIsPixmapCached( const bool );
+
void clear();
+ void setIgnoreUserValues( const bool = true );
+ bool ignoreUserValues() const;
+
bool value( const QString&, const QString&, int& ) const;
bool value( const QString&, const QString&, double& ) const;
bool value( const QString&, const QString&, bool& ) const;
bool myCheckExist;
TransListMap myTranslator;
QPixmap myDefaultPix;
+ bool myIsPixmapCached;
+
+ bool myIsIgnoreUserValues;
};
/*!
class QtxResourceMgr::Resources
{
public:
- Resources( const QString& );
+ Resources( const QtxResourceMgr*, const QString& );
virtual ~Resources();
QString file() const;
QString path( const QString&, const QString&, const QString& ) const;
+protected:
+ QtxResourceMgr* resMgr() const;
+
private:
Section& section( const QString& );
const Section& section( const QString& ) const;
private:
SectionMap mySections;
QString myFileName;
+ QMap<QString,QPixmap> myPixmapCache;
+ QtxResourceMgr* myMgr;
friend class QtxResourceMgr::Format;
};
#define TOOLTIP_HIDE_DELAY 7000
QtxToolTip::QtxToolTip( QWidget* parent )
-: QLabel( parent, "", WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WStyle_StaysOnTop | WType_TopLevel )
+: QLabel( parent, "", WStyle_Customize | WStyle_NoBorder | WX11BypassWM | WStyle_Tool | WStyle_StaysOnTop | WType_TopLevel )
{
setIndent( 3 );
setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
#include "SVTK_ViewManager.h"
#include "SVTK_ViewWindow.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_RenderWindowInteractor.h"
using namespace std;
virtual void Execute() {
if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow() ) {
PyObject* aPyClass = GetPyClass("vtkRenderWindow");
- vtkRenderWindow* aVTKObject = aVTKViewWindow->getRenderWindow()->getRenderWindow();
+ vtkRenderWindow* aVTKObject = aVTKViewWindow->getRenderWindow();
myResult = PyVTKObject_New(aPyClass,aVTKObject);
}
}
virtual void Execute() {
if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow() ) {
PyObject* aPyClass = GetPyClass("vtkRenderWindowInteractor");
- vtkRenderWindowInteractor* aVTKObject = aVTKViewWindow->getRWInteractor();
+ vtkRenderWindowInteractor* aVTKObject = aVTKViewWindow->getInteractor();
myResult = PyVTKObject_New(aPyClass,aVTKObject);
}
}
SUIT_ViewModel.h \
SUIT_ViewWindow.h \
SUIT_SelectionFilter.h \
- SUIT_Accel.h
+ SUIT_Accel.h \
+ SUIT_TreeSync.h
# .po files to transform in .qm
PO_FILES = SUIT_images.po \
#define DEFAULT_MESSAGE_DELAY 3000
void SUIT_Application::putInfo ( const QString& msg, const int msec )
{
- if ( desktop() ) {
- //desktop()->statusBar()->message( msg, msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec );
- if ( !myStatusLabel ) {
- myStatusLabel = new QLabel (desktop()->statusBar());
- desktop()->statusBar()->addWidget(myStatusLabel, /*int stretch = */1);
- }
- myStatusLabel->setText(msg);
- if( msec != -1 )
- QTimer::singleShot(msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec, myStatusLabel, SLOT(clear()));
+ if ( !desktop() )
+ return;
+
+ if ( !myStatusLabel )
+ {
+ myStatusLabel = new QLabel( desktop()->statusBar() );
+ desktop()->statusBar()->addWidget( myStatusLabel, 1 );
+ myStatusLabel->show();
}
+
+ myStatusLabel->setText( msg );
+ if ( msec != -1 )
+ QTimer::singleShot( msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec, myStatusLabel, SLOT( clear() ) );
}
SUIT_Application* SUIT_Application::startApplication( int argc, char** argv ) const
return dirname;
}
+
+/*!
+ QFileDialog::dirPath() has a bug on Linux Debian (1 level up from correct
+ directory is returned). This function fixes the bug.
+*/
+QString SUIT_FileDlg::dirPath() const
+{
+ if ( !mySelectedFile.isNull() )
+ return QFileInfo( mySelectedFile ).dirPath();
+
+ const QDir* aDir = dir();
+ if ( aDir->exists() )
+ return aDir->absPath();
+
+ return QFileDialog::dirPath();
+}
void setValidator( SUIT_FileValidator* );
+ QString dirPath() const; // QFileDialog::dirPath() has a bug on Linux Debian (1 level up from correct
+ // directory is returned). This redefinition fixes the bug.
+
static QString getFileName( QWidget* parent, const QString& initial, const QStringList& filters,
const QString& caption, const bool open, const bool showQuickDir = true,
SUIT_FileValidator* validator = 0 );
#ifndef SUIT_OPERATION_H
#define SUIT_OPERATION_H
-#include <qobject.h>
-
#include "SUIT.h"
+#include <qobject.h>
+#include <qguardedptr.h>
+
class SUIT_Study;
class SUIT_Application;
* - virtual void resumeOperation();
* - virtual void suspendOperation();
*/
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
class SUIT_EXPORT SUIT_Operation : public QObject
{
Q_OBJECT
void start( SUIT_Operation*, const bool = false );
+private:
+ typedef QGuardedPtr<SUIT_Study> StudyPtr;
+
private:
SUIT_Application* myApp; //!< application for this operation
int myFlags; //!< operation flags
- SUIT_Study* myStudy; //!< study for this operation
+ StudyPtr myStudy; //!< study for this operation
OperationState myState; //!< Operation state
ExecStatus myExecStatus; //!< Execution status
friend class SUIT_Study;
};
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
#endif
--- /dev/null
+
+#ifndef SUIT_TREE_SYNC_HEADER
+#define SUIT_TREE_SYNC_HEADER
+
+#include <qptrlist.h>
+#include <qvaluelist.h>
+
+template <class SrcItem, class TrgItem>
+struct DiffItem
+{
+ SrcItem mySrc; //if it is null, then this item is to deleted
+ TrgItem myTrg; //if it is null, then this item is to added
+ //if both fields aren't null, then this item is to update
+};
+
+template <class SrcItem, class TrgItem, class TreeData>
+TrgItem synchronize( const SrcItem&, const TrgItem&, const TreeData& );
+
+template <class SrcItem, class TrgItem, class TreeData>
+void diffSiblings( const SrcItem&, const TrgItem&,
+ QValueList < DiffItem < SrcItem,TrgItem > >&,
+ const TreeData& );
+
+template <class SrcItem, class TrgItem, class TreeData>
+TrgItem createSubTree( const SrcItem&, const TrgItem&, const TrgItem&, const bool, const TreeData& );
+
+template <class SrcItem, class TrgItem, class TreeData>
+const typename QValueList<TrgItem>::const_iterator findEqual( const QValueList<TrgItem>& l,
+ const typename QValueList<TrgItem>::const_iterator& first,
+ const SrcItem& it,
+ const TreeData& td );
+
+
+
+
+
+//int gSync = 0;
+template <class SrcItem, class TrgItem, class TreeData>
+TrgItem synchronize( const SrcItem& r1, const TrgItem& r2, const TreeData& td )
+{
+ // printf( "--- synchronize : %d ---\n", ++gSync );
+
+ if( td.isEqual( r1, r2 ) )
+ {
+ QValueList< DiffItem< SrcItem, TrgItem > > d;
+ diffSiblings( r1, r2, d, td );
+
+ typename QValueList< DiffItem< SrcItem, TrgItem > >::const_iterator anIt = d.begin(), aLast = d.end();
+ bool isFirst = true;
+ TrgItem lastItem = td.nullTrg();
+ // TrgItem tail = td.nullTrg();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ const DiffItem<SrcItem,TrgItem>& item = *anIt;
+ if( item.mySrc==td.nullSrc() )
+ if( item.myTrg==td.nullTrg() )
+ qDebug( "error: both null" );
+ else
+ //to delete
+ td.deleteItemWithChildren( item.myTrg );
+ else {
+ if( item.myTrg==td.nullTrg() )
+ {
+ //to add
+ lastItem = createSubTree( item.mySrc, r2, lastItem, isFirst, td );
+ }
+ else
+ {
+ //to update
+ td.updateItem( item.myTrg );
+ synchronize( item.mySrc, item.myTrg, td );
+ lastItem = item.myTrg;
+ }
+ isFirst = false;
+ }
+ }
+
+ return r2;
+ }
+ else
+ {
+ TrgItem new_r2 = createSubTree( r1, td.parent( r2 ), r2, false, td );
+ if( r2!=td.nullTrg() )
+ td.deleteItemWithChildren( r2 );
+ return new_r2;
+ }
+}
+
+template <class SrcItem, class TrgItem, class TreeData>
+const typename QValueList<TrgItem>::const_iterator findEqual( const QValueList<TrgItem>& l,
+ const typename QValueList<TrgItem>::const_iterator& first,
+ const SrcItem& it,
+ const TreeData& td )
+{
+ typename QValueList<TrgItem>::const_iterator cur = first, last = l.end();
+ for( ; cur!=last; cur++ )
+ if( td.isEqual( it, *cur ) )
+ return cur;
+ return last;
+}
+
+template <class SrcItem, class TrgItem, class TreeData>
+void diffSiblings( const SrcItem& src, const TrgItem& trg,
+ QValueList < DiffItem < SrcItem,TrgItem > >& d,
+ const TreeData& td )
+{
+ if( src==td.nullSrc() || trg==td.nullTrg() )
+ return;
+
+ QValueList<SrcItem> src_ch;
+ QValueList<TrgItem> trg_ch;
+ td.children( src, src_ch );
+ td.children( trg, trg_ch );
+
+ typename QValueList<SrcItem>::const_iterator src_it = src_ch.begin(), src_last = src_ch.end();
+ typename QValueList<TrgItem>::const_iterator cur = trg_ch.begin(), trg_last = trg_ch.end();
+
+ for( ; src_it!=src_last; src_it++ )
+ {
+ typename QValueList<TrgItem>::const_iterator f =
+ findEqual<SrcItem, TrgItem, TreeData>( trg_ch, cur, *src_it, td );
+ if( f!=trg_last ) //is found
+ {
+ //mark all items before found as "to be deleted"
+ for( typename QValueList<TrgItem>::const_iterator it = cur; it!=f; it++ )
+ {
+ DiffItem<SrcItem,TrgItem> ndiff;
+ ndiff.mySrc = td.nullSrc();
+ ndiff.myTrg = *it; //to delete;
+ d.append( ndiff );
+ }
+ cur = f;
+ DiffItem<SrcItem,TrgItem> ndiff;
+ ndiff.mySrc = *src_it;
+ ndiff.myTrg = *cur; //update this item
+ d.append( ndiff );
+ cur++;
+ }
+ else //not found
+ {
+ DiffItem<SrcItem,TrgItem> ndiff;
+ ndiff.mySrc = *src_it;
+ ndiff.myTrg = td.nullTrg(); //add this item
+ d.append( ndiff );
+ }
+ }
+ for( ; cur!=trg_last; cur++ )
+ {
+ DiffItem<SrcItem,TrgItem> ndiff;
+ ndiff.mySrc = td.nullSrc();
+ ndiff.myTrg = *cur; //to delete;
+ d.append( ndiff );
+ }
+}
+
+template <class SrcItem, class TrgItem, class TreeData>
+TrgItem createSubTree( const SrcItem& src, const TrgItem& parent,
+ const TrgItem& after, const bool asFirst,
+ const TreeData& td )
+{
+ if( src==td.nullSrc() )
+ return td.nullTrg();
+
+ TrgItem nitem = td.createItem( src, parent, after, asFirst );
+ if( nitem==td.nullTrg() )
+ return nitem;
+
+ QValueList<SrcItem> ch;
+ td.children( src, ch );
+ typename QValueList<SrcItem>::const_iterator anIt = ch.begin(), aLast = ch.end();
+ for( ; anIt!=aLast; anIt++ )
+ createSubTree( *anIt, nitem, td.nullTrg(), false, td );
+
+ return nitem;
+}
+
+#endif
void SUIT_ViewWindow::action( const int )
{
}
-
-/*! The method returns the visual parameters of this view as a formated string
- */
-QString SUIT_ViewWindow::getVisualParameters()
-{
- return " ";
-}
-
-/* The method restors visual parameters of this view from a formated string
- */
-void SUIT_ViewWindow::setVisualParameters( const QString& parameters )
-{
-}
void onAccelAction( int );
- virtual QString getVisualParameters();
- virtual void setVisualParameters( const QString& parameters );
-
public slots:
virtual void onDumpView();
void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
{
myView = theView;
+ setFocusProxy( myView ); // mkr : IPAL11388
}
virtual ~SUPERVGraph_Viewer();
virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
+ virtual QString getType() const { return Type(); }
};
SalomeApp_TypeFilter.h \
SalomeApp_StudyPropertiesDlg.h \
SalomeApp_CheckFileDlg.h
-# SalomeApp_VisualParameters.h
# .po files to transform in .qm
PO_FILES = SalomeApp_images.po \
SalomeApp_StudyPropertiesDlg.cxx \
SalomeApp_ListView.cxx \
SalomeApp_CheckFileDlg.cxx
-# SalomeApp_VisualParameters.cxx
LIB_MOC = SalomeApp_Application.h \
SalomeApp_DataModel.h \
#pragma warning ( disable: 4251 )
#endif
-
//! Registry Display
createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIconSet(),
tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
- SHIFT+Key_D, desk, false, this, SLOT( onRegDisplay() ) );
+ /*SHIFT+Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
3. update object browser if it existing */
void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
{
- // update existing data models (already loaded SComponents)
- LightApp_Application::updateObjectBrowser(updateModels);
-
// update "non-existing" (not loaded yet) data models
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
if ( study )
if ( aComponent->ComponentDataType() == "Interface Applicative" )
continue; // skip the magic "Interface Applicative" component
- SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
+ OB_Browser* ob = static_cast<OB_Browser*>( getWindow( WT_ObjectBrowser ));
+ const bool isAutoUpdate = ob->isAutoUpdate();
+ ob->setAutoUpdate( false );
+ SalomeApp_DataModel::synchronize( aComponent, study );
+ ob->setAutoUpdate( isAutoUpdate );
+ //SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
}
}
}
- if ( objectBrowser() )
+ // update existing data models (already loaded SComponents)
+ LightApp_Application::updateObjectBrowser( updateModels );
+
+/* if ( objectBrowser() )
{
objectBrowser()->updateGeometry();
- objectBrowser()->updateTree( 0, false );
- }
+ objectBrowser()->updateTree();
+ }*/
}
/*!Display Catalog Genenerator dialog */
class QDockWindow;
class LightApp_Preferences;
-class SalomeApp_Study;
class SalomeApp_Module;
class SALOME_LifeCycleCORBA;
void onCatalogGen();
void onRegDisplay();
void onOpenWith();
-
- friend class SalomeApp_Study;
};
#ifdef WIN32
#include <SUIT_Application.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_TreeSync.h>
+#include <SUIT_DataObjectIterator.h>
#include "SALOMEDS_Tool.hxx"
#include CORBA_SERVER_HEADER(SALOME_Exception)
//=======================================================================
-// name : BuildTree
-/*!Purpose : static method used by SalomeApp_Study and SalomeApp_DataModel classes
- * to create default SALOMEDS-based data object tree
- */
+// name : SalomeApp_DataModelSync
+/*!Purpose : Auxiliary class for synchronizing tree of kernel objects and SUIT_DataObjects */
//=======================================================================
-SUIT_DataObject* SalomeApp_DataModel::BuildTree( const _PTR(SObject)& obj,
- SUIT_DataObject* parent,
- SalomeApp_Study* study,
- bool skip )
+
+typedef _PTR(SObject) kerPtr;
+typedef SUIT_DataObject* suitPtr;
+
+class SalomeApp_DataModelSync
{
- SalomeApp_DataObject* aDataObj = 0;
- if ( !obj || !study )
- return aDataObj;
+public:
+ SalomeApp_DataModelSync( _PTR( Study ), SUIT_DataObject* );
- _PTR(SObject) refObj;
- if ( obj->GetName().size() || obj->ReferencedObject( refObj ) ) // skip nameless non references SObjects
- {
- _PTR(SComponent) aSComp( obj );
+ suitPtr createItem( const kerPtr&, const suitPtr&, const suitPtr&, const bool ) const;
+ void deleteItemWithChildren( const suitPtr& ) const;
+ bool isEqual( const kerPtr&, const suitPtr& ) const;
+ kerPtr nullSrc() const;
+ suitPtr nullTrg() const;
+ void children( const kerPtr&, QValueList<kerPtr>& ) const;
+ void children( const suitPtr&, QValueList<suitPtr>& ) const;
+ suitPtr parent( const suitPtr& ) const;
+ bool isCorrect( const kerPtr& ) const;
+ void updateItem( const suitPtr& ) const;
+
+private:
+ _PTR( Study ) myStudy;
+ SUIT_DataObject* myRoot;
+};
+
+
+SalomeApp_DataModelSync::SalomeApp_DataModelSync( _PTR( Study ) aStudy, SUIT_DataObject* aRoot )
+: myStudy( aStudy ),
+ myRoot( aRoot )
+{
+}
+
+bool SalomeApp_DataModelSync::isCorrect( const kerPtr& so ) const
+{
+ kerPtr refObj;
+ QString name = so->GetName();
+ bool res = so && ( so->GetName().size() || so->ReferencedObject( refObj ) );
+ return res;
+}
- // patch for bug IPAL9313
- if ( aSComp && parent && skip )
+suitPtr SalomeApp_DataModelSync::createItem( const kerPtr& so,
+ const suitPtr& parent,
+ const suitPtr& after,
+ const bool asFirst ) const
+{
+ if( !isCorrect( so ) )
+ return 0;
+
+ _PTR(SComponent) aSComp( so );
+ suitPtr nitem = aSComp ? new SalomeApp_ModuleObject( aSComp, 0 ) :
+ new SalomeApp_DataObject( so, 0 );
+ if( parent )
+ if( after )
{
- QString aSName( aSComp->GetName().c_str() );
- DataObjectList allComponents = parent->children( /*recursive=*/false );
- for ( DataObjectListIterator it( allComponents ); it.current(); ++it ) {
- SUIT_DataObject* componentObj = it.current();
- if ( componentObj->name() == aSName ) {
- // mkr : modifications for update of already published in
- // object browser, but not loaded yet components
- LightApp_Application* anApp = dynamic_cast<LightApp_Application*>
- (SUIT_Session::session()->activeApplication() );
- // asv : corresponding DataObjects are DELETED before update (so they are re-built).
- if (anApp && !anApp->module(aSName)) { // if module is not loaded, delete it's DataObject
- // jfa: remove children before DataObject deletion
- DataObjectList chilren = componentObj->children(/*recursive=*/true);
- for (DataObjectListIterator itc (chilren); itc.current(); ++itc)
- componentObj->removeChild(itc.current());
-
- // delete DataObject itself and re-create it and all its sub-objects
- delete componentObj;
- // don't do anything here, because iterator may be corrupted (deleted object inside it)
- break; // proceed to build_a_data_object code below
- }
- else
- return componentObj;
- }
- }
+ DataObjectList ch;
+ parent->children( ch );
+ int pos = ch.find( after );
+ if( pos>=0 )
+ parent->insertChild( nitem, pos+1 );
+ else
+ parent->appendChild( nitem );
}
+ else if( asFirst )
+ parent->insertChild( nitem, 0 );
+ else
+ parent->appendChild( nitem );
+ else if( myRoot )
+ myRoot->appendChild( nitem );
+ return nitem;
+}
- aDataObj = aSComp ? new SalomeApp_ModuleObject( aSComp, parent ) :
- new SalomeApp_DataObject ( obj, parent );
+void SalomeApp_DataModelSync::deleteItemWithChildren( const suitPtr& p ) const
+{
+ if( !p )
+ return;
- _PTR(ChildIterator) it ( study->studyDS()->NewChildIterator( obj ) );
- for ( ; it->More(); it->Next() ) {
- // don't use shared_ptr here, for Data Object will take
- // ownership of this pointer
- _PTR(SObject) aSO( it->Value() );
- BuildTree( aSO, aDataObj, study );
- }
+ DataObjectList ch;
+ p->children( ch );
+ DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end();
+ for( ; anIt!=aLast; anIt++ )
+ deleteItemWithChildren( *anIt );
+ delete p;
+}
+
+bool SalomeApp_DataModelSync::isEqual( const kerPtr& p, const suitPtr& q ) const
+{
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( q );
+ return ( !p && !q ) || ( obj && isCorrect( p ) && p->GetID()==obj->entry() );
+}
+
+kerPtr SalomeApp_DataModelSync::nullSrc() const
+{
+ return kerPtr();
+}
+
+suitPtr SalomeApp_DataModelSync::nullTrg() const
+{
+ return suitPtr( 0 );
+}
+
+void SalomeApp_DataModelSync::children( const kerPtr& obj, QValueList<kerPtr>& ch ) const
+{
+ ch.clear();
+ _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) );
+ for( ; it->More(); it->Next() )
+ ch.append( it->Value() );
+}
+
+void SalomeApp_DataModelSync::children( const suitPtr& p, QValueList<suitPtr>& ch ) const
+{
+ DataObjectList l;
+ if( p )
+ {
+ p->children( l );
+ ch.clear();
+ for( SUIT_DataObject* o = l.first(); o; o = l.next() )
+ ch.append( o );
+ }
+}
+
+suitPtr SalomeApp_DataModelSync::parent( const suitPtr& p ) const
+{
+ return p ? p->parent(): 0;
+}
+
+void SalomeApp_DataModelSync::updateItem( const suitPtr& ) const
+{
+}
+
+void showTree( SUIT_DataObject* root )
+{
+ qDebug( root ? "<tree>" : "<empty tree>" );
+ if( !root )
+ return;
+
+ SUIT_DataObjectIterator it( root, SUIT_DataObjectIterator::DepthLeft );
+ for( ; it.current(); ++it )
+ {
+ QString marg; marg.fill( ' ', 3*it.depth() );
+ QString nnn = "%1 '%2'";
+ qDebug( nnn.arg( marg ).arg( it.current()->name() ) );
}
- return aDataObj;
}
//=======================================================================
_PTR(Study) aStudy ( aDoc->studyDS() ); // shared_ptr cannot be used here
_PTR(SComponent) aSComp ( aStudy->FindComponentID( std::string( anId.latin1() ) ) );
if ( aSComp )
- buildTree( aSComp, 0, aDoc );
+ updateTree( aSComp, aDoc );
QStringList listOfFiles;
LightApp_DataModel::open(name, study, listOfFiles);
return true;
}
+//================================================================
+// Function : create
+/*! Purpose : Create data model*/
+//================================================================
+bool SalomeApp_DataModel::create( CAM_Study* theStudy )
+{
+ update(NULL, (LightApp_Study*)theStudy);
+ return true;
+}
+
//================================================================
// Function : update
/*! Purpose : Update application.*/
{
SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study);
LightApp_RootObject* studyRoot = 0;
- _PTR(SObject) sobj;
+ _PTR(SComponent) sobj;
SalomeApp_DataObject* modelRoot = dynamic_cast<SalomeApp_DataObject*>( root() );
if ( !modelRoot ){ // not yet connected to a study -> try using <study> argument
if ( !aSStudy )
}
}
}
- buildTree( sobj, studyRoot, aSStudy );
+ if ( sobj && aSStudy )
+ updateTree( sobj, aSStudy );
}
//================================================================
-// Function : buildTree
-/*! Purpose : private method, build tree.*/
+// Function : synchronize
+/*! Purpose : synchronizes kernel tree and suit data tree starting from component 'sobj' */
//================================================================
-void SalomeApp_DataModel::buildTree( const _PTR(SObject)& obj,
- SUIT_DataObject* parent,
- SalomeApp_Study* study )
+SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SComponent )& sobj, SalomeApp_Study* study )
{
- if ( !obj )
- return;
- //if ( !root() ){ // Build default SALOMEDS-based data object tree and insert it into study
- SalomeApp_ModuleObject* aNewRoot = dynamic_cast<SalomeApp_ModuleObject*>( BuildTree( obj, parent, study ) );
- if ( aNewRoot ){
- aNewRoot->setDataModel( this );
- setRoot( aNewRoot );
+ if( !study || !study->root() || !sobj )
+ return 0;
+
+ DataObjectList ch; study->root()->children( ch );
+ DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end();
+ SalomeApp_DataObject* suitObj = 0;
+ for( ; anIt!=aLast; anIt++ )
+ {
+ SalomeApp_DataObject* dobj = dynamic_cast<SalomeApp_DataObject*>( *anIt );
+ if( dobj && dobj->name()==sobj->GetName().c_str() )
+ {
+ suitObj = dobj;
+ break;
}
- //}
+ }
+
+ SalomeApp_DataModelSync sync( study->studyDS(), study->root() );
+
+ // QString srcName = sobj ? sobj->GetName().c_str() : "";
+ // QString trgName = ( suitObj && !suitObj->name().isNull() ) ? suitObj->name() : "";
+ // printf( "--- SalomeApp_DataModel::syncronize() calls synchronize()_1: src = %s, trg = %s ---\n", srcName.latin1(), trgName.latin1() );
+
+ SUIT_DataObject* o = ::synchronize<kerPtr,suitPtr,SalomeApp_DataModelSync>( sobj, suitObj, sync );
+// showTree( o );
+ return o;
+}
+
+//================================================================
+// Function : synchronize
+/*! Purpose : synchronizes kernel tree and suit data tree starting from 'sobj' and 'obj' correspondly */
+//================================================================
+SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SObject )& sobj, SUIT_DataObject* obj,
+ SalomeApp_Study* study )
+{
+ if( !study )
+ return 0;
+ SalomeApp_DataModelSync sync( study->studyDS(), study->root() );
+
+ // QString srcName = sobj ? sobj->GetName().c_str() : "";
+ // QString trgName = ( obj && !obj->name().isNull() ) ? obj->name() : "";
+ // printf( "--- SalomeApp_DataModel::syncronize() calls synchronize()_2: src = s, trg = %s ---\n", srcName.latin1(), trgName.latin1() );
+
+ return ::synchronize<kerPtr,suitPtr,SalomeApp_DataModelSync>( sobj, obj, sync );
+}
+
+//================================================================
+// Function : updateTree
+/*! Purpose : updates tree.*/
+//================================================================
+void SalomeApp_DataModel::updateTree( const _PTR( SComponent )& comp, SalomeApp_Study* study )
+{
+ SalomeApp_ModuleObject* aNewRoot = dynamic_cast<SalomeApp_ModuleObject*>( synchronize( comp, study ) );
+ if( aNewRoot )
+ {
+ aNewRoot->setDataModel( this );
+ setRoot( aNewRoot );
+ }
}
//================================================================
Q_OBJECT
public:
- static SUIT_DataObject* BuildTree(const _PTR(SObject)& obj,
- SUIT_DataObject* parent,
- SalomeApp_Study* study,
- bool skip = false );
+ static SUIT_DataObject* synchronize( const _PTR( SComponent )&, SalomeApp_Study* );
+ static SUIT_DataObject* synchronize( const _PTR( SObject )&, SUIT_DataObject*, SalomeApp_Study* );
SalomeApp_DataModel ( CAM_Module* theModule );
virtual ~SalomeApp_DataModel();
virtual bool open( const QString&, CAM_Study*, QStringList );
+ virtual bool create( CAM_Study* );
virtual void update( LightApp_DataObject* = 0, LightApp_Study* = 0 );
QString getRootEntry( SalomeApp_Study* ) const;
protected:
SalomeApp_Study* getStudy() const;
-
- virtual void buildTree(const _PTR(SObject)&, SUIT_DataObject*, SalomeApp_Study* );
+ virtual void updateTree( const _PTR( SComponent )&, SalomeApp_Study* );
};
+
#endif
QString pixmapName = QObject::tr( aPixAttr->GetPixMap().c_str() );
LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
if ( aRoot && aRoot->study() ) {
- QPixmap pixmap = aRoot->study()->application()->resourceMgr()->loadPixmap( componentDataType(), pixmapName, false );
- return pixmap;
+ SUIT_ResourceMgr* mgr = aRoot->study()->application()->resourceMgr();
+ return mgr->loadPixmap( componentDataType(), pixmapName, false );
}
}
}
VTKViewer_ViewModel.cxx \
VTKViewer_ConvexTool.cxx \
VTKViewer_ViewWindow.cxx
-
LIB_MOC = \
VTKViewer_RenderWindow.h \
VTKViewer_ViewModel.h \
VTKViewer_ViewWindow.h
-CPPFLAGS+=$(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES)
+BIN = VTKViewer
-LDFLAGS+=$(VTK_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) -lsuit
+CPPFLAGS+=$(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES)
-@CONCLUDE@
+LDFLAGS+=$(VTK_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL)
+LDFLAGSFORBIN=$(LDFLAGS) -lqtx -lsuit
+@CONCLUDE@
\ No newline at end of file
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module :
+// $Header$
+
+#include "VTKViewer_Actor.h"
+#include "VTKViewer_CellRectPicker.h"
+#include "VTKViewer_ExtractUnstructuredGrid.h"
+#include "VTKViewer_ConvexTool.h"
+#include "VTKViewer_Filter.h"
+#include "VTKViewer_GeometryFilter.h"
+#include "VTKViewer_AppendFilter.h"
+#include "VTKViewer_Algorithm.h"
+#include "VTKViewer_InteractorStyle.h"
+#include "VTKViewer_PassThroughFilter.h"
+#include "VTKViewer_RectPicker.h"
+#include "VTKViewer_RenderWindow.h"
+#include "VTKViewer_RenderWindowInteractor.h"
+#include "VTKViewer_ShrinkFilter.h"
+#include "VTKViewer_TransformFilter.h"
+#include "VTKViewer_Transform.h"
+#include "VTKViewer_Trihedron.h"
+#include "VTKViewer_Utilities.h"
+#include "VTKViewer_VectorText.h"
+#include "VTKViewer_ViewManager.h"
+#include "VTKViewer_ViewModel.h"
+#include "VTKViewer_ViewWindow.h"
+#include "VTKViewer_Functor.h"
+
+int
+main(int argc, char** argv)
+{
+ return 0;
+}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/
//
+// File : SALOME_Actor.cxx
+// Author : Nicolas REJNERI
+// Module : SALOME
+// $Header$
+
+/*!
+ \class SALOME_Actor SALOME_Actor.h
+ \brief Abstract class of SALOME Objects in VTK.
+*/
+
+
#include "VTKViewer_Actor.h"
+
#include "VTKViewer_Transform.h"
-#include "VTKViewer_GeometryFilter.h"
#include "VTKViewer_TransformFilter.h"
#include "VTKViewer_PassThroughFilter.h"
+#include "VTKViewer_GeometryFilter.h"
// VTK Includes
+#include <vtkCell.h>
+#include <vtkPolyData.h>
#include <vtkObjectFactory.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
#include <vtkRenderer.h>
-#include <vtkMapper.h>
-#include <vtkPolyData.h>
-#include <vtkCell.h>
+using namespace std;
-/*
-static void CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet){
- vtkPoints *aPoints = vtkPoints::New();
- vtkIdType iEnd = theSourceDataSet->GetNumberOfPoints();
- aPoints->SetNumberOfPoints(iEnd);
- for(vtkIdType i = 0; i < iEnd; i++){
- aPoints->SetPoint(i,theSourceDataSet->GetPoint(i));
- }
- theGrid->SetPoints(aPoints);
- aPoints->Delete();
-}
-*/
+#if defined __GNUC__
+ #if __GNUC__ == 2
+ #define __GNUC_2__
+ #endif
+#endif
+int VTKViewer_POINT_SIZE = 5;
+int VTKViewer_LINE_WIDTH = 3;
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VTKViewer_Actor);
-/*!Constructor.Initialize default parameters.*/
-VTKViewer_Actor::VTKViewer_Actor(){
- myIsHighlighted = myIsPreselected = false;
-
- myRepresentation = 1;
- myDisplayMode = myRepresentation - 1;
-
- myProperty = vtkProperty::New();
- PreviewProperty = NULL;
-
- myIsInfinite = false;
- myIsResolveCoincidentTopology = true;
-
+//----------------------------------------------------------------------------
+VTKViewer_Actor
+::VTKViewer_Actor():
+ myIsHighlighted(false),
+ myIsPreselected(false),
+ myRepresentation(VTK_SURFACE),
+ myDisplayMode(1),
+ myProperty(vtkProperty::New()),
+ PreviewProperty(NULL),
+ myIsInfinite(false),
+ myIsResolveCoincidentTopology(true),
+ myStoreMapping(false),
+ myGeomFilter(VTKViewer_GeometryFilter::New()),
+ myTransformFilter(VTKViewer_TransformFilter::New())
+{
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits);
- myStoreMapping = false;
- myGeomFilter = VTKViewer_GeometryFilter::New();
-
- myTransformFilter = VTKViewer_TransformFilter::New();
for(int i = 0; i < 6; i++)
myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
-
- Visibility = Pickable = true;
}
-/*!Destructor.*/
-VTKViewer_Actor::~VTKViewer_Actor(){
+//----------------------------------------------------------------------------
+VTKViewer_Actor
+::~VTKViewer_Actor()
+{
SetPreviewProperty(NULL);
- myGeomFilter->UnRegisterAllOutputs();
myGeomFilter->Delete();
- myTransformFilter->UnRegisterAllOutputs();
myTransformFilter->Delete();
- for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
- if(myPassFilter[i]){
- myPassFilter[i]->UnRegisterAllOutputs();
+ for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
+ if(myPassFilter[i])
myPassFilter[i]->Delete();
- }
- }
+
myProperty->Delete();
}
-/*!Add VTKViewer_Actor to renderer.
- *\param theRenderer - vtkRenderer
- */
-void VTKViewer_Actor::AddToRender(vtkRenderer* theRenderer){
+
+//----------------------------------------------------------------------------
+const char*
+VTKViewer_Actor
+::getName()
+{
+ return myName.c_str();
+}
+
+void
+VTKViewer_Actor
+::setName(const char* theName)
+{
+ myName = theName;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_Actor
+::AddToRender(vtkRenderer* theRenderer)
+{
theRenderer->AddActor(this);
}
-/*!Remove VTKViewer_Actor from renderer.
- *\param theRenderer - vtkRenderer
- */
-void VTKViewer_Actor::RemoveFromRender(vtkRenderer* theRenderer){
+void
+VTKViewer_Actor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
theRenderer->RemoveActor(this);
}
-/*!Add transformation to transform filter.
- *\param theTransform - transformation.
- */
-void VTKViewer_Actor::SetTransform(VTKViewer_Transform* theTransform){
+void
+VTKViewer_Actor
+::GetChildActors(vtkActorCollection*)
+{}
+
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_Actor
+::SetTransform(VTKViewer_Transform* theTransform)
+{
myTransformFilter->SetTransform(theTransform);
}
-/*!Set mapper to pipeline.\n
- *Call method for pipeline initialization.
- *\param theMapper - mapper
- */
-void VTKViewer_Actor::SetMapper(vtkMapper* theMapper){
+
+void
+VTKViewer_Actor
+::SetMapper(vtkMapper* theMapper)
+{
InitPipeLine(theMapper);
}
-/*!Initialize sequence of filters for mapper, if \a theMapper is not null.
- *\param theMapper - mapper
- */
-void VTKViewer_Actor::InitPipeLine(vtkMapper* theMapper){
+void
+VTKViewer_Actor
+::InitPipeLine(vtkMapper* theMapper)
+{
if(theMapper){
int anId = 0;
myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput());
}
}
- vtkLODActor::SetMapper(theMapper);
+ Superclass::SetMapper(theMapper);
}
-/*!*/
-void VTKViewer_Actor::Render(vtkRenderer *ren, vtkMapper* m){
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_Actor
+::Render(vtkRenderer *ren, vtkMapper* m)
+{
if(myIsResolveCoincidentTopology){
int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
float aFactor, aUnit;
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits);
- vtkLODActor::Render(ren,m);
+ Superclass::Render(ren,m);
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
}else{
- vtkLODActor::Render(ren,m);
+ Superclass::Render(ren,m);
}
}
-/*!Set flag myIsResolveCoincidentTopology to \a theIsResolve.
- *\param theIsResolve - bool flag.
- */
-void VTKViewer_Actor::SetResolveCoincidentTopology(bool theIsResolve) {
+
+void
+VTKViewer_Actor
+::SetResolveCoincidentTopology(bool theIsResolve)
+{
myIsResolveCoincidentTopology = theIsResolve;
}
-/*!Sets polygon offset factor and polygon offset units.
- *\param factor - float factor
- *\param units - float units
- */
-void VTKViewer_Actor::SetPolygonOffsetParameters(float factor, float units){
+void
+VTKViewer_Actor
+::SetPolygonOffsetParameters(float factor, float units)
+{
myPolygonOffsetFactor = factor;
myPolygonOffsetUnits = units;
}
-/*!Gets polygon offset factor and polygon offset units.
- *\param factor - output float
- *\param units - output float
- */
-void VTKViewer_Actor::GetPolygonOffsetParameters(float& factor, float& units){
+void
+VTKViewer_Actor
+::GetPolygonOffsetParameters(float& factor, float& units)
+{
factor = myPolygonOffsetFactor;
units = myPolygonOffsetUnits;
}
-/*!Get input data set.
- *\retval vtkDataSet pointer.
- */
-vtkDataSet* VTKViewer_Actor::GetInput(){
+//----------------------------------------------------------------------------
+float
+VTKViewer_Actor
+::GetShrinkFactor()
+{
+ return 1.0;
+}
+
+bool
+VTKViewer_Actor
+::IsShrunkable()
+{
+ return false;
+}
+
+bool
+VTKViewer_Actor
+::IsShrunk()
+{
+ return false;
+}
+
+void
+VTKViewer_Actor
+::SetShrink()
+{}
+
+void
+VTKViewer_Actor
+::UnShrink()
+{}
+
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VTKViewer_Actor
+::GetInput()
+{
return myPassFilter.front()->GetOutput();
}
-/*!Get modification time.
- *\retval time - unsigned long.
- */
-unsigned long int VTKViewer_Actor::GetMTime(){
+
+unsigned long int
+VTKViewer_Actor
+::GetMTime()
+{
unsigned long mTime = this->Superclass::GetMTime();
unsigned long time = myTransformFilter->GetMTime();
mTime = ( time > mTime ? time : mTime );
return mTime;
}
-/*!Set representation mode.
- *\param theMode - int.
- */
-void VTKViewer_Actor::SetRepresentation(int theMode) {
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_Actor
+::SetRepresentation(int theMode)
+{
switch(myRepresentation){
case VTK_POINTS :
case VTK_SURFACE :
GetProperty()->DeepCopy(myProperty);
break;
default:
- break;
GetProperty()->SetAmbient(1.0);
GetProperty()->SetDiffuse(0.0);
GetProperty()->SetSpecular(0.0);
switch(theMode){
case 3 :
myGeomFilter->SetInside(true);
- GetProperty()->SetRepresentation(1);
+ myGeomFilter->SetWireframeMode(true);
+ GetProperty()->SetRepresentation(VTK_WIREFRAME);
break;
case VTK_POINTS :
GetProperty()->SetPointSize(VTKViewer_POINT_SIZE);
- default :
GetProperty()->SetRepresentation(theMode);
+ myGeomFilter->SetWireframeMode(false);
+ myGeomFilter->SetInside(false);
+ break;
+ case VTK_WIREFRAME :
+ GetProperty()->SetRepresentation(theMode);
+ myGeomFilter->SetWireframeMode(true);
myGeomFilter->SetInside(false);
+ break;
+ case VTK_SURFACE :
+ GetProperty()->SetRepresentation(theMode);
+ myGeomFilter->SetWireframeMode(false);
+ myGeomFilter->SetInside(false);
+ break;
}
myRepresentation = theMode;
}
-/*!Get representation.
- *\retval representation mode.
- */
-int VTKViewer_Actor::GetRepresentation(){
+int
+VTKViewer_Actor
+::GetRepresentation()
+{
return myRepresentation;
}
-/*!Get VTK cell by object ID.
- *\param theObjID - object ID.
- *\retval vtkCell pointer.
- */
-vtkCell* VTKViewer_Actor::GetElemCell(int theObjID){
- return GetInput()->GetCell(theObjID);
+
+//----------------------------------------------------------------------------
+int
+VTKViewer_Actor
+::GetNodeObjId(int theVtkID)
+{
+ return theVtkID;
}
-/*!Get node coordinates by node ID.
- *\param theObjID - node ID.
- *\retval float array of coordinates.
- * \li array[0] - X coordinate.
- * \li array[1] - Y coordinate.
- * \li array[2] - Z coordinate.
- */
-float* VTKViewer_Actor::GetNodeCoord(int theObjID){
+float*
+VTKViewer_Actor
+::GetNodeCoord(int theObjID)
+{
return GetInput()->GetPoint(theObjID);
}
+vtkCell*
+VTKViewer_Actor
+::GetElemCell(int theObjID)
+{
+ return GetInput()->GetCell(theObjID);
+}
+
+int
+VTKViewer_Actor
+::GetElemObjId(int theVtkID)
+{
+ return theVtkID;
+}
+
//=================================================================================
// function : GetObjDimension
-/*! purpose : Return object dimension.\n
- * Virtual method shoulb be redifined by derived classes
- *\param theObjId - object ID.
- */
+// purpose : Return object dimension.
+// Virtual method shoulb be redifined by derived classes
//=================================================================================
-int VTKViewer_Actor::GetObjDimension( const int theObjId )
+int
+VTKViewer_Actor
+::GetObjDimension( const int theObjId )
{
if ( vtkCell* aCell = GetElemCell(theObjId) )
return aCell->GetCellDimension();
return 0;
}
-/*!Get infinite flag*/
-bool VTKViewer_Actor::IsInfinitive(){
+
+void
+VTKViewer_Actor
+::SetInfinitive(bool theIsInfinite)
+{
+ myIsInfinite = theIsInfinite;
+}
+
+
+bool
+VTKViewer_Actor
+::IsInfinitive()
+{
return myIsInfinite;
}
-/*!Set property - opacity.
- *\param theOpacity - new apacity
- */
-void VTKViewer_Actor::SetOpacity(float theOpacity){
+
+float*
+VTKViewer_Actor
+::GetBounds()
+{
+ return Superclass::GetBounds();
+}
+
+
+void
+VTKViewer_Actor
+::GetBounds(float theBounds[6])
+{
+ Superclass::GetBounds(theBounds);
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VTKViewer_Actor
+::IsSetCamera() const
+{
+ return false;
+}
+
+bool
+VTKViewer_Actor
+::IsResizable() const
+{
+ return false;
+}
+
+void
+VTKViewer_Actor
+::SetSize( const float )
+{}
+
+
+void
+VTKViewer_Actor
+::SetCamera( vtkCamera* )
+{}
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_Actor
+::SetOpacity(float theOpacity)
+{
myOpacity = theOpacity;
GetProperty()->SetOpacity(theOpacity);
}
-/*!Get property - opacity.
- *\retval float value.
- */
-float VTKViewer_Actor::GetOpacity(){
+float
+VTKViewer_Actor
+::GetOpacity()
+{
return myOpacity;
}
-/*!Set property - color
- *\param r - float Red value
- *\param g - float Green value
- *\param b - float Blue value
- */
-void VTKViewer_Actor::SetColor(float r,float g,float b){
+
+void
+VTKViewer_Actor
+::SetColor(float r,float g,float b)
+{
GetProperty()->SetColor(r,g,b);
}
-/*!Get property - color
- *\param r - output float Red value
- *\param g - output float Green value
- *\param b - output float Blue value
- */
-void VTKViewer_Actor::GetColor(float& r,float& g,float& b){
+void
+VTKViewer_Actor
+::SetColor(const float theRGB[3])
+{
+ SetColor(theRGB[0],theRGB[1],theRGB[2]);
+}
+
+void
+VTKViewer_Actor
+::GetColor(float& r,float& g,float& b)
+{
float aColor[3];
GetProperty()->GetColor(aColor);
r = aColor[0];
b = aColor[2];
}
-/*!Get display mode.
- *\retval int value
- */
-int VTKViewer_Actor::getDisplayMode(){
+
+//----------------------------------------------------------------------------
+int
+VTKViewer_Actor
+::getDisplayMode()
+{
return myDisplayMode;
}
-/*!Set display mode
- *\param theMode - integer value.
- */
-void VTKViewer_Actor::setDisplayMode(int theMode){
- SetRepresentation(theMode+1);
+void
+VTKViewer_Actor
+::setDisplayMode(int theMode)
+{
+ SetRepresentation(theMode + 1);
myDisplayMode = GetRepresentation() - 1;
}
+
+//----------------------------------------------------------------------------
+bool
+VTKViewer_Actor
+::hasHighlight()
+{
+ return false;
+}
+
+bool
+VTKViewer_Actor
+::isHighlighted()
+{
+ return myIsHighlighted;
+}
+
+void
+VTKViewer_Actor
+::SetPreSelected(bool thePreselect)
+{
+ myIsPreselected = thePreselect;
+}
+
+
+//----------------------------------------------------------------
+void
+VTKViewer_Actor
+::highlight(bool theIsHighlight)
+{
+ myIsHighlighted = theIsHighlight;
+}
+
+vtkCxxSetObjectMacro(VTKViewer_Actor,PreviewProperty,vtkProperty);
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/
//
+// File : SALOME_Actor.h
+// Author : Nicolas REJNERI
+// Module : SALOME
+// $Header$
+
#ifndef VTKVIEVER_ACTOR_H
#define VTKVIEVER_ACTOR_H
#include "VTKViewer.h"
-#include <vtkLODActor.h>
-#include <vtkProperty.h>
-#include <vtkShrinkFilter.h>
-#include <vtkDataSetMapper.h>
-#include <vtkUnstructuredGrid.h>
-
+#include <string>
#include <vector>
+#include <vtkLODActor.h>
+
class vtkCell;
+class vtkPointPicker;
+class vtkCellPicker;
class vtkDataSet;
-class vtkPolyData;
+class vtkCamera;
+class vtkProperty;
+class vtkRenderer;
class VTKViewer_Transform;
class VTKViewer_GeometryFilter;
class VTKViewer_TransformFilter;
class VTKViewer_PassThroughFilter;
-#define VTKViewer_POINT_SIZE 3
+extern int VTKViewer_POINT_SIZE;
+extern int VTKViewer_LINE_WIDTH;
+
/*! \class vtkLODActor
* \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
*/
-class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
+class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
{
-public:
- /*!Create new instance of actor.*/
+ public:
static VTKViewer_Actor* New();
-
- vtkTypeMacro( VTKViewer_Actor, vtkLODActor );
-
- /*!Get name of the actor*/
- virtual const char* getName() { return myName.c_str(); }
- /*!Set name of the actor*/
- virtual void setName(const char* theName){ myName = theName;}
-
- //! To generate highlight automaticaly
- virtual bool hasHighlight() { return false; }
- //! Sets highlight.
- virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
- //! Check highlight.
- virtual bool isHighlighted() { return myIsHighlighted; }
- virtual void SetOpacity(float theOpacity);
- virtual float GetOpacity();
-
- virtual void SetColor(float r,float g,float b);
- virtual void GetColor(float& r,float& g,float& b);
- void SetColor(const float theRGB[3]){ SetColor(theRGB[0],theRGB[1],theRGB[2]); }
-
- vtkSetObjectMacro(PreviewProperty,vtkProperty);
-
- virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
-
- //! Used to obtain all dependent actors
- virtual void GetChildActors(vtkActorCollection*) {};
-
- virtual void AddToRender(vtkRenderer* theRenderer);
- virtual void RemoveFromRender(vtkRenderer* theRenderer);
-
-
- /** @name For selection mapping purpose */
- //@{
- virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
- virtual float* GetNodeCoord(int theObjID);
-
- virtual int GetElemObjId(int theVtkID) { return theVtkID;}
- virtual vtkCell* GetElemCell(int theObjID);
- //@}
-
- virtual int GetObjDimension( const int theObjId );
-
- virtual void SetMapper(vtkMapper* theMapper);
- virtual vtkDataSet* GetInput();
-
- virtual void SetTransform(VTKViewer_Transform* theTransform);
- virtual unsigned long int GetMTime();
-
- virtual void SetRepresentation(int theMode);
- virtual int GetRepresentation();
-
- virtual int getDisplayMode();
- virtual void setDisplayMode(int theMode);
-
- /*! Infinitive means actor without size (point for example), \n
- * which is not taken into account in calculation of boundaries of the scene
- */
- void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
- virtual bool IsInfinitive();
+ vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
+
+ //----------------------------------------------------------------------------
+ //! Get its name
+ virtual
+ const char*
+ getName();
+
+ //! Name the #VTKViewer_Actor
+ virtual
+ void
+ setName(const char* theName);
+
+ //----------------------------------------------------------------------------
+ //! Change opacity
+ virtual
+ void
+ SetOpacity(float theOpacity);
+
+ //! Get current opacity
+ virtual
+ float
+ GetOpacity();
+
+ //! Change color
+ virtual
+ void
+ SetColor(float r,float g,float b);
+
+ //! Get current color
+ virtual
+ void
+ GetColor(float& r,float& g,float& b);
+
+ //! Change color
+ virtual
+ void
+ SetColor(const float theRGB[3]);
+
+ //----------------------------------------------------------------------------
+ // For selection mapping purpose
+ //! Maps VTK index of a node to corresponding object index
+ virtual
+ int
+ GetNodeObjId(int theVtkID);
+
+ //! Get coordinates of a node for given object index
+ virtual
+ float*
+ GetNodeCoord(int theObjID);
+
+ //! Maps VTK index of a cell to corresponding object index
+ virtual
+ int
+ GetElemObjId(int theVtkID);
+
+ //! Get corresponding #vtkCell for given object index
+ virtual
+ vtkCell*
+ GetElemCell(int theObjID);
+
+ //----------------------------------------------------------------------------
+ //! Get dimension of corresponding mesh element
+ virtual
+ int
+ GetObjDimension( const int theObjId );
+
+ //! To insert some additional filters and then sets the given #vtkMapper
+ virtual
+ void
+ SetMapper(vtkMapper* theMapper);
+
+ //! Allows to get initial #vtkDataSet
+ virtual
+ vtkDataSet*
+ GetInput();
+
+ //! Apply view transformation
+ virtual
+ void
+ SetTransform(VTKViewer_Transform* theTransform);
+
+ //! To calculatate last modified time
+ virtual
+ unsigned long int
+ GetMTime();
+
+ //----------------------------------------------------------------------------
+ //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
+ virtual
+ void
+ SetRepresentation(int theMode);
+
+ //! Get current representation mode
+ virtual
+ int
+ GetRepresentation();
+
+ //! Get current display mode (obsolete)
+ virtual
+ int
+ getDisplayMode();
+
+ //! Set display mode (obsolete)
+ virtual
+ void
+ setDisplayMode(int theMode);
+
+ //----------------------------------------------------------------------------
+ //! Set infinive flag
+ /*!
+ Infinitive means actor without size (point for example),
+ which is not taken into account in calculation of boundaries of the scene
+ */
+ void
+ SetInfinitive(bool theIsInfinite);
+
+ //! Get infinive flag
+ virtual
+ bool
+ IsInfinitive();
- void SetResolveCoincidentTopology(bool theIsResolve);
- void SetPolygonOffsetParameters(float factor, float units);
- void GetPolygonOffsetParameters(float& factor, float& units);
-
- virtual void Render(vtkRenderer *, vtkMapper *);
+ //! To calcualte current bounding box
+ virtual
+ float*
+ GetBounds();
+
+ //! To calcualte current bounding box
+ void
+ GetBounds(float bounds[6]);
+
+ //----------------------------------------------------------------------------
+ virtual
+ bool
+ IsSetCamera() const;
+
+ virtual
+ bool
+ IsResizable() const;
+
+ virtual
+ void
+ SetSize( const float );
+
+ virtual
+ void
+ SetCamera( vtkCamera* );
+
+ //----------------------------------------------------------------------------
+ //! Set ResolveCoincidentTopology flag
+ void
+ SetResolveCoincidentTopology(bool theIsResolve);
+
+ //! Set ResolveCoincidentTopology parameters
+ void
+ SetPolygonOffsetParameters(float factor, float units);
+
+ //! Get current ResolveCoincidentTopology parameters
+ void
+ GetPolygonOffsetParameters(float& factor, float& units);
+
+ virtual
+ void
+ Render(vtkRenderer *, vtkMapper *);
+
+ //----------------------------------------------------------------------------
+ //! Get current shrink factor
+ virtual
+ float
+ GetShrinkFactor();
+
+ //! Is the actor is shrunkable
+ virtual
+ bool
+ IsShrunkable();
+
+ //! Is the actor is shrunk
+ virtual
+ bool
+ IsShrunk();
+
+ //! Insert shrink filter into pipeline
+ virtual
+ void
+ SetShrink();
+
+ //! Remove shrink filter from pipeline
+ virtual
+ void
+ UnShrink();
+
+ //----------------------------------------------------------------------------
+ //! To publish the actor an all its internal devices
+ virtual
+ void
+ AddToRender(vtkRenderer* theRendere);
+
+ //! To remove the actor an all its internal devices
+ virtual
+ void
+ RemoveFromRender(vtkRenderer* theRendere);
-protected:
- /*!resolve coincedent topology flag*/
+ //! Used to obtain all dependent actors
+ virtual
+ void
+ GetChildActors(vtkActorCollection*);
+
+ //----------------------------------------------------------------------------
+ //! Ask, if the descendant of the VTKViewer_Actor will implement its own highlight or not
+ virtual
+ bool
+ hasHighlight();
+
+ //! Ask, if the VTKViewer_Actor is already highlighted
+ virtual
+ bool
+ isHighlighted();
+
+ //! Set preselection mode
+ virtual
+ void
+ SetPreSelected(bool thePreselect = false);
+
+ //----------------------------------------------------------------------------
+ //! Just to update visibility of the highlight devices
+ virtual
+ void
+ highlight(bool theHighlight);
+
+ void
+ SetPreviewProperty(vtkProperty* theProperty);
+
+ protected:
+ //----------------------------------------------------------------------------
bool myIsResolveCoincidentTopology;
- /*!polygon offset factor*/
float myPolygonOffsetFactor;
- /*!polygon offset units*/
float myPolygonOffsetUnits;
- /*!Actor name.*/
std::string myName;
- /*!preview property*/
- vtkProperty *PreviewProperty;
- /*!preselected flag*/
- bool myIsPreselected;
-
- /*!opacity*/
float myOpacity;
- /*!highlighted flag*/
- bool myIsHighlighted;
- /*!display mode*/
int myDisplayMode;
- /*!infinite flag*/
bool myIsInfinite;
- /*!store mapping flag*/
bool myStoreMapping;
- /*!geometry filter*/
VTKViewer_GeometryFilter *myGeomFilter;
- /*!transform filter*/
VTKViewer_TransformFilter *myTransformFilter;
- /*!vector of passive filters(siz filters used)*/
std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
- /*!presentation mode*/
int myRepresentation;
- /*!property*/
vtkProperty *myProperty;
- //! Main method, which calculate output.
- void InitPipeLine(vtkMapper* theMapper);
+ void
+ InitPipeLine(vtkMapper* theMapper);
VTKViewer_Actor();
~VTKViewer_Actor();
+
+ protected:
+ vtkProperty *PreviewProperty;
+ bool myIsPreselected;
+ bool myIsHighlighted;
};
-#endif
+#endif // VTKVIEVER_ACTOR_H
// $Header$
#include "VTKViewer_GeometryFilter.h"
-#include "VTKViewer_ConvexTool.h"
#include <vtkSmartPointer.h>
#include <vtkCellArray.h>
#include <vtkVoxel.h>
#include <vtkWedge.h>
+#include <vtkMath.h>
+#include <vtkPlane.h>
+#include <vtkDelaunay3D.h>
+#include <vtkGeometryFilter.h>
+
+#include <algorithm>
+#include <iterator>
#include <vector>
#include <map>
-using namespace std;
-
+#include <set>
#if defined __GNUC__
#if __GNUC__ == 2
#endif
#endif
+#define USE_ROBUST_TRIANGULATION
+
//----------------------------------------------------------------------------
vtkCxxRevisionMacro(VTKViewer_GeometryFilter, "$Revision$");
vtkStandardNewMacro(VTKViewer_GeometryFilter);
-VTKViewer_GeometryFilter::VTKViewer_GeometryFilter():
+VTKViewer_GeometryFilter
+::VTKViewer_GeometryFilter():
myShowInside(0),
myStoreMapping(0),
myIsWireframeMode(0)
{}
-VTKViewer_GeometryFilter::~VTKViewer_GeometryFilter()
+VTKViewer_GeometryFilter
+::~VTKViewer_GeometryFilter()
{}
//----------------------------------------------------------------------------
-void VTKViewer_GeometryFilter::Execute()
+void
+VTKViewer_GeometryFilter
+::Execute()
{
vtkDataSet *input= this->GetInput();
vtkIdType numCells=input->GetNumberOfCells();
//----------------------------------------------------------------------------
-void VTKViewer_GeometryFilter::UnstructuredGridExecute()
+void
+VTKViewer_GeometryFilter
+::UnstructuredGridExecute()
{
vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)this->GetInput();
vtkCellArray *Connectivity = input->GetCells();
- if (Connectivity == NULL) {return;}
+ // Check input
+ if ( Connectivity == NULL )
+ {
+ vtkDebugMacro(<<"Nothing to extract");
+ return;
+ }
+
vtkIdType cellId;
int i;
int allVisible;
vtkPolyData *output = this->GetOutput();
vtkPointData *outputPD = output->GetPointData();
+#ifdef USE_ROBUST_TRIANGULATION
+ vtkUnstructuredGrid* anUnstructuredGrid = vtkUnstructuredGrid::New();
+ vtkPoints* aDelaunayPoints = vtkPoints::New();
+
+ vtkDelaunay3D* aDelaunay3D = vtkDelaunay3D::New();
+ aDelaunay3D->SetInput(anUnstructuredGrid);
+
+ vtkGeometryFilter* aGeometryFilter = vtkGeometryFilter::New();
+ aGeometryFilter->SetInput(aDelaunay3D->GetOutput());
+#endif
+
vtkCellData *outputCD = output->GetCellData();
- vtkIdList *cellIds, *faceIds;
+ vtkGenericCell *cell = vtkGenericCell::New();
+
+
+ vtkIdList *cellIds = vtkIdList::New();
+ vtkIdList *faceIds = vtkIdList::New();
+
char *cellVis;
vtkIdType newCellId;
int faceId, *faceVerts, numFacePts;
cellGhostLevels = ((vtkUnsignedCharArray*)temp)->GetPointer(0);
}
- // Check input
- if ( Connectivity == NULL )
- {
- vtkDebugMacro(<<"Nothing to extract");
- return;
- }
-
// Determine nature of what we have to do
- cellIds = vtkIdList::New();
- faceIds = vtkIdList::New();
if ( (!this->CellClipping) && (!this->PointClipping) &&
(!this->ExtentClipping) )
{
outputCD->CopyData(cd,cellId,newCellId);
break;
- case VTK_CONVEX_POINT_SET:{
- TCellArray tmpCellArray;
- try{
- CONVEX_TOOL::GetPolygonalFaces(input,cellId,tmpCellArray); // "VTKViewer_ConvexTool.cxx"
- } catch (const std::exception& theExc){
- cout << __FILE__ << "[" << __LINE__ << "] " << "Exception:" << theExc.what() << endl;
- } catch (...) {
- cout << __FILE__ << "[" << __LINE__ << "] " << "Exception was occured"<< endl;
+ case VTK_CONVEX_POINT_SET: {
+ //cout<<"cellId = "<<cellId<<"\n";
+
+ vtkIdType aNumPts;
+ vtkPoints *aPoints;
+#ifdef USE_ROBUST_TRIANGULATION
+ aPoints = aDelaunayPoints;
+ anUnstructuredGrid->Initialize();
+ anUnstructuredGrid->Allocate();
+ anUnstructuredGrid->SetPoints(aDelaunayPoints);
+
+ vtkIdType *aPts;
+ input->GetCellPoints(cellId,aNumPts,aPts);
+ {
+ float aPntCoord[3];
+ aDelaunayPoints->SetNumberOfPoints(aNumPts);
+ vtkPoints *anInputPoints = input->GetPoints();
+ for (int aPntId = 0; aPntId < aNumPts; aPntId++) {
+ anInputPoints->GetPoint(aPts[aPntId],aPntCoord);
+ aDelaunayPoints->SetPoint(aPntId,aPntCoord);
+ }
}
- TCellArray::iterator aFaceIter = tmpCellArray.begin();
- for (; aFaceIter!=tmpCellArray.end(); aFaceIter++){
- TCell cell = aFaceIter->second;
- numFacePts = cell.size();
- if(numFacePts>3)
- aCellType = VTK_POLYGON;
- else if(numFacePts == 3)
- aCellType = VTK_TRIANGLE;
- else if(numFacePts<3)
+#else
+ input->GetCell(cellId,cell);
+ aPoints = input->GetPoints();
+ aNumPts = cell->GetNumberOfPoints();
+#endif
+ // To calculate the bary center of the cell
+ float aCellCenter[3] = {0.0, 0.0, 0.0};
+ {
+ float aPntCoord[3];
+ for (int aPntId = 0; aPntId < aNumPts; aPntId++) {
+#ifdef USE_ROBUST_TRIANGULATION
+ aPoints->GetPoint(aPntId,aPntCoord);
+#else
+ aPoints->GetPoint(cell->GetPointId(aPntId),aPntCoord);
+#endif
+ //cout<<"\t\taPntId = "<<aPntId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}\n";
+ aCellCenter[0] += aPntCoord[0];
+ aCellCenter[1] += aPntCoord[1];
+ aCellCenter[2] += aPntCoord[2];
+ }
+ aCellCenter[0] /= aNumPts;
+ aCellCenter[1] /= aNumPts;
+ aCellCenter[2] /= aNumPts;
+ }
+
+#ifdef USE_ROBUST_TRIANGULATION
+ aGeometryFilter->Update();
+ vtkPolyData* aPolyData = aGeometryFilter->GetOutput();
+
+ float aCellLength = aPolyData->GetLength();
+ int aNumFaces = aPolyData->GetNumberOfCells();
+#else
+ float aCellLength = sqrt(cell->GetLength2());
+ int aNumFaces = cell->GetNumberOfFaces();
+#endif
+
+ static float EPS = 1.0E-5;
+ float aDistEps = aCellLength * EPS;
+
+ // To initialize set of points that belong to the cell
+ typedef std::set<vtkIdType> TPointIds;
+ TPointIds anInitialPointIds;
+ for(vtkIdType aPntId = 0; aPntId < aNumPts; aPntId++){
+#ifdef USE_ROBUST_TRIANGULATION
+ anInitialPointIds.insert(aPntId);
+#else
+ anInitialPointIds.insert(cell->GetPointId(aPntId));
+#endif
+ }
+
+ // To initialize set of points by face that belong to the cell and backward
+ typedef std::set<vtkIdType> TFace2Visibility;
+ TFace2Visibility aFace2Visibility;
+
+ typedef std::set<TPointIds> TFace2PointIds;
+ TFace2PointIds aFace2PointIds;
+
+ for (int aFaceId = 0; aFaceId < aNumFaces; aFaceId++) {
+#ifdef USE_ROBUST_TRIANGULATION
+ vtkCell* aFace = aPolyData->GetCell(aFaceId);
+#else
+ vtkCell* aFace = cell->GetFace(aFaceId);
+#endif
+ vtkIdList *anIdList = aFace->PointIds;
+ aNewPts[0] = anIdList->GetId(0);
+ aNewPts[1] = anIdList->GetId(1);
+ aNewPts[2] = anIdList->GetId(2);
+
+#ifdef USE_ROBUST_TRIANGULATION
+ faceIds->Reset();
+ faceIds->InsertNextId(aPts[aNewPts[0]]);
+ faceIds->InsertNextId(aPts[aNewPts[1]]);
+ faceIds->InsertNextId(aPts[aNewPts[2]]);
+ input->GetCellNeighbors(cellId, faceIds, cellIds);
+#else
+ input->GetCellNeighbors(cellId, anIdList, cellIds);
+#endif
+ if((!allVisible && !cellVis[cellIds->GetId(0)]) ||
+ cellIds->GetNumberOfIds() <= 0 ||
+ myShowInside)
+ {
+ TPointIds aPointIds;
+ aPointIds.insert(aNewPts[0]);
+ aPointIds.insert(aNewPts[1]);
+ aPointIds.insert(aNewPts[2]);
+
+ aFace2PointIds.insert(aPointIds);
+ aFace2Visibility.insert(aFaceId);
+ }
+ }
+
+ for (int aFaceId = 0; aFaceId < aNumFaces; aFaceId++) {
+ if(aFace2Visibility.find(aFaceId) == aFace2Visibility.end())
continue;
+
+#ifdef USE_ROBUST_TRIANGULATION
+ vtkCell* aFace = aPolyData->GetCell(aFaceId);
+#else
+ vtkCell* aFace = cell->GetFace(aFaceId);
+#endif
+ vtkIdList *anIdList = aFace->PointIds;
+ aNewPts[0] = anIdList->GetId(0);
+ aNewPts[1] = anIdList->GetId(1);
+ aNewPts[2] = anIdList->GetId(2);
- for ( i=0; i < numFacePts; i++)
+ // To initialize set of points for the plane where the trinangle face belong to
+ TPointIds aPointIds;
+ aPointIds.insert(aNewPts[0]);
+ aPointIds.insert(aNewPts[1]);
+ aPointIds.insert(aNewPts[2]);
+
+ // To get know, if the points of the trinagle were already observed
+ bool anIsObserved = aFace2PointIds.find(aPointIds) == aFace2PointIds.end();
+ //cout<<"\taFaceId = "<<aFaceId<<"; anIsObserved = "<<anIsObserved;
+ //cout<<"; aNewPts = {"<<aNewPts[0]<<", "<<aNewPts[1]<<", "<<aNewPts[2]<<"}\n";
+
+ if(!anIsObserved){
+ // To get coordinates of the points of the traingle face
+ float aCoord[3][3];
+ aPoints->GetPoint(aNewPts[0],aCoord[0]);
+ aPoints->GetPoint(aNewPts[1],aCoord[1]);
+ aPoints->GetPoint(aNewPts[2],aCoord[2]);
+
+ // To calculate plane normal
+ float aVector01[3] = { aCoord[1][0] - aCoord[0][0],
+ aCoord[1][1] - aCoord[0][1],
+ aCoord[1][2] - aCoord[0][2] };
+
+ float aVector02[3] = { aCoord[2][0] - aCoord[0][0],
+ aCoord[2][1] - aCoord[0][1],
+ aCoord[2][2] - aCoord[0][2] };
+
+ float aCross21[3];
+ vtkMath::Cross(aVector02,aVector01,aCross21);
+
+ vtkMath::Normalize(aCross21);
+
+ // To calculate what points belong to the plane
+ // To calculate bounds of the point set
+ float aCenter[3] = {0.0, 0.0, 0.0};
{
- aNewPts[i] = cell[i];
+ TPointIds::const_iterator anIter = anInitialPointIds.begin();
+ TPointIds::const_iterator anEndIter = anInitialPointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ float aPntCoord[3];
+ vtkIdType aPntId = *anIter;
+ aPoints->GetPoint(aPntId,aPntCoord);
+ float aDist = vtkPlane::DistanceToPlane(aPntCoord,aCross21,aCoord[0]);
+ //cout<<"\t\taPntId = "<<aPntId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}; aDist = "<<aDist<<"\n";
+ if(fabs(aDist) < aDistEps){
+ aPointIds.insert(aPntId);
+ aCenter[0] += aPntCoord[0];
+ aCenter[1] += aPntCoord[1];
+ aCenter[2] += aPntCoord[2];
+ }
+ }
+ int aNbPoints = aPointIds.size();
+ aCenter[0] /= aNbPoints;
+ aCenter[1] /= aNbPoints;
+ aCenter[2] /= aNbPoints;
+ }
+
+ // To calculate the primary direction for point set
+ float aVector0[3] = { aCoord[0][0] - aCenter[0],
+ aCoord[0][1] - aCenter[1],
+ aCoord[0][2] - aCenter[2] };
+
+ //To sinchronize orientation of the cell and its face
+ float aVectorC[3] = { aCenter[0] - aCellCenter[0],
+ aCenter[1] - aCellCenter[1],
+ aCenter[2] - aCellCenter[2] };
+ vtkMath::Normalize(aVectorC);
+
+ float aDot = vtkMath::Dot(aCross21,aVectorC);
+ //cout<<"\t\taCross21 = {"<<aCross21[0]<<", "<<aCross21[1]<<", "<<aCross21[2]<<"}";
+ //cout<<"; aVectorC = {"<<aVectorC[0]<<", "<<aVectorC[1]<<", "<<aVectorC[2]<<"}\n";
+ //cout<<"\t\taDot = "<<aDot<<"\n";
+ if(aDot > 0){
+ aCross21[0] = -aCross21[0];
+ aCross21[1] = -aCross21[1];
+ aCross21[2] = -aCross21[2];
+ }
+
+ vtkMath::Normalize(aVector0);
+
+ //cout<<"\t\taCenter = {"<<aCenter[0]<<", "<<aCenter[1]<<", "<<aCenter[2]<<"}";
+ //cout<<"; aVector0 = {"<<aVector0[0]<<", "<<aVector0[1]<<", "<<aVector0[2]<<"}\n";
+
+ // To calculate the set of points by face those that belong to the plane
+ TFace2PointIds aRemoveFace2PointIds;
+ {
+ TFace2PointIds::const_iterator anIter = aFace2PointIds.begin();
+ TFace2PointIds::const_iterator anEndIter = aFace2PointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ const TPointIds& anIds = *anIter;
+ TPointIds anIntersection;
+ std::set_intersection(aPointIds.begin(),aPointIds.end(),
+ anIds.begin(),anIds.end(),
+ std::inserter(anIntersection,anIntersection.begin()));
+
+ if(anIntersection == anIds){
+ aRemoveFace2PointIds.insert(anIds);
+ }
+ }
+ }
+
+ // To remove from the set of points by face those that belong to the plane
+ {
+ TFace2PointIds::const_iterator anIter = aRemoveFace2PointIds.begin();
+ TFace2PointIds::const_iterator anEndIter = aRemoveFace2PointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ const TPointIds& anIds = *anIter;
+ aFace2PointIds.erase(anIds);
+ }
+ }
+
+ // To sort the planar set of the points accrding to the angle
+ {
+ typedef std::map<float,vtkIdType> TSortedPointIds;
+ TSortedPointIds aSortedPointIds;
+
+ TPointIds::const_iterator anIter = aPointIds.begin();
+ TPointIds::const_iterator anEndIter = aPointIds.end();
+ for(; anIter != anEndIter; anIter++){
+ float aPntCoord[3];
+ vtkIdType aPntId = *anIter;
+ aPoints->GetPoint(aPntId,aPntCoord);
+ float aVector[3] = { aPntCoord[0] - aCenter[0],
+ aPntCoord[1] - aCenter[1],
+ aPntCoord[2] - aCenter[2] };
+ vtkMath::Normalize(aVector);
+
+ float aCross[3];
+ vtkMath::Cross(aVector,aVector0,aCross);
+ bool aGreaterThanPi = vtkMath::Dot(aCross,aCross21) < 0;
+ float aCosinus = vtkMath::Dot(aVector,aVector0);
+ if(aCosinus > 1.0)
+ aCosinus = 1.0;
+ if(aCosinus < -1.0)
+ aCosinus = -1.0;
+ static float a2Pi = 2.0 * vtkMath::Pi();
+ float anAngle = acos(aCosinus);
+ //cout<<"\t\taPntId = "<<aPntId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}";
+ //cout<<"; aGreaterThanPi = "<<aGreaterThanPi<<"; aCosinus = "<<aCosinus<<"; anAngle = "<<anAngle<<"\n";
+ if(aGreaterThanPi)
+ anAngle = a2Pi - anAngle;
+ aSortedPointIds[anAngle] = aPntId;
+ //cout<<"\t\t\tanAngle = "<<anAngle<<"\n";
+ }
+ if(!aSortedPointIds.empty()){
+ aCellType = VTK_POLYGON;
+ int numFacePts = aSortedPointIds.size();
+ std::vector<vtkIdType> aConnectivities(numFacePts);
+ TSortedPointIds::const_iterator anIter = aSortedPointIds.begin();
+ TSortedPointIds::const_iterator anEndIter = aSortedPointIds.end();
+ for(vtkIdType anId = 0; anIter != anEndIter; anIter++, anId++){
+ vtkIdType aPntId = anIter->second;
+#ifdef USE_ROBUST_TRIANGULATION
+ aConnectivities[anId] = aPts[aPntId];
+#else
+ aConnectivities[anId] = aPntId;
+#endif
+ }
+ newCellId = output->InsertNextCell(aCellType,numFacePts,&aConnectivities[0]);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
}
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId);
}
- outputCD->CopyData(cd,cellId,newCellId);
}
+
break;
}
case VTK_TETRA: {
case VTK_QUADRATIC_TETRA:
case VTK_QUADRATIC_HEXAHEDRON:
if(!myIsWireframeMode){
- vtkGenericCell *cell = vtkGenericCell::New();
input->GetCell(cellId,cell);
vtkIdList *pts = vtkIdList::New();
vtkPoints *coords = vtkPoints::New();
cellIds->Delete();
coords->Delete();
pts->Delete();
- cell->Delete();
break;
}else{
switch(aCellType){
vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points,"
<< output->GetNumberOfCells() << " cells.");
+#ifdef USE_ROBUST_TRIANGULATION
+ anUnstructuredGrid->Delete();
+ aDelaunayPoints->Delete();
+
+ aDelaunay3D->Delete();
+ aGeometryFilter->Delete();
+#endif
+
+ cell->Delete();
+
cellIds->Delete();
faceIds->Delete();
+
if ( cellVis )
{
delete [] cellVis;
#include <vtkMapper.h>
#include <vtkDataSet.h>
#include <vtkSmartPointer.h>
+#include <vtkProperty.h>
#include <qapplication.h>
//VRV: porting on Qt 3.0.5
#include <vtkVertex.h>
#include <vtkRendererCollection.h>
#include <vtkPolyDataWriter.h>
+#include <vtkProperty.h>
// QT Includes
#include <qkeycode.h>