vtkIdType SPV3D_Prs::cellid = 0;
vtkIdType SPV3D_Prs::nbsolid = 0;
//std::map<vtkIdType, const char*> SPV3D_Prs::vtkIdToEntry;
-vtkSmartPointer<vtkMultiBlockDataSet> SPV3D_Prs::multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
+//vtkSmartPointer<vtkMultiBlockDataSet> SPV3D_Prs::multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData()
{
nbsolid = 0;
_multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
+ std::cout << "DDDDDDDDDDDDDDDDDDDDDD" << std::endl;
pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:")));
+ std::cout << "AAAAAAAAAAAAAAAAAAAAAa" << std::endl;
pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
+ std::cout << "BBBBBBBBBBBBBBBBBBBBBB" << std::endl;
_sourceProducer = builder->createSource("sources","PVTrivialProducer",serv);
- _repr = builder->createDataRepresentation(_sourceProducer->getOutputPort(0),getView(),"CADRepresentation");
- vtkSMViewProxy::RepresentationVisibilityChanged(_repr->getViewProxy(), _repr->getProxy(), true);
+ std::cout << "CCCCCCCCCCCCCCCCCCCCC" << std::endl;
}
void SPV3D_EXPORTSPV3DData::SetPolyData(vtkPolyData* ds)
{
nbsolid++;
}
-void SPV3D_EXPORTSPV3DData::SetPrs(vtkPolyData* ds; const char* entry)
+void SPV3D_EXPORTSPV3DData::SetPrs(vtkPolyData* ds, const char* entry)
{
unsigned int id;
if (havePrs(entry, id))
// cellIdArray->SetName("Edge id");
vtkIdType *pt( solidIdArray->GetPointer(0) );
- vtkIdType solidid = SPV3D_Prs::FromEntryToVtkId(GetEntry());
+ vtkIdType solidid = SPV3D_Prs::FromEntryToVtkId(entry);
std::cout <<"Presolidid_from_src: " <<solidid << std::endl;
std::for_each(pt,pt+nbCells,[solidid](vtkIdType& elt) { elt = solidid;});
// pt = cellIdArray->GetPointer(0);
ds->GetCellData()->AddArray( solidIdArray );
// ->GetCellData()->AddArray( cellIdArray );
SetPolyData(ds);
+ updateSource_for_display();
}
void SPV3D_EXPORTSPV3DData::RemovePrs(const char* entry)
if (!havePrs(entry, id))
{
std::cout << "Can not find solid " << entry<< std::endl;
- }
return;
+ }
_multiGEOMData->RemoveBlock(id);
- Hide_list.erase(SPV3D_Prs::FromEntryToVtkId(entry));
+ updateSource_for_display();
+ //Hide_list.erase(SPV3D_Prs::FromEntryToVtkId(entry));
}
-void SPV3D_EXPORTSPV3DData::updateSource_for_display() const
+void SPV3D_EXPORTSPV3DData::updateSource_for_display()
{
vtkNew<vtkAppendPolyData> appendFilter;
- std::cout <<"number of block: " << _multiGEOMData->GetNumberOfBlocks()<<std::endl;
- for (unsigned int i = 0; i < _multiGEOMData->GetNumberOfBlocks(); ++i)
+ nbsolid = _multiGEOMData->GetNumberOfBlocks();
+ std::cout <<"number of block: " << nbsolid<<std::endl;
+ for (unsigned int i = 0; i < nbsolid; ++i)
{
vtkPolyData* polyData = vtkPolyData::SafeDownCast(_multiGEOMData->GetBlock(i));
if (polyData)
{
vtkIdTypeArray* retrievedArray = vtkIdTypeArray::SafeDownCast(polyData->GetCellData()->GetArray("Solid id"));
- if (retrievedArray && !Hide_list.find(retrievedArray->GetValue(0)))
+ if (retrievedArray && Hide_list.find(retrievedArray->GetValue(0)) == Hide_list.end())
appendFilter->AddInputData(polyData);
}
}
vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject);
clientSideObjectCast->SetOutput(ds);
_sourceProducer->updatePipeline();
- pqProxy *producerBase2( getPQProxy(producerBase) );
- if(producerBase2 && !_name.empty())
- producerBase2->rename( _name.c_str() );
+
+ //pqServerManagerModel* smmodel = pqApplicationCore::instance()->getServerManagerModel();
+ //pqProxy *producerBase2( smmodel->findItem<pqProxy*>(producerBase) );
+ //if(producerBase2 && !_name.empty())
+ // producerBase2->rename( _name.c_str() );
}
bool SPV3D_EXPORTSPV3DData::IsVisible() const
bool SPV3D_EXPORTSPV3DData::SolidIsVisible(vtkIdType solid_id) const
{
- if( Hide_list.find(solid_id) )
+ if( Hide_list.find(solid_id) != Hide_list.end() )
return false;
- return true
+ return true;
}
bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id)
void SPV3D_EXPORTSPV3DData::HideSolid(vtkIdType solid_id)
{
- auto ret = Hide_list.emplace(solid_id);
- if (!ret.second)
- std::cout << SPV3D_Prs::FromVtkIdToEntry(solid_id) << " already exists in Hide_list\n" << std::endl;
+ //auto ret = Hide_list.emplace(solid_id);
+ //if (!ret.second)
+ // std::cout << SPV3D_Prs::FromVtkIdToEntry(solid_id) << " already exists in Hide_list\n" << std::endl;
+ const char* entry = SPV3D_Prs::FromVtkIdToEntry(solid_id);
+ std::cout << "entry from vtkidtoentry: "<< entry << std::endl;
+ RemovePrs(entry);
+ updateSource_for_display();
}
void SPV3D_EXPORTSPV3DData::DisplaySolid(vtkIdType solid_id)
{
std::cout << SPV3D_Prs::FromVtkIdToEntry(solid_id) << " is not in Hide_list\n" << std::endl;
}
+ updateSource_for_display();
}
void SPV3D_EXPORTSPV3DData::Hide() const
const char* SPV3D_Prs::FromVtkIdToEntry(vtkIdType id)
{
int d = id & 0xFF;
- std::uint32_t c_work = ( val & 0xFF00 ); int c = c_work >> 8;
- std::uint32_t b_work = ( val & 0xFF0000 ); int b = b_work >> 16;
- std::uint32_t a_work = ( val & 0xFF000000 ); int a = a_work >> 24;
+ std::uint32_t c_work = ( id & 0xFF00 ); int c = c_work >> 8;
+ std::uint32_t b_work = ( id & 0xFF0000 ); int b = b_work >> 16;
+ std::uint32_t a_work = ( id & 0xFF000000 ); int a = a_work >> 24;
std::string ret = std::to_string(a) + ":" + std::to_string(b) + ":" + std::to_string(c)+ ":" + std::to_string(d);
return ret.c_str();
}
return smmodel->findItem<pqProxy*>(proxy);
}
-void SPV3D_Prs::FillUsingActor_init(vtkActor *actor) const
-{
- std::cout << "Hello FillUsingActor"<<std::endl;
-
- SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr;
- alreadyExistingSrc = _view->isEntryAlreadyExist( GetEntry() );
-
- if(alreadyExistingSrc && !alreadyExistingSrc->GetSourceProducer())
- {
- actor->GetMapper()->Update();
- vtkDataObject *ds = actor->GetMapper()->GetInput();
- vtkPolyData *ds3 = vtkPolyData::SafeDownCast(ds);
- vtkNew<vtkPolyData> ds4;
- if(ds3)
- {
- ds4->ShallowCopy( ds3 );
- auto nbCells( ds4->GetNumberOfCells() );
-
- vtkNew<vtkIdTypeArray> solidIdArray;
- std::cout << "nb of cells: " <<nbCells <<std::endl;
- solidIdArray->SetNumberOfComponents(1);
- solidIdArray->SetNumberOfTuples( nbCells );
- solidIdArray->SetName("Solid id");
-
- // vtkNew<vtkIdTypeArray> cellIdArray;
- // cellIdArray->SetNumberOfComponents(1);
- // cellIdArray->SetNumberOfTuples( nbCells );
- // cellIdArray->SetName("Edge id");
-
- vtkIdType *pt( solidIdArray->GetPointer(0) );
- vtkIdType solidid = SPV3D_Prs::FromEntryToVtkId(GetEntry());
- SPV3D_Prs::vtkIdToEntry[solidid] = GetEntry();
- std::cout <<"Presolidid_from_src: " <<solidid << std::endl;
- std::for_each(pt,pt+nbCells,[solidid](vtkIdType& elt) { elt = solidid;});
- // pt = cellIdArray->GetPointer(0);
- // std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::cellid;SPV3D_Prs::cellid++; });
-
- ds4->GetCellData()->AddArray( solidIdArray );
- // ds4->GetCellData()->AddArray( cellIdArray );
- ////Add dataset to multiblock
-//
- SPV3D_Prs::multiGEOMData->SetBlock(SPV3D_Prs::nbsolid , ds4);
- SPV3D_Prs::nbsolid ++;
-//
- }
- vtkNew<vtkAppendPolyData> appendFilter;
- std::cout <<"number of block: " << SPV3D_Prs::multiGEOMData->GetNumberOfBlocks()<<std::endl;
- for (unsigned int i = 0; i < SPV3D_Prs::multiGEOMData->GetNumberOfBlocks(); ++i)
- {
- vtkPolyData* polyData = vtkPolyData::SafeDownCast(SPV3D_Prs::multiGEOMData->GetBlock(i));
- if (polyData)
- {
- appendFilter->AddInputData(polyData);
- }
- }
- appendFilter->Update();
- vtkNew<vtkPolyData> ds5;
- ds5->ShallowCopy(appendFilter->GetOutput());
-
- pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:")));
- pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
- pqPipelineSource *mySourceProducer(builder->createSource("sources","PVTrivialProducer",serv));
- vtkSMProxy* producerBase = mySourceProducer->getProxy();
- vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase));
- vtkObjectBase *clientSideObject(producer->GetClientSideObject());
- vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject);
- clientSideObjectCast->SetOutput(ds5);
- mySourceProducer->updatePipeline();
- pqProxy *producerBase2( getPQProxy(producerBase) );
- if(producerBase2 && !_name.empty())
- producerBase2->rename( _name.c_str() );
- this->SetSourceProducer( mySourceProducer );
- }
- else
- {
- this->CopyInfo( alreadyExistingSrc );
- }
-}
-
SPV3D_Prs:: ~SPV3D_Prs()
{
}
void SPV3D_Prs::FillUsingActor(vtkActor *actor) const
{
std::cout << "Hello FillUsingActor"<<std::endl;
-
+ std::cout << "entry: " <<GetEntry()<< std::endl;
//SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr;
- alreadyExisting = _view->isEntryAlreadyExist( GetEntry() );
+ int id = _view->isEntryAlreadyExist( GetEntry() );
- if(alreadyExisting) // hide but it exist in SPV3D_EXPORTSPV3DData
+ if(id == -1) // not exist
{
-
+ std::cout << "FillUsingActor111111111111111"<<std::endl;
+ actor->GetMapper()->Update();
+ vtkDataObject *ds = actor->GetMapper()->GetInput();
+ vtkPolyData *ds2 = vtkPolyData::SafeDownCast(ds);
+ if(ds2)
+ {
+ std::cout << "FillUsingActor2222222222222222éé"<<std::endl;
+ _view->ExportToSPV3D(ds2, GetEntry());
+ }
}
- else
+ else //exist but hide
{
- this->CopyInfo( alreadyExistingSrc );
+ std::cout << "FillUsingActor33333333333333é"<<std::endl;
+ _view->DisplayObj_withEntry( GetEntry() );
}
}
\ No newline at end of file
#include "SPV3D_ViewModel.h"
#include "SPV3D_ViewWindow.h"
-#include "SPV3D_Prs.h"
#include "PVViewer_Core.h"
#include <pqActiveObjects.h>
return _view;
}
+void SPV3D_ViewModel::updatePVPrsPipeline(const SPV3D_Prs* aPrs)
+{
+ if (aPrs->GetRepresentation())
+ {
+ aPrs->GetRepresentation()->setVisible(0);
+ delete(aPrs->GetRepresentation());
+ }
+ pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
+ pqActiveObjects::instance().setActiveView(getView());
+ pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer();
+ aPrs->SetSourceProducer( mySourceProducer );
+ pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"CADRepresentation"));//"GeometryRepresentation"
+ vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true);
+ aPrs->SetRepresentation(myRepr);
+ myRepr->setVisible(1);
+ vtkSMPVRepresentationProxy* proxy(dynamic_cast<vtkSMPVRepresentationProxy*>(myRepr->getProxy()));
+ if(proxy)
+ {
+ vtkSMPropertyHelper inputHelper(proxy, "Input");
+ vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy());
+ input->UpdatePipeline();
+ }
+}
/*!
Display presentation
\param prs - presentation
*/
void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs )
{
+ std::cout << "SPV3D_ViewModel::Display" << std::endl;
+ if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( prs ))
+ {
+ updatePVPrsPipeline(aPrs);
+ getView()->resetDisplay();
+ getView()->render();
+ }
+ else
+ {
+ std::cout<< "Can't update PV presentation pipeline"<< std::endl;
+ }
+ /*
+
if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( prs ))
{
if( !aPrs->GetRepresentation() )
aPrs->SetSourceProducer( mySourceProducer );
pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"CADRepresentation"));//"GeometryRepresentation"
vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true);
+
aPrs->SetRepresentation(myRepr);
}
pqDataRepresentation* myRepr = aPrs->GetRepresentation();
+
myRepr->setVisible(1);
vtkSMPVRepresentationProxy* proxy(dynamic_cast<vtkSMPVRepresentationProxy*>(myRepr->getProxy()));
if(proxy)
getView()->resetDisplay();
getView()->render();
}
+ */
}
/*!
void SPV3D_ViewModel::Erase( const SALOME_PV3DPrs* prs, const bool /*forced*/ )
{
// NYI - hide a source
- std::cout << "SPV3D_ViewModel::Erase"<< std::endl;
if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( prs )){
if(aPrs->IsNull())
return;
- aPrs->GetRepresentation()->setVisible(0);
+ aPrs->hide();
+ updatePVPrsPipeline(aPrs);
+ ////aPrs->GetRepresentation()->setVisible(0);
+ ////aPrs->GetRepresentation()->setVisible(1);
+ ////
+ getView()->resetDisplay();
getView()->render();
//pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
//pqServer* activeServer = pqActiveObjects::instance().activeServer();
*/
SPV3D_ViewWindow::SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel):
PV3DViewer_ViewWindow(theDesktop, theModel),
- myModel(theModel),
- myPrs( new SPV3D_EXPORTSPV3DData())
+ myModel(theModel)
{
}
QAction *selectionAction = toolMgr()->toolBar(myToolBar)->addAction(SUIT_Session::session()->resourceMgr()->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ), tr( "MNU_SVTK_PRESELECTION_STANDARD" ) );
selectionAction->setCheckable(true);
QObject::connect(selectionAction, &QAction::toggled, this, &SPV3D_ViewWindow::goSelect);
+
+ SPV3D_EXPORTSPV3DData* rawPtr = new SPV3D_EXPORTSPV3DData();
+ myPrs.reset(rawPtr);
}
void SPV3D_ViewWindow::goSelect(bool val)
renderView->render();
}
+
SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry )
{//en cours
- std::string entryCpp( entry );
SPV3D_Prs *prsOut( new SPV3D_Prs( entry, this ) );
- for(auto& prs : myPrs)
- {
- if(entryCpp == prs.first)
- {
- prsOut->SetPVRenderInfo( prs.second.get() );
- return prsOut;
- }
- }
- std::unique_ptr<SPV3D_EXPORTSPV3DData> data(new SPV3D_EXPORTSPV3DData);
- prsOut->SetPVRenderInfo( data.get() );
- std::pair<std::string, std::unique_ptr<SPV3D_EXPORTSPV3DData> > p(entryCpp,std::move(data));
- myPrs.emplace_back( std::move(p) );
+ prsOut->SetPVRenderInfo( myPrs.get() );
return prsOut;
}
-SPV3D_EXPORTSPV3DData *SPV3D_ViewWindow::isEntryAlreadyExist( const char* entry ) const
+unsigned int SPV3D_ViewWindow::isEntryAlreadyExist( const char* entry ) const
{
//std::string entryCpp( entry );
//for(const auto& prs : myPrs)
//return nullptr;
unsigned int id;
if(myPrs->havePrs(entry, id))
- {
-
- }
+ return id;
else
- {
- return nullptr;
- }
+ return -1;
+}
+
+void SPV3D_ViewWindow::ExportToSPV3D(vtkPolyData* ds, const char* entry)
+{
+ myPrs->SetPrs(ds, entry);
}
/*!
bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
{
- std::string entryCpp( theIObject->getEntry() );
- for(auto& prs : myPrs)
+ auto entry = theIObject->getEntry();
+ //for(auto& prs : myPrs)
+ //{
+ // if(entryCpp == prs.first )
+ // return prs.second->IsVisible();
+ //}
+ unsigned int id;
+ if (myPrs->havePrs(entry, id))
{
- if(entryCpp == prs.first )
- return prs.second->IsVisible();
+ return myPrs->SolidIsVisible(SPV3D_Prs::FromEntryToVtkId(entry));
}
return false;
}
//{
// prs.second->Hide();
//}
- myPrs->Hide()
+ myPrs->Hide();
if(myModel)
myModel->render();
}
{
emit Hide( theEvent );
}
+
+void SPV3D_ViewWindow::DisplayObj_withEntry(const char* entry)
+{
+ myPrs->DisplaySolid(SPV3D_Prs::FromEntryToVtkId(entry));
+}
+
+void SPV3D_ViewWindow::HideObj_withEntry(const char* entry)
+{
+ myPrs->HideSolid(SPV3D_Prs::FromEntryToVtkId(entry));
+}
\ No newline at end of file