/**
 * Creates a new tracker insert command that adds a \a tracker to a parent node with \a parentIndex in the \a model.
 *
 * If \a parent is not null, this command is appended to parent's child list and then owns this command.
 */
CmdInsertTracker::CmdInsertTracker( TTracker* tracker,  const QModelIndex& parentIndex, SoSceneKit* scene, SceneModel* model, QUndoCommand* parent )
: QUndoCommand("Insert Tracker", parent), m_tracker ( tracker ), m_coinParent( 0 ), m_scene( scene ), m_pModel( model ), m_row( 0 )
{
	if( !m_tracker ) gf::SevereError( "CmdInsertTracker Null tracker." );
	m_tracker->ref();

	if( !parentIndex.isValid() ) gf::SevereError( "CmdInsertTracker called with invalid ModelIndex." );
	InstanceNode* instanceParent = m_pModel->NodeFromIndex( parentIndex );
	if( !instanceParent->GetNode() ) gf::SevereError( "CmdInsertTracker called with NULL parent node." );
	m_coinParent = static_cast< SoBaseKit* > ( instanceParent->GetNode() );
}
/**
 * Creates a new analyzerkit insert command that adds a \a analyzerkit node to a node given with the \a parentIndex node in the \a model.
 *
 * If \a parent is not null, this command is appended to parent's child list and then owns this command.
 */
CmdInsertAnalyzerKit::CmdInsertAnalyzerKit( const QModelIndex& parentIndex, TAnalyzerKit* analyzerKit, SceneModel* model, QUndoCommand* parent )
    : QUndoCommand("InsertAnalyzerKit", parent), m_coinParent( 0 ), m_analyzerKit(analyzerKit), m_pModel(model), m_row( -1 )
{
    if( m_analyzerKit == 0 ) gf::SevereError( "CmdInsertAnalyzerKit called with NULL TAnalyzerKit*" );
    m_analyzerKit->ref();

    if( !parentIndex.isValid() ) gf::SevereError( "CmdInsertAnalyzerKit called with invalid ModelIndex." );
    InstanceNode* instanceParent = m_pModel->NodeFromIndex( parentIndex );
    if( !instanceParent->GetNode() ) gf::SevereError( "CmdInsertAnalyzerKit called with NULL parent node." );
    m_coinParent = static_cast< SoBaseKit* > ( instanceParent->GetNode() );

}
/*!
 * Returns true if the \a m_nodetypeList contains the type of the element defined with \a sourceRow and \a sourceParent
 */
bool NodesFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{

	SceneModel* sceneModel = dynamic_cast< SceneModel* > ( sourceModel() );
	QModelIndex index = sceneModel->index(sourceRow, 0, sourceParent);

	InstanceNode* nodeInstance = sceneModel->NodeFromIndex( index );
	if( !nodeInstance )		return false;

	SoNode* node = nodeInstance->GetNode();
	if( !node )		return false;


	if( node->getTypeId().isDerivedFrom( TSeparatorKit::getClassTypeId() ) )	return ( true );
	if( node->getTypeId().isDerivedFrom( TShapeKit::getClassTypeId() ) )
	{
		if( m_shapeTypeList.count() < 1 )	return ( true );

		TShapeKit* shapeKit = static_cast< TShapeKit* >( node );
		if(!shapeKit)	return ( false );
		TShape* shape = static_cast< TShape* >( shapeKit->getPart( "shape", false ) );

		if( shape  &&  m_shapeTypeList.contains( shape->getTypeId().getName().getString() ) )
			return ( true );
	}


	return ( false );
}
/**
 * Creates a new group node insert command that adds a \a separatorKit to \a parentIndex node in the \a model.
 *
 * If \a parent is not null, this command is appended to parent's child list and then owns this command.
 */
CmdInsertSeparatorKit::CmdInsertSeparatorKit( TSeparatorKit* separatorKit,  const QModelIndex& parentIndex, SceneModel* model, QUndoCommand* parent )
: QUndoCommand("InsertSeparatorKit", parent), m_separatorKit ( separatorKit ), m_coinParent( 0 ), m_pModel( model ), m_row( -1 )
{
	if( !m_separatorKit ) gf::SevereError( "CmdInsertSeparatorKit Null separatorKit." );
	m_separatorKit->ref();

	if( !parentIndex.isValid() ) gf::SevereError( "CmdInsertSeparatorKit called with invalid ModelIndex." );
	InstanceNode* instanceParent = m_pModel->NodeFromIndex( parentIndex );
	m_coinParent = static_cast< SoBaseKit* > ( instanceParent->GetNode() );
}
Exemple #5
0
/**
 * Creates a new cut command that represents the cut the node located with \a index from the \a model.
 * The node is stored at the \a clipborad.
 *
 * If \a parent is not null, this command is appended to parent's child list and then owns this command.
 */
CmdCut::CmdCut( const QModelIndex& selectedIndex, SoNode*& clipboard, SceneModel* model, QUndoCommand* parent )
: QUndoCommand("Cut", parent), m_pClipboard ( clipboard ), m_previousNode ( 0 ), m_coinNode( 0 ), m_coinParent( 0 ), m_pModel( model ), m_row ( -1 )
{
	InstanceNode* instanceNode = m_pModel->NodeFromIndex( selectedIndex );
	m_coinNode = instanceNode->GetNode();
	m_coinNode->ref();
	m_coinParent = static_cast< SoBaseKit* > (instanceNode->GetParent()->GetNode() );

	m_previousNode = clipboard ;

	m_row = instanceNode->GetParent()->children.indexOf( instanceNode );
}
Exemple #6
0
/*
 * Returns the type of the surface
 */
QString FluxAnalysis::GetSurfaceType( QString nodeURL )
{
	QModelIndex nodeIndex = m_pCurrentSceneModel->IndexFromNodeUrl( nodeURL );
	if( !nodeIndex.isValid()  )		return QLatin1String( "" );

	InstanceNode* instanceNode = m_pCurrentSceneModel->NodeFromIndex( nodeIndex );
	if( !instanceNode || instanceNode == 0 )	return QLatin1String( "" );

	TShapeKit* shapeKit = static_cast< TShapeKit* > ( instanceNode->GetNode() );
	if( !shapeKit || shapeKit == 0 )	return QLatin1String( "" );

	TShape* shape = static_cast< TShape* >( shapeKit->getPart( "shape", false ) );
	if( !shape || shape == 0 )	return QLatin1String( "" );

	return ( shape->getTypeId().getName().getString() );
}