Thanks for reporting Nehme. I've added a bug report: http://paraview.org/Bug/view.php?id=12959
Utkarsh On Wed, Feb 22, 2012 at 11:42 AM, Nehme Bilal <[email protected]> wrote: > Hello, > > Just to let you know that copying and pasting of a clip filter causes > a crash. I think it will be the same for all filters using a 3D > widget. > > I implemented a copy/paste few years ago for ParaViewGeo (based on > ParaView 3.4) and I think that it was able to copy the 3D widgets > correctly. The copy/paste action was a little different: when you copy > a filter, you can paste it on a source and it will create a new filter > on that source with the copied properties. > I find the new way used in ParaView (copying and pasting from/to > existing objects) simpler and better. Here is my old code, in case it > can help fixing the bug. > > //---------------------------------------------------------------------------- > void pqPipelineBrowser::copyItem() > { > // The copy item option only supports one filter at a time. > if(this->getSelectionModel()->selectedIndexes().size() != 1) > { > this->proxyCopy = NULL; > this->proxyCopyType = "none"; > this->portCopy = NULL; > return; > } > QModelIndex current = this->getSelectionModel()->currentIndex(); > vtkSMProxyManager *proxyManager = vtkSMProxyManager::GetProxyManager(); > > pqPipelineFilter *filter = dynamic_cast<pqPipelineFilter *>( > this->Model->getItemFor(current)); > if(filter) > { > this->proxyCopyType = "filter"; > this->portCopy = filter->getOutputPort(0); > } > else > { > pqPipelineSource *source = dynamic_cast<pqPipelineSource*>( > this->Model->getItemFor(current)); > > if(source) > { > this->portCopy = source->getOutputPort(0); > this->proxyCopyType = "source"; > } > else > { > this->portCopy = NULL; > this->proxyCopyType = "none"; > } > } > emit copyFired(this->portCopy); > } > > //---------------------------------------------------------------------------- > void pqPipelineBrowser::pasteItem() > { > > if(!this->portCopy) > return; > > QModelIndexList indexes = this->getSelectionModel()->selectedIndexes(); > > // The copy/paste feature only supports one filter at a time. > if(indexes.size() != 1) > { > return; > } > > pqOutputPort *Port = NULL; > > QModelIndex current = this->getSelectionModel()->currentIndex(); > pqPipelineSource *source = dynamic_cast<pqPipelineSource *>( > this->Model->getItemFor(current)); > > if(!source) > { > Port = dynamic_cast<pqOutputPort *>( > this->Model->getItemFor(indexes.first())); > if(Port) > { > source = Port->getSource(); > } > } > > pqApplicationCore* core = pqApplicationCore::instance(); > pqObjectBuilder* builder = core->getObjectBuilder(); > > if(source) > { > if(this->proxyCopyType == "filter") > { > vtkSMInputProperty *input = > vtkSMInputProperty::SafeDownCast( > > portCopy->getSource()->getProxy()->GetProperty("Input")); > input->RemoveAllUncheckedProxies(); > > if(!Port) > { > Port = source->getOutputPort(0); > } > input->AddUncheckedInputConnection( > Port->getSource()->getProxy(), > Port->getPortNumber()); > > > if(input->IsInDomains()) > { > QMap<QString, QList<pqOutputPort*> > > namedInputs; > QList<pqOutputPort*> inputs; > inputs.push_back(Port); > namedInputs["Input"] = inputs; > > pqPipelineSource* newFilter = > builder->createFilter("filters", > > portCopy->getSource()->getProxy()->GetXMLName(), namedInputs, > this->Internal->activeServer); > this->copyPipelineProxy(portCopy->getSource(), > newFilter); > } > else > { > qDebug()<< "incompatible source type"; > } > > > } > } > > else if(this->proxyCopyType == "source") > { > vtkSMStringVectorProperty *fileName = > vtkSMStringVectorProperty:: > > SafeDownCast(portCopy->getSource()->getProxy()->GetProperty("FileName")); > > pqPipelineSource *newSource; > if(fileName) > { > newSource = builder->createReader("sources", > > portCopy->getSource()->getProxy()->GetXMLName(), > QStringList(tr(fileName->GetElement(0))), > this->Internal->activeServer); > } > else > { > vtkSMStringVectorProperty *fileName = > vtkSMStringVectorProperty:: > > SafeDownCast(portCopy->getSource()->getProxy()->GetProperty("FileNames")); > if(fileName) > { > QStringList files; > for(unsigned int i=0; > i<fileName->GetNumberOfElements(); i++) > { > > files.push_back(fileName->GetElement(i)); > } > newSource = builder->createReader("sources", > > portCopy->getSource()->getProxy()->GetXMLName(), > files, this->Internal->activeServer); > } > else > { > newSource = builder->createSource("sources", > > portCopy->getSource()->getProxy()->GetXMLName(),this->Internal->activeServer); > } > } > > this->copyPipelineProxy(portCopy->getSource(), newSource); > } > } > > //------------------------------------------------------------------------------------------ > void pqPipelineBrowser::copyPipelineProxy(pqPipelineSource* src, > pqPipelineSource* dest) > { > this->copyHelperProxies(src,dest); > this->copyProxy(src->getProxy(),dest->getProxy()); > > vtkSMPropertyIterator* piter; > piter = src->getProxy()->NewPropertyIterator(); > for(piter->Begin(); !piter->IsAtEnd(); piter->Next()) > { > if (piter->GetProperty()->IsA("vtkSMProxyProperty") &! > piter->GetProperty()->IsA("vtkSMInputProperty")) > { > vtkSMProxyProperty* psource = > (vtkSMProxyProperty*)piter->GetProperty(); > > // get helperProxy ID > int ID = -1; > for (int i=0;i<src->getHelperProxies().size();i++) > { > if (src->getHelperProxies()[i] == psource->GetProxy(0)) > { > ID = i; > break; > } > } > if (ID != -1) > { > vtkSMProxyProperty* ptarget = > (vtkSMProxyProperty*)dest->getProxy()->GetProperty(piter->GetKey()); > ptarget->SetProxy(0, dest->getHelperProxies()[ID]); > } > } > } > piter->Delete(); > } > > > //------------------------------------------------------------------------------------------ > void pqPipelineBrowser::copyProxy(vtkSMProxy* src, vtkSMProxy* dest) > { > vtkSMProxyManager *pxm = vtkSMProxyManager::GetProxyManager(); > vtkSMPropertyIterator* iter = dest->NewPropertyIterator(); > for (iter->Begin(); !iter->IsAtEnd(); iter->Next()) > { > vtkSMProperty* destProp = iter->GetProperty(); > vtkSMProperty* srcProp = src->GetProperty(iter->GetKey()); > > if(!destProp->IsA("vtkSMProxyProperty") ) > { > if (destProp && srcProp) > { > destProp->Copy(srcProp); > } > } > } > iter->Delete(); > } > > //------------------------------------------------------------------------------------------ > void pqPipelineBrowser::copyHelperProxies(pqPipelineSource* src, > pqPipelineSource* dest) > { > > QList<QString> helperProxiesKey = dest->getHelperKeys(); > foreach(QString key, helperProxiesKey) > { > QList<vtkSMProxy*> destProxies = dest->getHelperProxies(key); > QList<vtkSMProxy*> srcProxies = src->getHelperProxies(key); > int i=0; > foreach(vtkSMProxy* proxy, destProxies) > { > this->copyProxy(srcProxies[i], proxy); > } > } > } > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Follow this link to subscribe/unsubscribe: > http://www.paraview.org/mailman/listinfo/paraview _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview
