Exemplo n.º 1
0
//!	Toggle group playback
void
RouteWindow::_toggleGroupRolling()
{
	if (!m_selectedGroupID)
		return;

	NodeGroup* g;
	status_t err = m_routingView->manager->findGroup(m_selectedGroupID, &g);
	if (err < B_OK)
		return;

	Autolock _l(g);
	uint32 startAction = (g->runMode() == BMediaNode::B_OFFLINE)
		? NodeGroup::M_ROLL : NodeGroup::M_START;

	BMessenger m(g);
	switch (g->transportState()) {
		case NodeGroup::TRANSPORT_STOPPED:
			m.SendMessage(startAction);
			break;

		case NodeGroup::TRANSPORT_RUNNING:
		case NodeGroup::TRANSPORT_ROLLING:
			m.SendMessage(NodeGroup::M_STOP);
			break;

		default:
			break;
	}
}
Exemplo n.º 2
0
LinkToKnobDialog::LinkToKnobDialog(const KnobGuiPtr& from,
                                   QWidget* parent)
    : QDialog(parent)
    , _imp( new LinkToKnobDialogPrivate(from) )
{
    _imp->mainLayout = new QVBoxLayout(this);

    _imp->firstLine = new QWidget(this);
    _imp->firstLineLayout = new QHBoxLayout(_imp->firstLine);

    _imp->mainLayout->addWidget(_imp->firstLine);

    _imp->buttons = new QDialogButtonBox(QDialogButtonBox::StandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel),
                                         Qt::Horizontal, this);
    QObject::connect( _imp->buttons, SIGNAL(accepted()), this, SLOT(accept()) );
    QObject::connect( _imp->buttons, SIGNAL(rejected()), this, SLOT(reject()) );
    _imp->mainLayout->addWidget(_imp->buttons);

    _imp->selectNodeLabel = new Label(tr("Parent:"), _imp->firstLine);
    _imp->firstLineLayout->addWidget(_imp->selectNodeLabel);


    EffectInstance* isEffect = dynamic_cast<EffectInstance*>( from->getKnob()->getHolder() );
    assert(isEffect);
    if (!isEffect) {
        throw std::logic_error("");
    }
    boost::shared_ptr<NodeCollection> group = isEffect->getNode()->getGroup();
    group->getActiveNodes(&_imp->allNodes);
    NodeGroup* isGroup = dynamic_cast<NodeGroup*>( group.get() );
    if (isGroup) {
        _imp->allNodes.push_back( isGroup->getNode() );
    }
    QStringList nodeNames;
    for (NodesList::iterator it = _imp->allNodes.begin(); it != _imp->allNodes.end(); ++it) {
        QString name = QString::fromUtf8( (*it)->getLabel().c_str() );
        nodeNames.push_back(name);
        //_imp->nodeSelectionCombo->addItem(name);
    }
    nodeNames.sort();
    _imp->nodeSelectionCombo = new CompleterLineEdit(nodeNames, nodeNames, false, this);
    _imp->nodeSelectionCombo->setToolTip( GuiUtils::convertFromPlainText(tr("Input the name of a node in the current project."), Qt::WhiteSpaceNormal) );
    _imp->firstLineLayout->addWidget(_imp->nodeSelectionCombo);


    _imp->nodeSelectionCombo->setFocus(Qt::PopupFocusReason);
    QTimer::singleShot( 25, _imp->nodeSelectionCombo, SLOT(showCompleter()) );

    _imp->knobSelectionCombo = new ComboBox(_imp->firstLine);
    _imp->firstLineLayout->addWidget(_imp->knobSelectionCombo);

    QObject::connect( _imp->nodeSelectionCombo, SIGNAL(itemCompletionChosen()), this, SLOT(onNodeComboEditingFinished()) );

    _imp->firstLineLayout->addStretch();
}
Exemplo n.º 3
0
NodeGroup *StrokeTesselator::Tesselate(StrokeVertexIterator begin, StrokeVertexIterator end)
{
  NodeGroup *group = new NodeGroup;
  NodeShape *tshape = new NodeShape;
  group->AddChild(tshape);
  // tshape->material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
  tshape->setFrsMaterial(_FrsMaterial);

  for (StrokeVertexIterator c = begin, cend = end; c != cend; c++) {
    tshape->AddRep(Tesselate((*c)));
  }

  return group;
}
Exemplo n.º 4
0
void
GuiAppInstance::onGroupCreationFinished(const NodePtr& node,
                                        CreateNodeReason reason)
{
    if (reason == eCreateNodeReasonUserCreate) {
        NodeGraph* graph = 0;
        boost::shared_ptr<NodeCollection> collection = node->getGroup();
        assert(collection);
        NodeGroup* isGrp = dynamic_cast<NodeGroup*>( collection.get() );
        if (isGrp) {
            NodeGraphI* graph_i = isGrp->getNodeGraph();
            assert(graph_i);
            graph = dynamic_cast<NodeGraph*>(graph_i);
        } else {
            graph = _imp->_gui->getNodeGraph();
        }
        assert(graph);
        if (!graph) {
            throw std::logic_error("");
        }
        NodesGuiList selectedNodes = graph->getSelectedNodes();
        NodeGuiPtr selectedNode;
        if ( !selectedNodes.empty() ) {
            selectedNode = selectedNodes.front();
            if ( dynamic_cast<BackdropGui*>( selectedNode.get() ) ) {
                selectedNode.reset();
            }
        }
        boost::shared_ptr<NodeGuiI> node_gui_i = node->getNodeGui();
        assert(node_gui_i);
        NodeGuiPtr nodeGui = boost::dynamic_pointer_cast<NodeGui>(node_gui_i);
        graph->moveNodesForIdealPosition(nodeGui, selectedNode, true);
    }

    AppInstance::onGroupCreationFinished(node, reason);

    /*std::list<ViewerInstance* > viewers;
       node->hasViewersConnected(&viewers);
       for (std::list<ViewerInstance* >::iterator it2 = viewers.begin(); it2 != viewers.end(); ++it2) {
        (*it2)->renderCurrentFrame(false);
       }*/
}
Exemplo n.º 5
0
void CircuitICNDocument::slotAssignNodeGroups()
{
	ICNDocument::slotAssignNodeGroups();

	const ECNodeMap::iterator end = m_ecNodeList.end();
	for ( ECNodeMap::iterator it = m_ecNodeList.begin(); it != end; ++it )
	{
		NodeGroup *ng = createNodeGroup ( *it );
		if ( ng ) ng->init();
	}

	// We've destroyed the old node groups, so any collapsed flowcontainers
	// containing new node groups need to update them to make them invisible.
	const ItemMap::const_iterator itemListEnd = m_itemList.end();
	for ( ItemMap::const_iterator it = m_itemList.begin(); it != itemListEnd; ++it )
	{
		if ( FlowContainer * fc = dynamic_cast<FlowContainer*> ( *it ) )
			fc->updateContainedVisibility();
	}
}
Exemplo n.º 6
0
void PrintMarksComponent::EndImportCustomPrintMark(CamelotRecordHandler *pHandler)
{
	PORTNOTETRACE("print","PrintMarksComponent::EndImportCustomPrintMark - do nothing");
#ifndef EXCLUDE_FROM_XARALX
	ERROR3IF(CustomCurrentContext == NULL || pNewMark == NULL, "EndImportCustomPrintMark - StartImportCustomMark not called/failed");

	// Find the Print mark manager and it's PrintMark cache
	PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager();
	if (pMarksMan == NULL)
		return;

	// Restore the previous import context node
	pHandler->SetInsertContextNode(CustomPreviousContext);

	// Complete the mark and add it to the PMM cache
	NodeGroup *Glyph = (NodeGroup *)CustomCurrentContext->FindFirstChild();
	ERROR3IF(Glyph == NULL, "Import of custom mark subtree must have failed");
	if (Glyph != NULL)
	{
		ERROR3IF(!Glyph->IsKindOf(CC_RUNTIME_CLASS(NodeGroup)), "Imported print mark doesn't start with a group");

		Glyph->UnlinkNodeFromTree(NULL);
		UINT32 MarkHandle = pMarksMan->PMMCache.AddNewMark(pNewMark, Glyph);

		// Add a reference to the mark to ourself, so the mark is enabled
		AddMark(MarkHandle);
	}
	else
	{
		// Try not to leak too much!
		delete pNewMark;
	}

	// Tidy up
	pNewMark = NULL;
	CustomPreviousContext = NULL;
	delete CustomCurrentContext;
	CustomCurrentContext = NULL;
#endif
}
Exemplo n.º 7
0
void RouteAppNodeManager::nodeCreated(
	NodeRef*											ref) {

	// prepare the log message
	BMessage logMsg(M_LOG);
	BString title = "Node '";
	title << ref->name() << "' created";
	logMsg.AddString("title", title);

	// create a default group for the node
	// [em 8feb00]
	NodeGroup* g = createGroup(ref->name());

	if(ref->kind() & B_TIME_SOURCE) {
		// notify observers
		BMessage m(M_TIME_SOURCE_CREATED);
		m.AddInt32("nodeID", ref->id());
		notify(&m);
	}

	// adopt node's time source if it's not the system clock (the default)
	// [em 20mar00]
	media_node systemClock;
	status_t err = roster->GetSystemTimeSource(&systemClock);
	if(err == B_OK)
	{
		BTimeSource* ts = roster->MakeTimeSourceFor(ref->node());
		if(ts->Node() != systemClock)
		{
			g->setTimeSource(ts->Node());
			logMsg.AddString("line", "Synced to system clock");
		}
		ts->Release();
	}

	g->addNode(ref);

	m_logTarget.SendMessage(&logMsg);
}
Exemplo n.º 8
0
void MediaRoutingView::_initContent()
{
	D_METHOD(("MediaRoutingView::_initContent()\n"));

	Autolock lock(manager);

	void *cookie = 0;
	NodeRef *ref;
	while (manager->getNextRef(&ref, &cookie) == B_OK)
	{
		// add self as observer
		add_observer(this, ref);
		// create & place node view (+++++ defer until observer status confirmed!)
		_addPanelFor(ref->id(), BPoint(M_CLEANUP_H_MARGIN, M_CLEANUP_V_MARGIN));
	}
	cookie = 0;
	Connection connection;
	while (manager->getNextConnection(&connection, &cookie) == B_OK)
	{
		_addWireFor(connection);
	}

	// create default groups
	NodeGroup* group;
	NodeRef* videoIn = manager->videoInputNode();
	if (videoIn)
	{
		group = manager->createGroup("Video Input");
		group->setRunMode(BMediaNode::B_RECORDING);
		group->addNode(videoIn);
	}
	NodeRef* audioIn = manager->audioInputNode();
	if (audioIn)
	{
		group = manager->createGroup("Audio Input");
		group->setRunMode(BMediaNode::B_RECORDING);
		group->addNode(audioIn);
	}
	NodeRef* videoOut = manager->videoOutputNode();
	if (videoOut)
	{
		group = manager->createGroup("Video Output");
		group->addNode(videoOut);
	}
}
Exemplo n.º 9
0
void
GuiAppInstance::createNodeGui(const NodePtr &node,
                              const NodePtr& parentMultiInstance,
                              const CreateNodeArgs& args)
{
    boost::shared_ptr<NodeCollection> group = node->getGroup();
    NodeGraph* graph;

    if (group) {
        NodeGraphI* graph_i = group->getNodeGraph();
        assert(graph_i);
        graph = dynamic_cast<NodeGraph*>(graph_i);
        assert(graph);
    } else {
        graph = _imp->_gui->getNodeGraph();
    }
    if (!graph) {
        throw std::logic_error("");
    }

    NodesGuiList selectedNodes = graph->getSelectedNodes();
    NodeGuiPtr nodegui = _imp->_gui->createNodeGUI(node, args);

    assert(nodegui);
    if (parentMultiInstance && nodegui) {
        nodegui->hideGui();


        boost::shared_ptr<NodeGuiI> parentNodeGui_i = parentMultiInstance->getNodeGui();
        assert(parentNodeGui_i);
        nodegui->setParentMultiInstance( boost::dynamic_pointer_cast<NodeGui>(parentNodeGui_i) );
    }

    ///It needs to be here because we rely on the _nodeMapping member
    bool isViewer = node->isEffectViewer() != 0;
    if (isViewer) {
        _imp->_gui->createViewerGui(node);
    }

    ///must be done after the viewer gui has been created
    if ( node->isRotoPaintingNode() ) {
        _imp->_gui->createNewRotoInterface( nodegui.get() );
    }

    if ( ( node->isTrackerNodePlugin() || node->getEffectInstance()->isBuiltinTrackerNode() ) && !parentMultiInstance ) {
        _imp->_gui->createNewTrackerInterface( nodegui.get() );
    }

    NodeGroup* isGroup = node->isEffectGroup();
    if ( isGroup && isGroup->isSubGraphUserVisible() ) {
        _imp->_gui->createGroupGui(node, args.reason);
    }

    ///Don't initialize inputs if it is a multi-instance child since it is not part of  the graph
    if (!parentMultiInstance) {
        nodegui->initializeInputs();
    }

    if ( (args.reason == eCreateNodeReasonUserCreate) && !isViewer ) {
        ///we make sure we can have a clean preview.
        node->computePreviewImage( getTimeLine()->currentFrame() );
        triggerAutoSave();
    }


    ///only move main instances
    if ( node->getParentMultiInstanceName().empty() ) {
        bool autoConnect = args.reason == eCreateNodeReasonUserCreate;

        if ( selectedNodes.empty() ) {
            autoConnect = false;
        }
        if ( (args.xPosHint != INT_MIN) && (args.yPosHint != INT_MIN) && (!autoConnect) ) {
            QPointF pos = nodegui->mapToParent( nodegui->mapFromScene( QPointF(args.xPosHint, args.yPosHint) ) );
            nodegui->refreshPosition( pos.x(), pos.y(), true );
        } else {
            BackdropGui* isBd = dynamic_cast<BackdropGui*>( nodegui.get() );
            if (!isBd) {
                NodeGuiPtr selectedNode;
                if ( (args.reason == eCreateNodeReasonUserCreate) && (selectedNodes.size() == 1) ) {
                    selectedNode = selectedNodes.front();
                    BackdropGui* isBackdropGui = dynamic_cast<BackdropGui*>( selectedNode.get() );
                    if (isBackdropGui) {
                        selectedNode.reset();
                    }
                }
                nodegui->getDagGui()->moveNodesForIdealPosition(nodegui, selectedNode, autoConnect);
            }
        }
    }
} // createNodeGui
Exemplo n.º 10
0
PickKnobDialog::PickKnobDialog(DockablePanel* panel,
                               QWidget* parent)
    : QDialog(parent)
    , _imp( new PickKnobDialogPrivate(panel) )
{
    NodeSettingsPanel* nodePanel = dynamic_cast<NodeSettingsPanel*>(panel);

    assert(nodePanel);
    if (!nodePanel) {
        throw std::logic_error("PickKnobDialog::PickKnobDialog()");
    }
    NodeGuiPtr nodeGui = nodePanel->getNode();
    NodePtr node = nodeGui->getNode();
    NodeGroup* isGroup = node->isEffectGroup();
    boost::shared_ptr<NodeCollection> collec = node->getGroup();
    NodeGroup* isCollecGroup = dynamic_cast<NodeGroup*>( collec.get() );
    NodesList collectNodes = collec->getNodes();
    for (NodesList::iterator it = collectNodes.begin(); it != collectNodes.end(); ++it) {
        if ( !(*it)->getParentMultiInstance() && (*it)->isActivated() && ( (*it)->getKnobs().size() > 0 ) ) {
            _imp->allNodes.push_back(*it);
        }
    }
    if (isCollecGroup) {
        _imp->allNodes.push_back( isCollecGroup->getNode() );
    }
    if (isGroup) {
        NodesList groupnodes = isGroup->getNodes();
        for (NodesList::iterator it = groupnodes.begin(); it != groupnodes.end(); ++it) {
            if ( !(*it)->getParentMultiInstance() && (*it)->isActivated() && ( (*it)->getKnobs().size() > 0 ) ) {
                _imp->allNodes.push_back(*it);
            }
        }
    }
    QStringList nodeNames;
    for (NodesList::iterator it = _imp->allNodes.begin(); it != _imp->allNodes.end(); ++it) {
        QString name = QString::fromUtf8( (*it)->getLabel().c_str() );
        nodeNames.push_back(name);
    }
    nodeNames.sort();

    _imp->mainLayout = new QGridLayout(this);
    _imp->selectNodeLabel = new Label( tr("Node:") );
    _imp->nodeSelectionCombo = new CompleterLineEdit(nodeNames, nodeNames, false, this);
    _imp->nodeSelectionCombo->setToolTip( GuiUtils::convertFromPlainText(tr("Input the name of a node in the current project."), Qt::WhiteSpaceNormal) );
    _imp->nodeSelectionCombo->setFocus(Qt::PopupFocusReason);

    _imp->knobSelectionCombo = new ComboBox(this);
    QObject::connect( _imp->knobSelectionCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onKnobComboIndexChanged(int)) );
    QString useAliasTt = GuiUtils::convertFromPlainText(tr("If checked, an alias of the selected parameter will be created, coyping entirely its state. "
                                                           "Only the script-name, label and tooltip will be editable.\n"
                                                           "For choice parameters this will also "
                                                           "dynamically refresh the menu entries when the original parameter's menu is changed.\n"
                                                           "When unchecked, a simple expression will be set linking the two parameters, but things such as dynamic menus "
                                                           "will be disabled."), Qt::WhiteSpaceNormal);
    _imp->useAliasLabel = new Label(tr("Make Alias:"), this);
    _imp->useAliasLabel->setToolTip(useAliasTt);
    _imp->useAliasCheckBox = new QCheckBox(this);
    _imp->useAliasCheckBox->setToolTip(useAliasTt);
    _imp->useAliasCheckBox->setChecked(true);

    QObject::connect( _imp->nodeSelectionCombo, SIGNAL(itemCompletionChosen()), this, SLOT(onNodeComboEditingFinished()) );

    _imp->destPageLabel = new Label(tr("Page:"), this);
    QString pagett = GuiUtils::convertFromPlainText(tr("Select the page into which the parameter will be created."), Qt::WhiteSpaceNormal);
    _imp->destPageLabel->setToolTip(pagett);
    _imp->destPageCombo = new ComboBox(this);
    _imp->destPageCombo->setToolTip(pagett);
    QObject::connect( _imp->destPageCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onPageComboIndexChanged(int)) );
    const KnobsVec& knobs = node->getKnobs();
    for (std::size_t i = 0; i < knobs.size(); ++i) {
        if ( knobs[i]->isUserKnob() ) {
            boost::shared_ptr<KnobPage> isPage = boost::dynamic_pointer_cast<KnobPage>(knobs[i]);
            if (isPage) {
                _imp->pages.push_back(isPage);
                _imp->destPageCombo->addItem( QString::fromUtf8( isPage->getName().c_str() ) );
            } else {
                boost::shared_ptr<KnobGroup> isGrp = boost::dynamic_pointer_cast<KnobGroup>(knobs[i]);
                if (isGrp) {
                    _imp->groups.push_back(isGrp);
                }
            }
        }
    }
    if (_imp->destPageCombo->count() == 0) {
        _imp->destPageLabel->hide();
        _imp->destPageCombo->hide();
    }


    _imp->groupLabel = new Label(tr("Group:"), this);
    QString grouptt = GuiUtils::convertFromPlainText(tr("Select the group into which the parameter will be created."), Qt::WhiteSpaceNormal);
    _imp->groupCombo = new ComboBox(this);
    _imp->groupLabel->setToolTip(grouptt);
    _imp->groupCombo->setToolTip(grouptt);
    onPageComboIndexChanged(0);

    _imp->buttons = new QDialogButtonBox(QDialogButtonBox::StandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel),
                                         Qt::Horizontal, this);
    QObject::connect( _imp->buttons, SIGNAL(accepted()), this, SLOT(accept()) );
    QObject::connect( _imp->buttons, SIGNAL(rejected()), this, SLOT(reject()) );

    _imp->mainLayout->addWidget(_imp->selectNodeLabel, 0, 0, 1, 1);
    _imp->mainLayout->addWidget(_imp->nodeSelectionCombo, 0, 1, 1, 1);
    _imp->mainLayout->addWidget(_imp->knobSelectionCombo, 0, 2, 1, 1);
    _imp->mainLayout->addWidget(_imp->useAliasLabel, 1, 0, 1, 1);
    _imp->mainLayout->addWidget(_imp->useAliasCheckBox, 1, 1, 1, 1);
    _imp->mainLayout->addWidget(_imp->destPageLabel, 2, 0, 1, 1);
    _imp->mainLayout->addWidget(_imp->destPageCombo, 2, 1, 1, 1);
    _imp->mainLayout->addWidget(_imp->groupLabel, 2, 2, 1, 1);
    _imp->mainLayout->addWidget(_imp->groupCombo, 2, 3, 1, 1);
    _imp->mainLayout->addWidget(_imp->buttons, 3, 0, 1, 3);

    QTimer::singleShot( 25, _imp->nodeSelectionCombo, SLOT(showCompleter()) );
}
Exemplo n.º 11
0
int Controller::LoadMesh(Render *re, SceneRenderLayer *srl)
{
	BlenderFileLoader loader(re, srl);

	loader.setRenderMonitor(_pRenderMonitor);

	_Chrono.start();

	NodeGroup *blenderScene = loader.Load();

	if (blenderScene == NULL) {
		if (G.debug & G_DEBUG_FREESTYLE) {
			cout << "Cannot load scene" << endl;
		}
		return 1;
	}

	if (blenderScene->numberOfChildren() < 1) {
		if (G.debug & G_DEBUG_FREESTYLE) {
			cout << "Empty scene" << endl;
		}
		blenderScene->destroy();
		delete blenderScene;
		return 1;
	}

	real duration = _Chrono.stop();
	if (G.debug & G_DEBUG_FREESTYLE) {
		cout << "Scene loaded" << endl;
		printf("Mesh cleaning    : %lf\n", duration);
		printf("View map cache   : %s\n", _EnableViewMapCache ? "enabled" : "disabled");
	}
	_SceneNumFaces += loader.numFacesRead();

#if 0
	if (loader.minEdgeSize() < _minEdgeSize) {
		_minEdgeSize = loader.minEdgeSize();
	}
#endif

#if 0  // DEBUG
	ScenePrettyPrinter spp;
	blenderScene->accept(spp);
#endif

	_RootNode->AddChild(blenderScene);
	_RootNode->UpdateBBox(); // FIXME: Correct that by making a Renderer to compute the bbox

	_pView->setModel(_RootNode);
	//_pView->FitBBox();

	if (_pRenderMonitor->testBreak())
		return 0;

	if (_EnableViewMapCache) {

		NodeCamera *cam;
		if (g_freestyle.proj[3][3] != 0.0)
			cam = new NodeOrthographicCamera;
		else
			cam = new NodePerspectiveCamera;
		double proj[16];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				proj[i * 4 + j] = g_freestyle.proj[i][j];
			}
		}
		cam->setProjectionMatrix(proj);
		_RootNode->AddChild(cam);
		_RootNode->AddChild(new NodeSceneRenderLayer(*re->scene, *srl));

		sceneHashFunc.reset();
		//blenderScene->accept(sceneHashFunc);
		_RootNode->accept(sceneHashFunc);
		if (G.debug & G_DEBUG_FREESTYLE) {
			cout << "Scene hash       : " << sceneHashFunc.toString() << endl;
		}
		if (hitViewMapCache()) {
			ClearRootNode();
			return 0;
		}
		else {
			delete _ViewMap;
			_ViewMap = NULL;
		}
	}

	_Chrono.start();

	WXEdgeBuilder wx_builder;
	wx_builder.setRenderMonitor(_pRenderMonitor);
	blenderScene->accept(wx_builder);
	_winged_edge = wx_builder.getWingedEdge();

	duration = _Chrono.stop();
	if (G.debug & G_DEBUG_FREESTYLE) {
		printf("WEdge building   : %lf\n", duration);
	}

#if 0
	_pView->setDebug(_DebugNode);

	// delete stuff
	if (0 != ws_builder) {
		delete ws_builder;
		ws_builder = 0;
	}

	soc QFileInfo qfi(iFileName);
	soc string basename((const char*)qfi.fileName().toAscii().data());
	char cleaned[FILE_MAX];
	BLI_strncpy(cleaned, iFileName, FILE_MAX);
	BLI_cleanup_file(NULL, cleaned);
	string basename = string(cleaned);
#endif

	_ListOfModels.push_back("Blender_models");

	_Scene3dBBox = _RootNode->bbox();

	_bboxDiag = (_RootNode->bbox().getMax() - _RootNode->bbox().getMin()).norm();
	if (G.debug & G_DEBUG_FREESTYLE) {
		cout << "Triangles nb     : " << _SceneNumFaces << " imported, " <<
		        _winged_edge->getNumFaces() << " retained" << endl;
		cout << "Bounding Box     : " << _bboxDiag << endl;
	}

	ClearRootNode();

	_SceneNumFaces = _winged_edge->getNumFaces();
	if (_SceneNumFaces == 0) {
		DeleteWingedEdge();
		return 1;
	}

	return 0;
}
Exemplo n.º 12
0
void
NodeGraph::mouseMoveEvent(QMouseEvent* e)
{
    QPointF newPos = mapToScene( e->pos() );
    QPointF lastMousePosScene = mapToScene( _imp->_lastMousePos.x(), _imp->_lastMousePos.y() );
    double dx, dy;
    {
        QPointF newPosRoot = _imp->_root->mapFromScene(newPos);
        QPointF lastMousePosRoot = _imp->_root->mapFromScene(lastMousePosScene);
        dx = newPosRoot.x() - lastMousePosRoot.x();
        dy = newPosRoot.y() - lastMousePosRoot.y();
    }

    _imp->_hasMovedOnce = true;

    bool mustUpdate = true;
    boost::shared_ptr<NodeCollection> collection = getGroup();
    NodeGroup* isGroup = dynamic_cast<NodeGroup*>( collection.get() );
    bool isGroupEditable = true;
    bool groupEdited = true;
    if (isGroup) {
        isGroupEditable = isGroup->isSubGraphEditable();
        groupEdited = isGroup->getNode()->hasPyPlugBeenEdited();
    }
    if (!groupEdited && isGroupEditable) {
        ///check if user is nearby unlock
        int iw = _imp->unlockIcon.width();
        int ih = _imp->unlockIcon.height();
        int w = width();
        if ( ( e->x() >= (w - iw - 10 - 15) ) && ( e->x() <= (w - 10 + 15) ) &&
                ( e->y() >= (10 - 15) ) && ( e->y() <= (10 + ih + 15) ) ) {
            assert(isGroup);
            QPoint pos = mapToGlobal( e->pos() );
            QToolTip::showText( pos, GuiUtils::convertFromPlainText(QCoreApplication::translate("NodeGraph", "Clicking the unlock button will convert the PyPlug to a regular group saved in the project and dettach it from the script.\n"
                                "Any modification will not be written to the Python script. Subsequent loading of the project will no longer load this group from the python script."), Qt::WhiteSpaceNormal) );
        }
    }

    QRectF sceneR = visibleSceneRect();
    if ( groupEdited && (_imp->_evtState != eEventStateSelectionRect) && (_imp->_evtState != eEventStateDraggingArrow) ) {
        // Set cursor

        std::set<NodeGui*> visibleNodes;
        getNodesWithinViewportRect(visibleWidgetRect(), &visibleNodes);

        NodeGuiPtr selected;
        Edge* selectedEdge = 0;
        bool optionalInputsAutoHidden = areOptionalInputsAutoHidden();

        for (std::set<NodeGui*>::iterator it = visibleNodes.begin(); it != visibleNodes.end(); ++it) {
            QPointF evpt = (*it)->mapFromScene(newPos);
            QRectF bbox = (*it)->mapToScene( (*it)->boundingRect() ).boundingRect();
            if ( (*it)->isActive() && bbox.intersects(sceneR) ) {
                if ( (*it)->contains(evpt) ) {
                    selected = (*it)->shared_from_this();
                    if (optionalInputsAutoHidden) {
                        (*it)->refreshEdgesVisility(true);
                    } else {
                        break;
                    }
                } else {
                    Edge* edge = (*it)->hasEdgeNearbyPoint(newPos);
                    if (edge) {
                        selectedEdge = edge;
                        if (!optionalInputsAutoHidden) {
                            break;
                        }
                    } else if ( optionalInputsAutoHidden && !(*it)->getIsSelected() ) {
                        (*it)->refreshEdgesVisility(false);
                    }
                }
            }
        }
        if (selected) {
            _imp->cursorSet = true;
            setCursor( QCursor(Qt::OpenHandCursor) );
        } else if (selectedEdge) {
        } else if (!selectedEdge && !selected) {
            if (_imp->cursorSet) {
                _imp->cursorSet = false;
                unsetCursor();
            }
        }
    }

    bool mustUpdateNavigator = false;
    ///Apply actions
    switch (_imp->_evtState) {
    case eEventStateDraggingArrow: {
        QPointF np = _imp->_arrowSelected->mapFromScene(newPos);
        if ( _imp->_arrowSelected->isOutputEdge() ) {
            _imp->_arrowSelected->dragDest(np);
        } else {
            _imp->_arrowSelected->dragSource(np);
        }
        checkAndStartAutoScrollTimer(newPos);
        mustUpdate = true;
        break;
    }
    case eEventStateDraggingNode: {
        mustUpdate = true;
        mustUpdateNavigator = true;
        bool controlDown = modifierHasControl(e);
        bool shiftdown = modifierHasShift(e);
        moveSelectedNodesBy(shiftdown, controlDown, lastMousePosScene, newPos, sceneR, true);
        break;
    }
    case eEventStateMovingArea: {
        mustUpdateNavigator = true;
        moveRootInternal(dx, dy);
        _imp->cursorSet = true;
        setCursor( QCursor(Qt::SizeAllCursor) );
        mustUpdate = true;
        break;
    }
    case eEventStateResizingBackdrop: {
        mustUpdateNavigator = true;
        assert(_imp->_backdropResized);
        QPointF p = _imp->_backdropResized->scenePos();
        int w = newPos.x() - p.x();
        int h = newPos.y() - p.y();
        checkAndStartAutoScrollTimer(newPos);
        mustUpdate = true;
        pushUndoCommand( new ResizeBackdropCommand(_imp->_backdropResized, w, h) );
        break;
    }
    case eEventStateSelectionRect: {
        QPointF startDrag = _imp->_lastSelectionStartPointScene;
        QPointF cur = newPos;
        double xmin = std::min( cur.x(), startDrag.x() );
        double xmax = std::max( cur.x(), startDrag.x() );
        double ymin = std::min( cur.y(), startDrag.y() );
        double ymax = std::max( cur.y(), startDrag.y() );
        checkAndStartAutoScrollTimer(newPos);
        QRectF selRect(xmin, ymin, xmax - xmin, ymax - ymin);
        _imp->_selectionRect = selRect;
        mustUpdate = true;
        break;
    }
    case eEventStateDraggingNavigator: {
        QPointF mousePosSceneCoordinates;
        bool insideNavigator = isNearbyNavigator(e->pos(), mousePosSceneCoordinates);
        if (insideNavigator) {
            _imp->_refreshOverlays = true;
            centerOn(mousePosSceneCoordinates);
            _imp->_lastMousePos = e->pos();
            update();

            return;
        }
        break;
    }
    case eEventStateZoomingArea: {
        int delta = 2 * ( ( e->x() - _imp->_lastMousePos.x() ) - ( e->y() - _imp->_lastMousePos.y() ) );
        setTransformationAnchor(QGraphicsView::AnchorViewCenter);
        wheelEventInternal(modCASIsControl(e), delta);
        setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
        mustUpdate = true;
        break;
    }
    default:
        mustUpdate = false;
        break;
    } // switch


    _imp->_lastMousePos = e->pos();


    if (mustUpdateNavigator) {
        _imp->_refreshOverlays = true;
        mustUpdate = true;
    }

    if (mustUpdate) {
        update();
    }
    QGraphicsView::mouseMoveEvent(e);
} // mouseMoveEvent
Exemplo n.º 13
0
NodeSerialization::NodeSerialization(const NodePtr & n,
                                     bool serializeInputs)
    : _isNull(true)
      , _nbKnobs(0)
      , _knobsValues()
      , _knobsAge(0)
      , _nodeLabel()
      , _nodeScriptName()
      , _pluginID()
      , _pluginMajorVersion(-1)
      , _pluginMinorVersion(-1)
      , _hasRotoContext(false)
      , _hasTrackerContext(false)
      , _node()
      , _pythonModuleVersion(0)
{
    if (n) {
        _node = n;

        ///All this code is MT-safe

        _knobsValues.clear();
        _inputs.clear();

        if ( n->isOpenFXNode() ) {
            OfxEffectInstance* effect = dynamic_cast<OfxEffectInstance*>( n->getEffectInstance().get() );
            assert(effect);
            if (effect) {
                effect->syncPrivateData_other_thread();
            }
        }

        std::vector< KnobPtr >  knobs = n->getEffectInstance()->getKnobs_mt_safe();
        std::list<KnobPtr > userPages;
        for (U32 i  = 0; i < knobs.size(); ++i) {
            KnobGroup* isGroup = dynamic_cast<KnobGroup*>( knobs[i].get() );
            KnobPage* isPage = dynamic_cast<KnobPage*>( knobs[i].get() );

            if (isPage) {
                _pagesIndexes.push_back( knobs[i]->getName() );
                if ( knobs[i]->isUserKnob() ) {
                    userPages.push_back(knobs[i]);
                }
            }

            if ( !knobs[i]->isUserKnob() &&
                 knobs[i]->getIsPersistant() &&
                 !isGroup && !isPage
                 && knobs[i]->hasModificationsForSerialization() ) {
                ///For choice do a deepclone because we need entries
                //bool doCopyKnobs = isChoice ? true : copyKnobs;

                boost::shared_ptr<KnobSerialization> newKnobSer( new KnobSerialization(knobs[i]) );
                _knobsValues.push_back(newKnobSer);
            }
        }

        _nbKnobs = (int)_knobsValues.size();

        for (std::list<KnobPtr >::const_iterator it = userPages.begin(); it != userPages.end(); ++it) {
            boost::shared_ptr<GroupKnobSerialization> s( new GroupKnobSerialization(*it) );
            _userPages.push_back(s);
        }

        _knobsAge = n->getKnobsAge();

        _nodeLabel = n->getLabel_mt_safe();

        _nodeScriptName = n->getScriptName_mt_safe();

        _cacheID = n->getCacheID();

        _pluginID = n->getPluginID();

        if ( !n->hasPyPlugBeenEdited() ) {
            _pythonModule = n->getPluginPythonModule();
            _pythonModuleVersion = n->getMajorVersion();
        }

        _pluginMajorVersion = n->getMajorVersion();

        _pluginMinorVersion = n->getMinorVersion();

        if (serializeInputs) {
            n->getInputNames(_inputs);
        }

        NodePtr masterNode = n->getMasterNode();
        if (masterNode) {
            _masterNodeName = masterNode->getFullyQualifiedName();
        }

        boost::shared_ptr<RotoContext> roto = n->getRotoContext();
        if ( roto && !roto->isEmpty() ) {
            _hasRotoContext = true;
            roto->save(&_rotoContext);
        } else {
            _hasRotoContext = false;
        }

        boost::shared_ptr<TrackerContext> tracker = n->getTrackerContext();
        if (tracker) {
            _hasTrackerContext = true;
            tracker->save(&_trackerContext);
        } else {
            _hasTrackerContext = false;
        }


        NodeGroup* isGrp = n->isEffectGroup();
        if (isGrp) {
            NodesList nodes;
            isGrp->getActiveNodes(&nodes);

            _children.clear();

            for (NodesList::iterator it = nodes.begin(); it != nodes.end(); ++it) {
                if ( (*it)->isPartOfProject() ) {
                    boost::shared_ptr<NodeSerialization> state( new NodeSerialization(*it) );
                    _children.push_back(state);
                }
            }
        }

        _multiInstanceParentName = n->getParentMultiInstanceName();

        NodesList childrenMultiInstance;
        _node->getChildrenMultiInstance(&childrenMultiInstance);
        if ( !childrenMultiInstance.empty() ) {
            assert(!isGrp);
            for (NodesList::iterator it = childrenMultiInstance.begin(); it != childrenMultiInstance.end(); ++it) {
                assert( (*it)->getParentMultiInstance() );
                if ( (*it)->isActivated() ) {
                    boost::shared_ptr<NodeSerialization> state( new NodeSerialization(*it) );
                    _children.push_back(state);
                }
            }
        }

        n->getUserCreatedComponents(&_userComponents);

        _isNull = false;
    }
}
Exemplo n.º 14
0
void MediaRoutingView::MessageReceived(
	BMessage* message)
{
	D_METHOD(("MediaRoutingView::MessageReceived()\n"));

	switch (message->what)
	{
		case B_MEDIA_NODE_CREATED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_CREATED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("media_node_id", &type, &count) == B_OK)
			{
				for(int32 n = 0; n < count; n++) 
				{
					int32 id;
					if (message->FindInt32("media_node_id", n, &id) == B_OK)
					{
						// [e.moon 8dec99] allow for existing panel
						MediaNodePanel* panel;
						if(_findPanelFor(id, &panel) < B_OK)
							_addPanelFor(id, BPoint(5.0, 5.0));
					}
				}
			}
			break;
		}
		case B_MEDIA_NODE_DELETED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_DELETED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("media_node_id", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++) 
				{
					int32 id;
					if (message->FindInt32("media_node_id", n, &id) == B_OK)
					{
						_removePanelFor(id);
					}
				}
			}			
			break;
		}
		case B_MEDIA_CONNECTION_MADE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_MADE)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("output", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					media_output output;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("output", B_RAW_TYPE, n, &data, &dataSize) == B_OK)
					{
						output = *reinterpret_cast<const media_output *>(data);
						Connection connection;
						if (manager->findConnection(output.node.node, output.source, &connection) == B_OK)
						{
							_addWireFor(connection);
						}
					}
				}
			}
			break;
		}
		case B_MEDIA_CONNECTION_BROKEN:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_BROKEN)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("__connection_id", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					int32 id;
					if (message->FindInt32("__connection_id", n, &id) == B_OK)
					{
						_removeWireFor(id);
					}	
				}
			}
			break;
		}
		case B_MEDIA_FORMAT_CHANGED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_FORMAT_CHANGED)\n"));
			
			media_node_id nodeID;
			if(message->FindInt32("__source_node_id", &nodeID) < B_OK)
				break;

			uint32 connectionID;
			if(message->FindInt32("__connection_id", (int32*)&connectionID) < B_OK)
				break;

			media_source* source;
			ssize_t dataSize;
			if(message->FindData("be:source", B_RAW_TYPE, (const void**)&source, &dataSize) < B_OK)
				break;
				
			MediaWire* wire;
			if(_findWireFor(connectionID, &wire) == B_OK) {
				// copy new connection data
				manager->findConnection(nodeID, *source, &wire->connection);
			}
			break;
		}
		case M_CLEANUP_REQUESTED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_M_CLEANUP_REQUESTED)\n"));
			cleanUp();
			break;
		}
		case M_SELECT_ALL:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_SELECT_ALL)\n"));
			selectAll(DiagramItem::M_BOX);
			break;
		}
		case M_DELETE_SELECTION:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_DELETE_SELECTION)\n"));
			_deleteSelection();
			break;
		}
		case M_NODE_CHANGE_CYCLING:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_CYCLING_CHANGED)\n"));
			bool cycle;
			if (message->FindBool("cycle", &cycle) == B_OK)
			{
				_changeCyclingForSelection(cycle);
			}
			break;
		}
		case M_NODE_CHANGE_RUN_MODE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_RUNMODE_CHANGED)\n"));
			int32 mode;
			if (message->FindInt32("run_mode", &mode) == B_OK)
			{
				_changeRunModeForSelection(static_cast<uint32>(mode));
			}
			break;
		}
		case M_LAYOUT_CHANGED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_LAYOUT_CHANGED)\n"));
			layout_t layout;
			if (message->FindInt32("layout", (int32*)&layout) == B_OK)
			{
				if (layout != m_layout)
				{
					layoutChanged(layout);
					updateDataRect();
					Invalidate();
				}
			}
			break;
		}
		case M_NODE_START_TIME_SOURCE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_START_TIME_SOURCE)\n"));
			int32 id;
			if(message->FindInt32("nodeID", &id) < B_OK)
				break;
			NodeRef* ref;
			if(manager->getNodeRef(id, &ref) < B_OK)
				break;
			
			bigtime_t when = system_time();
			status_t err = manager->roster->StartTimeSource(ref->node(), when);
			if(err < B_OK) {
				PRINT((
					"! StartTimeSource(%ld): '%s'\n",
					ref->id(), strerror(err)));
			}
			break;
		}
		case M_NODE_STOP_TIME_SOURCE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_STOP_TIME_SOURCE)\n"));
			int32 id;
			if(message->FindInt32("nodeID", &id) < B_OK)
				break;
			NodeRef* ref;
			if(manager->getNodeRef(id, &ref) < B_OK)
				break;
			
			bigtime_t when = system_time();
			status_t err = manager->roster->StopTimeSource(ref->node(), when);
			if(err < B_OK) {
				PRINT((
					"! StopTimeSource(%ld): '%s'\n",
					ref->id(), strerror(err)));
			}
			break;
		}
		case M_NODE_TWEAK_PARAMETERS: {
			D_MESSAGE((" -> M_NODE_TWEAK_PARAMETERS\n"));
			_openParameterWindowsForSelection();
			break;
		}
		case M_NODE_START_CONTROL_PANEL: {
			D_MESSAGE((" -> M_NODE_START_CONTROL_PANEL\n"));
			_startControlPanelsForSelection();
			break;
		}
		case M_GROUP_SET_LOCKED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_GROUP_SET_LOCKED)\n"));
			int32 groupID;
			if(message->FindInt32("groupID", &groupID) < B_OK)
				break;
			bool locked;
			if(message->FindBool("locked", &locked) < B_OK)
				break;
			NodeGroup* group;
			if(manager->findGroup(groupID, &group) < B_OK)
				break;
			uint32 f = locked ?
				group->groupFlags() | NodeGroup::GROUP_LOCKED :
				group->groupFlags() & ~NodeGroup::GROUP_LOCKED;
			group->setGroupFlags(f);
			break;
		}
		case M_BROADCAST_SELECTION: {
			D_MESSAGE((" -> M_BROADCAST_SELECTION\n"));
			_broadcastSelection();
			break;
		}
		case InfoWindowManager::M_INFO_WINDOW_REQUESTED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(InfoView::M_INFO_WINDOW_REQUESTED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("input", &type, &count) == B_OK)
			{
				for (int32 i = 0; i < count; i++)
				{
					media_input input;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("input", B_RAW_TYPE, i, &data, &dataSize) == B_OK)
					{
						input = *reinterpret_cast<const media_input *>(data);
						InfoWindowManager *manager = InfoWindowManager::Instance();
						if (manager && manager->Lock()) {
							manager->openWindowFor(input);
							manager->Unlock();
						}
					}
				}
			}
			else if (message->GetInfo("output", &type, &count) == B_OK)
			{
				for (int32 i = 0; i < count; i++)
				{
					media_output output;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("output", B_RAW_TYPE, i, &data, &dataSize) == B_OK)
					{
						output = *reinterpret_cast<const media_output *>(data);
						InfoWindowManager *manager = InfoWindowManager::Instance();
						if (manager && manager->Lock()) {
							manager->openWindowFor(output);
							manager->Unlock();
						}
					}
				}
			}
			else
			{
				_openInfoWindowsForSelection();
			}
			break;
		}
		case NodeManager::M_RELEASED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(NodeManager::M_RELEASED)\n"));
			remove_observer(this, manager);
			const_cast<RouteAppNodeManager*&>(manager) = 0;	
			// +++++ disable view!
			break;
		}			
		case NodeRef::M_RELEASED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(NodeRef::M_RELEASED)\n"));
			// only relevant on shutdown; do nothing
			break;
		}
		default:
		{
			DiagramView::MessageReceived(message);
		}
	}
}
Exemplo n.º 15
0
Connector *CircuitICNDocument::createConnector(Connector *con1, Connector *con2, const QPoint &pos1, const QPoint &pos2, QPointList *pointList )
{
	if ( !canConnect( con1, con2 ) ) return 0;
	
	const bool con1UsedManual = con1->usesManualPoints();
	const bool con2UsedManual = con2->usesManualPoints();
	
	QList<QPointList> oldCon1Points = con1->splitConnectorPoints(pos1);
	QList<QPointList> oldCon2Points = con2->splitConnectorPoints(pos2);
	
	ECNode *node1a = dynamic_cast<ECNode*> ( con1->startNode() );
	ECNode *node1b = dynamic_cast<ECNode*> ( con1->endNode(  ) );
	
	ECNode *node2a = dynamic_cast<ECNode*> ( con2->startNode() );
	ECNode *node2b = dynamic_cast<ECNode*> ( con2->endNode(  ) );
	
	if ( !node1a || !node1b || !node2a || !node2b ) return 0;
	
	con1->hide();	
	con2->hide();

	// from this point forward, we are dealing with a circuit document -> all nodes are electronic
	
	ECNode *newNode1 = new JunctionNode( this, 0, pos1 );
	ECNode *newNode2 = new JunctionNode( this, 0, pos2 );
	
	Connector *con1a = newNode1->createConnector(node1a);
	node1a->addConnector(con1a);

	Connector *con1b = newNode1->createConnector(node1b);
	node1b->addConnector(con1b);
	
	Connector *newCon = newNode1->createConnector(newNode2);
	newNode2->addConnector(newCon);
	
	Connector *con2a = node2a->createConnector(newNode2);
	newNode2->addConnector(con2a);

	Connector *con2b = node2b->createConnector(newNode2);
	newNode2->addConnector(con2b);
	
	if(!con1a || !con1b || !con2a || !con2b ) {
		// This should never happen, as the canConnect function should strictly
		// determine whether the connectors could be created before hand.
		kWarning() << k_funcinfo << "Not all the connectors were created, this should never happen" << endl;
		
		if(con1a) con1a->removeConnector();
		if(con1b) con1b->removeConnector();
		if(con2a) con2a->removeConnector();
		if(con2b) con2b->removeConnector();
		
		newNode1->removeNode();
		newNode2->removeNode();
		
		flushDeleteList();
		return 0;
	}
	
	con1a->setRoutePoints(oldCon1Points.at(0), con1UsedManual );
	con1b->setRoutePoints(oldCon1Points.at(1), con1UsedManual );
	
	con2a->setRoutePoints(oldCon2Points.at(0), con2UsedManual );
	con2b->setRoutePoints(oldCon2Points.at(1), con2UsedManual );
	
	QPointList autoPoints;

	if (!pointList) {
		addAllItemConnectorPoints();
		ConRouter cr(this);
		cr.mapRoute( pos1.x(), pos1.y(), pos2.x(), pos2.y() );
		autoPoints = cr.pointList(false);
		pointList = &autoPoints;
	}

	newCon->setRoutePoints(*pointList,true);

	// Avoid flicker: tell them to update their draw lists now
	con1->updateConnectorPoints(false);
	con2->updateConnectorPoints(false);
	newCon->updateDrawList();
	con1a->updateDrawList();
	con1b->updateDrawList();
	con2a->updateDrawList();
	con2b->updateDrawList();
	
	// Now it's safe to remove the connectors
	con1->removeConnector();
	con2->removeConnector();
	
	flushDeleteList();

	deleteNodeGroup(node1a);
	deleteNodeGroup(node1b);
	deleteNodeGroup(node2a);
	deleteNodeGroup(node2b);

	NodeGroup *ng = createNodeGroup(newNode1);

	ng->addNode( newNode2, true );
	ng->init();
	
	return newCon;
}
Exemplo n.º 16
0
void RouteAppNodeManager::connectionMade(
	Connection*										connection) {

	D_HOOK((
		"@ RouteAppNodeManager::connectionMade()\n"));
		
	status_t err;

	// prepare the log message
	BMessage logMsg(M_LOG);
	BString title = "Connection ";
	if (strcmp(connection->outputName(), connection->inputName()) == 0) {
		title << "'" << connection->outputName() << "' ";
	}
	title << "made";
	logMsg.AddString("title", title);

	if(!(connection->flags() & Connection::INTERNAL))
		// don't react to connection Cortex didn't make
		return;
	
	// create or merge groups
	NodeRef *producer, *consumer;
	err = getNodeRef(connection->sourceNode(), &producer);
	if(err < B_OK) {
		D_HOOK((
			"!!! RouteAppNodeManager::connectionMade():\n"
			"    sourceNode (%ld) not found\n",
			connection->sourceNode()));
		return;	
	}
	err = getNodeRef(connection->destinationNode(), &consumer);
	if(err < B_OK) {
		D_HOOK((
			"!!! RouteAppNodeManager::connectionMade():\n"
			"    destinationNode (%ld) not found\n",
			connection->destinationNode()));
		return;	
	}

	// add node names to log messages
	BString line = "Between:";
	logMsg.AddString("line", line);
	line = "    ";
	line << producer->name() << " and ";
	line << consumer->name();
	logMsg.AddString("line", line);

	// add format to log message
	line = "Negotiated format:";
	logMsg.AddString("line", line);
	line = "    ";
	line << MediaString::getStringFor(connection->format(), false);
	logMsg.AddString("line", line);

	NodeGroup *group = 0;
	BString groupName = "Untitled group ";
	if(_canGroup(producer) && _canGroup(consumer))
	{
		if (producer->group() && consumer->group() &&
			!(producer->group()->groupFlags() & NodeGroup::GROUP_LOCKED) &&
			!(consumer->group()->groupFlags() & NodeGroup::GROUP_LOCKED))
		{
			// merge into consumers group
			group = consumer->group();
			mergeGroups(producer->group(), group);
		}
		else if (producer->group() &&
			!(producer->group()->groupFlags() & NodeGroup::GROUP_LOCKED))
		{ // add consumer to producers group
			group = producer->group();
			group->addNode(consumer);
		}
		else if (consumer->group() &&
			!(consumer->group()->groupFlags() & NodeGroup::GROUP_LOCKED))
		{ // add producer to consumers group
			group = consumer->group();
			group->addNode(producer);
		}
		else
		{ // make new group for both
			groupName << m_nextGroupNumber++;
			group = createGroup(groupName.String());
			group->addNode(producer);
			group->addNode(consumer);
		}
	}
	else if(_canGroup(producer) && !producer->group())
	{ // make new group for producer
		groupName << m_nextGroupNumber++;
		group = createGroup(groupName.String());
		group->addNode(producer);
	}
	else if(_canGroup(consumer) && !consumer->group())
	{ // make new group for consumer
		groupName << m_nextGroupNumber++;
		group = createGroup(groupName.String());
		group->addNode(consumer);			
	}

	m_logTarget.SendMessage(&logMsg);
}
Exemplo n.º 17
0
int Controller::LoadMesh(Render *re, SceneRenderLayer *srl)
{
	BlenderFileLoader loader(re, srl);

	loader.setRenderMonitor(_pRenderMonitor);

	_Chrono.start();

	NodeGroup *blenderScene = loader.Load();

	if (blenderScene == NULL) {
		if (G.debug & G_DEBUG_FREESTYLE) {
			cout << "Cannot load scene" << endl;
		}
		return 1;
	}

	if (blenderScene->numberOfChildren() < 1) {
		if (G.debug & G_DEBUG_FREESTYLE) {
			cout << "Empty scene" << endl;
		}
		blenderScene->destroy();
		delete blenderScene;
		return 1;
	}

	real duration = _Chrono.stop();
	if (G.debug & G_DEBUG_FREESTYLE) {
		cout << "Scene loaded" << endl;
		printf("Mesh cleaning    : %lf\n", duration);
	}
	_SceneNumFaces += loader.numFacesRead();

	if (loader.minEdgeSize() < _minEdgeSize) {
		_minEdgeSize = loader.minEdgeSize();
	}

#if 0  // DEBUG
	ScenePrettyPrinter spp;
	blenderScene->accept(spp);
#endif

	_RootNode->AddChild(blenderScene);
	_RootNode->UpdateBBox(); // FIXME: Correct that by making a Renderer to compute the bbox

	_pView->setModel(_RootNode);
	//_pView->FitBBox();

	if (_pRenderMonitor->testBreak())
		return 0;

	_Chrono.start();

	WXEdgeBuilder wx_builder;
	wx_builder.setRenderMonitor(_pRenderMonitor);
	blenderScene->accept(wx_builder);
	_winged_edge = wx_builder.getWingedEdge();

	duration = _Chrono.stop();
	if (G.debug & G_DEBUG_FREESTYLE) {
		printf("WEdge building   : %lf\n", duration);
	}

#if 0
	_pView->setDebug(_DebugNode);

	// delete stuff
	if (0 != ws_builder) {
		delete ws_builder;
		ws_builder = 0;
	}

	soc QFileInfo qfi(iFileName);
	soc string basename((const char*)qfi.fileName().toAscii().data());
	char cleaned[FILE_MAX];
	BLI_strncpy(cleaned, iFileName, FILE_MAX);
	BLI_cleanup_file(NULL, cleaned);
	string basename = string(cleaned);
#endif

	_ListOfModels.push_back("Blender_models");

	_Scene3dBBox = _RootNode->bbox();

	_bboxDiag = (_RootNode->bbox().getMax() - _RootNode->bbox().getMin()).norm();
	if (G.debug & G_DEBUG_FREESTYLE) {
		cout << "Triangles nb     : " << _SceneNumFaces << endl;
		cout << "Bounding Box     : " << _bboxDiag << endl;
	}

	ClearRootNode();

	return 0;
}