#include <QGraphicsSceneMoveEvent>\r
#include <QGraphicsSceneResizeEvent>\r
#include <QGraphicsSceneWheelEvent>\r
+#include <QInputDialog>\r
\r
#include "QNEPort.h"\r
#include "QNEConnection.h"\r
{\r
this->_CreateBlock(\r
dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ),\r
- QPointF( )\r
+ QPointF( vIt->second->GetViewX( ), vIt->second->GetViewY( ) )\r
);\r
\r
} // rof\r
return( "" );\r
}\r
\r
+// -------------------------------------------------------------------------\r
+void PipelineEditor::QNodesEditor::\r
+synchronizeBlockPositions( )\r
+{\r
+ auto bIt = this->m_Graph->BeginVertices( );\r
+ auto fIt = this->m_Workspace->GetGraph( )->BeginVertices( );\r
+ while(\r
+ bIt != this->m_Graph->EndVertices( ) &&\r
+ fIt != this->m_Workspace->GetGraph( )->EndVertices( )\r
+ )\r
+ {\r
+ auto pos = bIt->second->scenePos( );\r
+ fIt->second->SetViewCoords( pos.x( ), pos.y( ) );\r
+ bIt++;\r
+ fIt++;\r
+\r
+ } // elihw\r
+}\r
+\r
// -------------------------------------------------------------------------\r
void PipelineEditor::QNodesEditor::\r
install( QGraphicsScene* s )\r
QNEBlock* b = new QNEBlock( 0, this->m_Scene );\r
b->setNamePort( f->GetName( ) );\r
b->setTypePort( f->GetClassName( ) );\r
- // TODO: b->setScenePos( pnt );\r
+ b->setPos( pnt );\r
\r
// Add input ports\r
std::set< std::string > inputs;\r
\r
if( block != NULL )\r
{\r
+ QString old_name = block->namePort( )->name( );\r
+ bool ok;\r
+ QString new_name =\r
+ QInputDialog::getText(\r
+ dynamic_cast< QWidget* >( this->parent( ) ),\r
+ "Change filter name",\r
+ "Filter name:",\r
+ QLineEdit::Normal,\r
+ old_name,\r
+ &ok\r
+ );\r
+ if( ok && !new_name.isEmpty( ) && old_name != new_name )\r
+ {\r
+ ok = this->m_Graph->RenameVertex(\r
+ old_name.toStdString( ),\r
+ new_name.toStdString( )\r
+ );\r
+ if( ok )\r
+ {\r
+ block->namePort( )->setName( new_name );\r
+ this->m_Workspace->GetGraph( )->RenameVertex(\r
+ old_name.toStdString( ),\r
+ new_name.toStdString( )\r
+ );\r
+\r
+ } // fi\r
+\r
+ } // fi\r
+\r
/* TODO\r
auto ports = block->ports( );\r
std::string name = "";\r
const std::string& filter,\r
const QPointF& pnt = QPointF( )\r
);\r
+ void synchronizeBlockPositions( );\r
\r
void install( QGraphicsScene* s );\r
bool eventFilter( QObject* o, QEvent* e );\r
return;
std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
+ this->m_UI->Canvas->editor( )->synchronizeBlockPositions( );
std::string err = this->m_Workspace->SaveWorkspace( fname );
if( err != "" )
QMessageBox::critical(
for( ; rIt != mIt->second.end( ); ++rIt )
{
if( mIt->first == old_index )
- this->m_Matrix[ new_index ][ rIt->first ].push_back( rIt->second );
+ this->m_Matrix[ new_index ][ rIt->first ] = rIt->second;
else if( rIt->first == old_index )
- this->m_Matrix[ mIt->first ][ new_index ].push_back( rIt->second );
+ this->m_Matrix[ mIt->first ][ new_index ] = rIt->second;
} // rof
return( false );
}
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Workspace::
+Connect( const std::string& i, const std::string& o )
+{
+ auto ii = this->m_InputPorts.find( i );
+ auto oi = this->m_OutputPorts.find( o );
+ if( ii != this->m_InputPorts.end( ) && oi != this->m_OutputPorts.end( ) )
+ return(
+ this->Connect(
+ oi->second.first,
+ ii->second.first,
+ oi->second.second,
+ ii->second.second
+ )
+ );
+ else
+ return( false );
+}
+
// -------------------------------------------------------------------------
cpPlugins::Interface::Workspace::
TParameters* cpPlugins::Interface::Workspace::
return( false );
}
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+AddInputPort(
+ const std::string& name,
+ const std::string& filter, const std::string& filter_input
+ )
+{
+ this->m_InputPorts[ name ] = TGlobalPort( filter, filter_input );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+AddOutputPort(
+ const std::string& name,
+ const std::string& filter, const std::string& filter_output
+ )
+{
+ this->m_OutputPorts[ name ] = TGlobalPort( filter, filter_output );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+ClearInputPorts( )
+{
+ this->m_InputPorts.clear( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Workspace::
+ClearOutputPorts( )
+{
+ this->m_OutputPorts.clear( );
+}
+
// -------------------------------------------------------------------------
std::string cpPlugins::Interface::Workspace::
Execute( )
typedef TFilter::TParameters TParameters;
// Various types
- typedef std::set< std::string > TStringContainer;
+ typedef std::set< std::string > TStringContainer;
+ typedef std::pair< std::string, std::string > TGlobalPort;
+ typedef std::map< std::string, TGlobalPort > TGlobalPorts;
// Graph type
typedef std::pair< std::string, std::string > TConnection;
const std::string& output_name,
const std::string& input_name
);
+ bool Connect( const std::string& i, const std::string& o );
TParameters* GetParameters( const std::string& name );
const TParameters* GetParameters( const std::string& name ) const;
TFilter* GetFilter( const std::string& name );
// Graph reduction
bool Reduce( const std::string& name );
+ void AddInputPort(
+ const std::string& name,
+ const std::string& filter, const std::string& filter_input
+ );
+ void AddOutputPort(
+ const std::string& name,
+ const std::string& filter, const std::string& filter_output
+ );
+ void ClearInputPorts( );
+ void ClearOutputPorts( );
// Pipeline execution
std::string Execute( );
// Processing graph
typename TGraph::Pointer m_Graph;
+ TGlobalPorts m_InputPorts;
+ TGlobalPorts m_OutputPorts;
};
} // ecapseman