Commit 08e58f46 authored by Yumin Yuan's avatar Yumin Yuan Committed by Kitware Robot

Merge topic 'inline-code-cleanup'

c76e00ca Clean up some inline codes that behaves randomly on different os
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Bob Obara's avatarBob Obara <bob.obara@kitware.com>
Merge-request: !355
parents 17145d98 c76e00ca
......@@ -63,6 +63,50 @@ public:
delete this->ContoursDialog;
}
}
qtAttribute* createAttUI(
smtk::attribute::AttributePtr att, QWidget* pw, qtBaseView* view)
{
if(att && att->numberOfItems()>0)
{
qtAttribute* attInstance = new qtAttribute(att, pw, view);
if(attInstance && attInstance->widget())
{
//Without any additional info lets use a basic layout with model associations
// if any exists
attInstance->createBasicLayout(true);
attInstance->widget()->setObjectName("polygonContourOpEditor");
QVBoxLayout* parentlayout = static_cast<QVBoxLayout*> (pw->layout());
parentlayout->insertWidget(0, attInstance->widget());
}
return attInstance;
}
return NULL;
}
vtkSMProxy* createVTKContourOperator(
vtkSMProxy *sourceProxy)
{
vtkSMProxy* smPolyEdgeOp = vtkSMProxyManager::GetProxyManager()->NewProxy(
"polygon_operators", "PolygonContourOperator");
if(!smPolyEdgeOp)
return NULL;
smPolyEdgeOp->UpdateVTKObjects();
sourceProxy->UpdateVTKObjects();
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(sourceProxy) << "GetOutputDataObject"
<< 0
<< vtkClientServerStream::End;
smPolyEdgeOp->GetSession()->ExecuteStream(smPolyEdgeOp->GetLocation(), stream);
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(smPolyEdgeOp) << "SetContourInput"
<< smPolyEdgeOp->GetSession()->GetLastResult(vtkProcessModule::DATA_SERVER_ROOT).GetArgument(0,0)
<< vtkClientServerStream::End;
smPolyEdgeOp->GetSession()->ExecuteStream(smPolyEdgeOp->GetLocation(), stream);
return smPolyEdgeOp;
}
QPointer<pqGenerateContoursDialog> ContoursDialog;
QPointer<qtAttribute> CurrentAtt;
......@@ -132,51 +176,6 @@ void qtExtractContoursView::createWidget( )
layout->addWidget(contourButton);
}
inline qtAttribute* internal_createAttUI(
smtk::attribute::AttributePtr att, QWidget* pw, qtBaseView* view)
{
if(att && att->numberOfItems()>0)
{
qtAttribute* attInstance = new qtAttribute(att, pw, view);
if(attInstance && attInstance->widget())
{
//Without any additional info lets use a basic layout with model associations
// if any exists
attInstance->createBasicLayout(true);
attInstance->widget()->setObjectName("polygonContourOpEditor");
QVBoxLayout* parentlayout = static_cast<QVBoxLayout*> (pw->layout());
parentlayout->insertWidget(0, attInstance->widget());
}
return attInstance;
}
return NULL;
}
inline vtkSMProxy* internal_createVTKContourOperator(
vtkSMProxy *sourceProxy)
{
vtkSMProxy* smPolyEdgeOp = vtkSMProxyManager::GetProxyManager()->NewProxy(
"polygon_operators", "PolygonContourOperator");
if(!smPolyEdgeOp)
return NULL;
smPolyEdgeOp->UpdateVTKObjects();
sourceProxy->UpdateVTKObjects();
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(sourceProxy) << "GetOutputDataObject"
<< 0
<< vtkClientServerStream::End;
smPolyEdgeOp->GetSession()->ExecuteStream(smPolyEdgeOp->GetLocation(), stream);
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(smPolyEdgeOp) << "SetContourInput"
<< smPolyEdgeOp->GetSession()->GetLastResult(vtkProcessModule::DATA_SERVER_ROOT).GetArgument(0,0)
<< vtkClientServerStream::End;
smPolyEdgeOp->GetSession()->ExecuteStream(smPolyEdgeOp->GetLocation(), stream);
return smPolyEdgeOp;
}
//----------------------------------------------------------------------------
void qtExtractContoursView::updateAttributeData()
{
......@@ -226,7 +225,7 @@ void qtExtractContoursView::updateAttributeData()
this->Internals->CurrentOp = edgeOp;
// expecting only 1 instance of the op?
smtk::attribute::AttributePtr att = edgeOp->specification();
this->Internals->CurrentAtt = internal_createAttUI(att, this->Widget, this);
this->Internals->CurrentAtt = this->Internals->createAttUI(att, this->Widget, this);
}
//----------------------------------------------------------------------------
......@@ -271,7 +270,7 @@ void qtExtractContoursView::acceptContours(pqPipelineSource* contourSource)
smtk::attribute::IntItem::Ptr opProxyIdItem = spec->findInt("HelperGlobalID");
if(!opProxyIdItem)
return;
vtkSMProxy* smPolyEdgeOp = internal_createVTKContourOperator(contourSource->getProxy());
vtkSMProxy* smPolyEdgeOp = this->Internals->createVTKContourOperator(contourSource->getProxy());
if(!smPolyEdgeOp)
return;
if(this->Internals->CurrentImage)
......
......@@ -56,6 +56,49 @@ public:
delete CurrentAtt;
}
bool needArc(const smtk::model::OperatorPtr& op)
{
bool able2Op = op
&& (op->name() == "tweak edge"
|| op->name() == "create edge")
&& op->ensureSpecification()
;
if(!able2Op)
{
return able2Op;
}
// for create-edge operation, we only handle "interactive widget" case
if(op->name() == "create edge")
{
smtk::attribute::IntItem::Ptr optypeItem =
op->specification()->findInt("construction method");
able2Op = optypeItem && (optypeItem->discreteIndex(0) == 2);
}
return able2Op;
}
qtAttribute* createAttUI(
smtk::attribute::AttributePtr att, QWidget* pw, qtBaseView* view)
{
if(att && att->numberOfItems()>0)
{
qtAttribute* attInstance = new qtAttribute(att, pw, view);
if(attInstance && attInstance->widget())
{
//Without any additional info lets use a basic layout with model associations
// if any exists
attInstance->createBasicLayout(true);
attInstance->widget()->setObjectName("polygonEdgeOpEditor");
QVBoxLayout* parentlayout = static_cast<QVBoxLayout*> (pw->layout());
parentlayout->insertWidget(0, attInstance->widget());
}
return attInstance;
}
return NULL;
}
QPointer<pqArcWidgetManager> ArcManager;
QPointer<qtAttribute> CurrentAtt;
QPointer<QVBoxLayout> EditorLayout;
......@@ -125,49 +168,6 @@ void qtPolygonEdgeOperationView::createWidget( )
this, SLOT(cancelOperation(const smtk::model::OperatorPtr&)));
}
inline bool internal_needArc(const smtk::model::OperatorPtr& op)
{
bool able2Op = op
&& (op->name() == "tweak edge"
|| op->name() == "create edge")
&& op->ensureSpecification()
;
if(!able2Op)
{
return able2Op;
}
// for create-edge operation, we only handle "interactive widget" case
if(op->name() == "create edge")
{
smtk::attribute::IntItem::Ptr optypeItem =
op->specification()->findInt("construction method");
able2Op = optypeItem && (optypeItem->discreteIndex(0) == 2);
}
return able2Op;
}
inline qtAttribute* internal_createAttUI(
smtk::attribute::AttributePtr att, QWidget* pw, qtBaseView* view)
{
if(att && att->numberOfItems()>0)
{
qtAttribute* attInstance = new qtAttribute(att, pw, view);
if(attInstance && attInstance->widget())
{
//Without any additional info lets use a basic layout with model associations
// if any exists
attInstance->createBasicLayout(true);
attInstance->widget()->setObjectName("polygonEdgeOpEditor");
QVBoxLayout* parentlayout = static_cast<QVBoxLayout*> (pw->layout());
parentlayout->insertWidget(0, attInstance->widget());
}
return attInstance;
}
return NULL;
}
//----------------------------------------------------------------------------
void qtPolygonEdgeOperationView::updateAttributeData()
{
......@@ -217,12 +217,12 @@ void qtPolygonEdgeOperationView::updateAttributeData()
this->Internals->CurrentOp = edgeOp;
// expecting only 1 instance of the op?
smtk::attribute::AttributePtr att = edgeOp->specification();
this->Internals->CurrentAtt = internal_createAttUI(att, this->Widget, this);
this->Internals->CurrentAtt = this->Internals->createAttUI(att, this->Widget, this);
// The arc widget interaction is only needed for:
// * create edge op : with "construction method" set to "interactive widget"
// * tweak edge
if(internal_needArc(edgeOp))
if(this->Internals->needArc(edgeOp))
{
pqRenderView* renView = qobject_cast<pqRenderView*>(pqActiveObjects::instance().activeView());
pqServer* server = pqApplicationCore::instance()->getActiveServer();
......@@ -323,7 +323,7 @@ void qtPolygonEdgeOperationView::operationSelected(const smtk::model::OperatorPt
return;
// Based on which type of operations, we update UI panel
if(internal_needArc(op) && this->Internals->ArcManager)
if(this->Internals->needArc(op) && this->Internals->ArcManager)
{
if(this->Internals->SplitEdgeWidget)
{
......
......@@ -55,6 +55,26 @@ public:
~qtSurfaceExtractorViewInternals()
{
}
qtAttribute* createAttUI(smtk::attribute::AttributePtr att, QWidget* pw, qtBaseView* view)
{
if(att && att->numberOfItems()>0)
{
qtAttribute* attInstance = new qtAttribute(att, pw, view);
if(attInstance && attInstance->widget())
{
//Without any additional info lets use a basic layout with model associations
// if any exists
attInstance->createBasicLayout(true);
attInstance->widget()->setObjectName("polygonContourOpEditor");
QVBoxLayout* parentlayout = static_cast<QVBoxLayout*> (pw->layout());
parentlayout->insertWidget(0, attInstance->widget());
}
return attInstance;
}
return NULL;
}
QPointer<qtAttribute> CurrentAtt;
smtk::weak_ptr<smtk::model::Operator> CurrentOp;
imageFeatureExtractorWidget * ExtractorWidget;
......@@ -121,26 +141,6 @@ void qtSurfaceExtractorView::createWidget( )
layout->addWidget(contourButton);
}
inline qtAttribute*
internal_createAttUI(smtk::attribute::AttributePtr att, QWidget* pw, qtBaseView* view)
{
if(att && att->numberOfItems()>0)
{
qtAttribute* attInstance = new qtAttribute(att, pw, view);
if(attInstance && attInstance->widget())
{
//Without any additional info lets use a basic layout with model associations
// if any exists
attInstance->createBasicLayout(true);
attInstance->widget()->setObjectName("polygonContourOpEditor");
QVBoxLayout* parentlayout = static_cast<QVBoxLayout*> (pw->layout());
parentlayout->insertWidget(0, attInstance->widget());
}
return attInstance;
}
return NULL;
}
//----------------------------------------------------------------------------
void qtSurfaceExtractorView::updateAttributeData()
{
......@@ -190,7 +190,7 @@ void qtSurfaceExtractorView::updateAttributeData()
this->Internals->CurrentOp = edgeOp;
// expecting only 1 instance of the op?
smtk::attribute::AttributePtr att = edgeOp->specification();
this->Internals->CurrentAtt = internal_createAttUI(att, this->Widget, this);
this->Internals->CurrentAtt = this->Internals->createAttUI(att, this->Widget, this);
}
//----------------------------------------------------------------------------
......
......@@ -34,25 +34,27 @@
using namespace smtk::attribute;
using namespace smtk::extension;
inline void init_Att_Names_and_NEW(QList<QString>& attNames,
const RefItemDefinition *itemDef)
{
smtk::attribute::DefinitionPtr attDef = itemDef->attributeDefinition();
if(!attDef)
{
return;
}
attNames.push_back("None");
std::vector<smtk::attribute::AttributePtr> result;
System *attSystem = attDef->system();
attSystem->findAttributes(attDef, result);
std::vector<smtk::attribute::AttributePtr>::iterator it;
for (it=result.begin(); it!=result.end(); ++it)
{
attNames.push_back((*it)->name().c_str());
}
attNames.push_back("New");
}
namespace qtAttRefComboInternal {
void init_Att_Names_and_NEW(QList<QString>& attNames,
const RefItemDefinition *itemDef)
{
smtk::attribute::DefinitionPtr attDef = itemDef->attributeDefinition();
if(!attDef)
{
return;
}
attNames.push_back("None");
std::vector<smtk::attribute::AttributePtr> result;
System *attSystem = attDef->system();
attSystem->findAttributes(attDef, result);
std::vector<smtk::attribute::AttributePtr>::iterator it;
for (it=result.begin(); it!=result.end(); ++it)
{
attNames.push_back((*it)->name().c_str());
}
attNames.push_back("New");
}
};
//-----------------------------------------------------------------------------
qtAttRefCombo::qtAttRefCombo(smtk::attribute::ItemPtr refitem, QWidget * inParent)
......@@ -80,7 +82,7 @@ void qtAttRefCombo::showPopup()
const RefItemDefinition *itemDef =
dynamic_cast<const RefItemDefinition*>(
this->m_RefItem.lock()->definition().get());
init_Att_Names_and_NEW(attNames, itemDef);
qtAttRefComboInternal::init_Att_Names_and_NEW(attNames, itemDef);
this->blockSignals(true);
RefItemPtr refitem =
......@@ -421,7 +423,7 @@ void qtAttributeRefItem::updateItemData()
return;
}
QList<QString> attNames;
init_Att_Names_and_NEW(attNames, itemDef);
qtAttRefComboInternal::init_Att_Names_and_NEW(attNames, itemDef);
foreach(QComboBox* combo, this->Internals->comboBoxes)
{
......
......@@ -692,29 +692,8 @@ void QEntityItemModel::rebuildSubphrases(const QModelIndex& qidx)
emit dataChanged(qidx, qidx);
}
/*
inline QModelIndex _internal_getPhraseIndex(
smtk::extension::QEntityItemModel* qmodel,
const smtk::model::EntityRef& entRef,
const QModelIndex& top, bool recursive = false)
namespace QEntityItemModelInternal
{
for (int row = 0; row < qmodel->rowCount(top); ++row)
{
QModelIndex cIdx(qmodel->index(row, 0, top));
DescriptivePhrasePtr dp = qmodel->getItem(cIdx);
if(dp && (dp->relatedEntity() == entRef))
return cIdx;
if(recursive)
{
QModelIndex recurIdx(_internal_getPhraseIndex(qmodel, entRef, cIdx, recursive));
if(recurIdx.isValid())
return recurIdx;
}
}
return QModelIndex();
}
*/
inline QModelIndex _internal_getPhraseIndex(
smtk::extension::QEntityItemModel* qmodel,
const DescriptivePhrasePtr& phrase,
......@@ -827,6 +806,7 @@ inline void _internal_updateAllMeshCollectionPhrases(
}
}
}
};
void QEntityItemModel::addChildPhrases(
const DescriptivePhrasePtr& parntDp,
......@@ -836,7 +816,7 @@ void QEntityItemModel::addChildPhrases(
QModelIndex qidx;
if(parntDp != this->m_root)
{
qidx = (_internal_getPhraseIndex(
qidx = (QEntityItemModelInternal::_internal_getPhraseIndex(
this, parntDp, topIndex, descend));
if(!qidx.isValid())
{
......@@ -929,7 +909,7 @@ void QEntityItemModel::removeChildPhrases(
const std::vector< std::pair<DescriptivePhrasePtr, int> > & remDphrs,
const QModelIndex& topIndex)
{
QModelIndex qidx(_internal_getPhraseIndex(
QModelIndex qidx(QEntityItemModelInternal::_internal_getPhraseIndex(
this, parntDp, topIndex, true));
if(!qidx.isValid())
{
......@@ -1088,7 +1068,7 @@ void QEntityItemModel::updateChildPhrases(
// subphrases did not change, just emit dataChanged signal
if(remDphrs.size() == 0 && newDphrs.size() == 0 && emitEvenNoChanges)
{
QModelIndex qidx(_internal_getPhraseIndex(
QModelIndex qidx(QEntityItemModelInternal::_internal_getPhraseIndex(
this, phrase, topIndex, true));
if(!qidx.isValid())
{
......@@ -1288,7 +1268,7 @@ void QEntityItemModel::updateMeshPhrases(
{
DescriptivePhrases meshPhrasesNeedUpdate;
DescriptivePhrases collectionPhrases;
_internal_updateAllMeshCollectionPhrases(startDp, relatedCollections,
QEntityItemModelInternal::_internal_updateAllMeshCollectionPhrases(startDp, relatedCollections,
meshPhrasesNeedUpdate, collectionPhrases, meshMgr);
smtk::model::DescriptivePhrases::iterator mit;
for(mit = meshPhrasesNeedUpdate.begin(); mit != meshPhrasesNeedUpdate.end(); ++mit)
......@@ -1297,7 +1277,7 @@ void QEntityItemModel::updateMeshPhrases(
// emit DataChanged signal for collection index
for(mit = collectionPhrases.begin(); mit != collectionPhrases.end(); ++mit)
{
QModelIndex qidx(_internal_getPhraseIndex(this, *mit, topIndex, true));
QModelIndex qidx(QEntityItemModelInternal::_internal_getPhraseIndex(this, *mit, topIndex, true));
if(qidx.isValid())
emit this->dataChanged(qidx, qidx);
}
......@@ -1359,7 +1339,7 @@ void QEntityItemModel::updateWithOperatorResult(
result->findModelEntity("modified");
if(modEnts && modEnts->numberOfValues() > 0)
{
_internal_findAllExistingPhrases(startPhr, modEnts, modifiedPhrases);
QEntityItemModelInternal::_internal_findAllExistingPhrases(startPhr, modEnts, modifiedPhrases);
smtk::model::DescriptivePhrases::iterator mit;
for(mit = modifiedPhrases.begin(); mit != modifiedPhrases.end(); ++mit)
this->updateChildPhrases(*mit, sessIndex);
......@@ -1382,12 +1362,12 @@ void QEntityItemModel::updateWithOperatorResult(
if(relatedCollections.size() > 0)
this->updateMeshPhrases(relatedCollections, startPhr, sessIndex, this->manager()->meshes());
_internal_findAllExistingMeshPhrases(startPhr, modifiedMeshes, modifiedMeshPhrases);
QEntityItemModelInternal::_internal_findAllExistingMeshPhrases(startPhr, modifiedMeshes, modifiedMeshPhrases);
smtk::model::DescriptivePhrases::iterator mit;
for(mit = modifiedMeshPhrases.begin(); mit != modifiedMeshPhrases.end(); ++mit)
{
QModelIndex qidx(_internal_getPhraseIndex(
QModelIndex qidx(QEntityItemModelInternal::_internal_getPhraseIndex(
this, *mit, sessIndex, true));
if(!qidx.isValid())
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment