Exemplo n.º 1
0
void
KnobGui::onRemoveKeyActionTriggered()
{
    QAction* action = qobject_cast<QAction*>( sender() );

    assert(action);
    int dim = action->data().toInt();
    KnobPtr knob = getKnob();

    assert( knob->getHolder()->getApp() );
    //get the current time on the global timeline
    SequenceTime time = knob->getHolder()->getApp()->getTimeLine()->currentFrame();
    std::map<boost::shared_ptr<CurveGui>, std::vector<KeyFrame > > toRemove;
    KnobGuiPtr thisShared = shared_from_this();

    for (int i = 0; i < knob->getDimension(); ++i) {
        if ( (dim == -1) || (i == dim) ) {
            std::list<boost::shared_ptr<CurveGui> > curves = getGui()->getCurveEditor()->findCurve(thisShared, i);
            for (std::list<boost::shared_ptr<CurveGui> >::iterator it = curves.begin(); it != curves.end(); ++it) {
                KeyFrame kf;
                bool foundKey = knob->getCurve(ViewIdx(0), i)->getKeyFrameWithTime(time, &kf);

                if (foundKey) {
                    std::vector<KeyFrame > vect;
                    vect.push_back(kf);
                    toRemove.insert( std::make_pair(*it, vect) );
                }
            }
        }
    }
    pushUndoCommand( new RemoveKeysCommand(getGui()->getCurveEditor()->getCurveWidget(),
                                           toRemove) );
}
Exemplo n.º 2
0
void
KnobGui::onRemoveAnimationActionTriggered()
{
    QAction* action = qobject_cast<QAction*>( sender() );

    assert(action);
    int dim = action->data().toInt();
    KnobPtr knob = getKnob();
    std::map<boost::shared_ptr<CurveGui>, std::vector<KeyFrame > > toRemove;
    KnobGuiPtr thisShared = shared_from_this();
    for (int i = 0; i < knob->getDimension(); ++i) {
        if ( (dim == -1) || (dim == i) ) {
            std::list<boost::shared_ptr<CurveGui> > curves = getGui()->getCurveEditor()->findCurve(thisShared, i);
            for (std::list<boost::shared_ptr<CurveGui> >::iterator it = curves.begin(); it != curves.end(); ++it) {
                KeyFrameSet keys = (*it)->getInternalCurve()->getKeyFrames_mt_safe();
                std::vector<KeyFrame > vect;
                for (KeyFrameSet::const_iterator it2 = keys.begin(); it2 != keys.end(); ++it2) {
                    vect.push_back(*it2);
                }
                toRemove.insert( std::make_pair(*it, vect) );
            }
        }
    }
    pushUndoCommand( new RemoveKeysCommand(getGui()->getCurveEditor()->getCurveWidget(),
                                           toRemove) );
    //refresh the gui so it doesn't indicate the parameter is animated anymore
    updateGUI(dim);
}
Exemplo n.º 3
0
void
KnobGui::show(int /*index*/)
{
    if ( !getGui() ) {
        return;
    }
    if (!_imp->customInteract) {
        _show();
    } else {
        _imp->customInteract->show();
    }

    //also show the curve from the curve editor if there's any
    KnobPtr knob = getKnob();
    if ( knob && knob->getHolder() && knob->getHolder()->getApp() ) {
        getGui()->getCurveEditor()->showCurves( shared_from_this() );
    }

    //if (_imp->isOnNewLine) {
    if (_imp->field) {
        _imp->field->show();
    }
    if (_imp->container) {
        _imp->container->refreshTabWidgetMaxHeight();
    }
    //}

    if (_imp->labelContainer) {
        _imp->labelContainer->show();
    } else if (_imp->descriptionLabel) {
        _imp->descriptionLabel->show();
    }
}
Exemplo n.º 4
0
void
NodeGraph::updateCacheSizeText()
{
    if ( !getGui() ) {
        return;
    }
    if ( getGui()->isGUIFrozen() ) {
        if ( _imp->_cacheSizeText->isVisible() ) {
            _imp->_cacheSizeText->hide();
        }

        return;
    } else {
        if ( !_imp->cacheSizeHidden && !_imp->_cacheSizeText->isVisible() ) {
            _imp->_cacheSizeText->show();
        } else if ( _imp->cacheSizeHidden && _imp->_cacheSizeText->isVisible() ) {
            _imp->_cacheSizeText->hide();

            return;
        }
    }

    QString oldText = _imp->_cacheSizeText->text();
    quint64 cacheSize = appPTR->getTileCache()->getCurrentSize();
    QString cacheSizeStr = QDirModelPrivate_size(cacheSize);
    QString newText = tr("Image Cache: %1").arg(cacheSizeStr);
    if (newText != oldText) {
        _imp->_cacheSizeText->setText(newText);
    }
}
Exemplo n.º 5
0
void
KnobGuiColor::onDialogCurrentColorChanged(const QColor & color)
{
    KnobColorPtr knob = _knob.lock();
    bool isSimple = _useSimplifiedUI;
    int nDims = knob->getDimension();

    if (nDims == 1) {
        knob->setValue(color.redF(), ViewSpec::all(), 0);
    } else if (nDims == 3) {
        knob->setValues(isSimple ? color.redF() : Color::from_func_srgb( color.redF() ),
                        isSimple ? color.greenF() : Color::from_func_srgb( color.greenF() ),
                        isSimple ? color.blueF() : Color::from_func_srgb( color.blueF() ),
                        ViewSpec::all(),
                        eValueChangedReasonNatronInternalEdited);
    } else if (nDims == 4) {
        knob->setValues(isSimple ? color.redF() : Color::from_func_srgb( color.redF() ),
                        isSimple ? color.greenF() : Color::from_func_srgb( color.greenF() ),
                        isSimple ? color.blueF() : Color::from_func_srgb( color.blueF() ),
                        color.alphaF(),
                        ViewSpec::all(),
                        eValueChangedReasonNatronInternalEdited);
    }
    if ( getGui() ) {
        getGui()->setDraftRenderEnabled(true);
    }
}
Exemplo n.º 6
0
PyPanel::PyPanel(const QString& scriptName,
                 const QString& label,
                 bool useUserParameters,
                 GuiApp* app)
    : QWidget( app->getGui() )
    , UserParamHolder()
    , PanelWidget(scriptName.toStdString(), this, app->getGui() )
    , _imp( new PyPanelPrivate() )
{
    setLabel( label.toStdString() );


    int idx = 1;
    std::string name = NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly( scriptName.toStdString() );
    PanelWidget* existing = 0;
    existing = getGui()->findExistingTab(name);
    while (existing) {
        std::stringstream ss;
        ss << name << idx;
        existing = getGui()->findExistingTab( ss.str() );
        if (!existing) {
            name = ss.str();
        }
        ++idx;
    }

    setScriptName(name);


    if (useUserParameters) {
        _imp->holder = DialogParamHolder::create( QString::fromUtf8( name.c_str() ), getGui()->getApp(), this );
        setHolder(_imp->holder);
        _imp->holder->initializeKnobsPublic();
        _imp->mainLayout = new QVBoxLayout(this);
        _imp->mainLayout->setContentsMargins(0, 0, 0, 0);

        _imp->centerContainer = new QWidget(this);
        _imp->centerLayout = new QVBoxLayout(_imp->centerContainer);
        _imp->centerLayout->setContentsMargins(0, 0, 0, 0);

        _imp->panel = new DockablePanel(getGui(),
                                        _imp->holder,
                                        _imp->mainLayout,
                                        DockablePanel::eHeaderModeNoHeader,
                                        false,
                                        boost::shared_ptr<QUndoStack>(),
                                        QString(), QString(),
                                        _imp->centerContainer);
        _imp->panel->turnOffPages();
        _imp->centerLayout->insertWidget(0, _imp->panel);

        _imp->mainLayout->addWidget(_imp->centerContainer);
        _imp->mainLayout->addStretch();
    }
}
Exemplo n.º 7
0
void
KnobGuiColor::onPickingEnabled(bool enabled)
{
    if ( getKnob()->getHolder()->getApp() ) {
        if (enabled) {
            getGui()->registerNewColorPicker( _knob.lock() );
        } else {
            getGui()->removeColorPicker( _knob.lock() );
        }
    }
}
Exemplo n.º 8
0
void
KnobGui::onSetKeyActionTriggered()
{
    QAction* action = qobject_cast<QAction*>( sender() );

    assert(action);
    int dim = action->data().toInt();
    KnobPtr knob = getKnob();

    assert( knob->getHolder()->getApp() );
    //get the current time on the global timeline
    SequenceTime time = knob->getHolder()->getApp()->getTimeLine()->currentFrame();
    AddKeysCommand::KeysToAddList toAdd;
    KnobGuiPtr thisShared = shared_from_this();
    for (int i = 0; i < knob->getDimension(); ++i) {
        if ( (dim == -1) || (i == dim) ) {
            std::list<boost::shared_ptr<CurveGui> > curves = getGui()->getCurveEditor()->findCurve(thisShared, i);
            for (std::list<boost::shared_ptr<CurveGui> >::iterator it = curves.begin(); it != curves.end(); ++it) {
                AddKeysCommand::KeyToAdd keyToAdd;
                KeyFrame kf;
                kf.setTime(time);
                Knob<int>* isInt = dynamic_cast<Knob<int>*>( knob.get() );
                Knob<bool>* isBool = dynamic_cast<Knob<bool>*>( knob.get() );
                AnimatingKnobStringHelper* isString = dynamic_cast<AnimatingKnobStringHelper*>( knob.get() );
                Knob<double>* isDouble = dynamic_cast<Knob<double>*>( knob.get() );

                if (isInt) {
                    kf.setValue( isInt->getValue(i) );
                } else if (isBool) {
                    kf.setValue( isBool->getValue(i) );
                } else if (isDouble) {
                    kf.setValue( isDouble->getValue(i) );
                } else if (isString) {
                    std::string v = isString->getValue(i);
                    double dv;
                    isString->stringToKeyFrameValue(time, ViewIdx(0), v, &dv);
                    kf.setValue(dv);
                }

                keyToAdd.keyframes.push_back(kf);
                keyToAdd.curveUI = *it;
                keyToAdd.knobUI = thisShared;
                keyToAdd.dimension = i;
                toAdd.push_back(keyToAdd);
            }
        }
    }
    pushUndoCommand( new AddKeysCommand(getGui()->getCurveEditor()->getCurveWidget(), toAdd) );
}
Exemplo n.º 9
0
	void FlowLayout::layoutChildren()
	{
		if(getGui())
		{
			getGui()->toggleWidgetLocationChanged(false);
		}
		
		agui::FlowLayout::layoutChildren();
		if(getGui())
		{
			getGui()->toggleWidgetLocationChanged(true);
			getGui()->_widgetLocationChanged();
		}
		
	}
Exemplo n.º 10
0
ViewerTab::~ViewerTab()
{
    Gui* gui = getGui();
    if (gui) {
        NodeGraph* graph = 0;
        ViewerNodePtr internalNode = getInternalNode();

        ViewerInstancePtr viewerNode = internalNode ? internalNode->getInternalViewerNode() : ViewerInstancePtr();
        if (viewerNode) {
            NodeCollectionPtr collection = viewerNode->getNode()->getGroup();
            if (collection) {
                NodeGroupPtr isGrp = toNodeGroup(collection);
                if (isGrp) {
                    NodeGraphI* graph_i = isGrp->getNodeGraph();
                    if (graph_i) {
                        graph = dynamic_cast<NodeGraph*>(graph_i);
                        assert(graph);
                    }
                } else {
                    graph = gui->getNodeGraph();
                }
            }
            internalNode->invalidateUiContext();
        } else {
            graph = gui->getNodeGraph();
        }
        assert(graph);
        GuiAppInstancePtr app = gui->getApp();
        if ( app && !app->isClosing() && graph && (graph->getLastSelectedViewer() == this) ) {
            graph->setLastSelectedViewer(0);
        }
    }
    _imp->nodesContext.clear();
}
Exemplo n.º 11
0
void
ViewerTab::setInfoBarAndViewerResolution(const RectI& rect, const RectD& canonicalRect, double par, int texIndex)
{
    std::string formatName, infoBarName;
    Gui* gui = getGui();
    if (!gui) {
        return;
    }
    GuiAppInstancePtr app = gui->getApp();
    if (!app) {
        return;
    }
    if (!app->getProject()->getFormatNameFromRect(rect, par, &formatName)) {
        formatName = makeUpFormatName(rect, par);
        infoBarName = formatName;
    } else {
        // If the format has a name, for the info bar also add the resolution
        std::stringstream ss;
        ss << formatName;
        ss << ' ';
        ss << rect.width();
        ss << 'x';
        ss << rect.height();
        infoBarName = ss.str();
    }
    _imp->infoWidget[texIndex]->setResolution(QString::fromUtf8(infoBarName.c_str()));
    _imp->viewer->setFormat(formatName, canonicalRect, par, texIndex);
}
Exemplo n.º 12
0
bool
NodeGraph::pasteClipboard(const QPointF& pos)
{
    QPointF position;
    if (pos.x() == INT_MIN || pos.y() == INT_MIN) {
        position =  mapToScene( mapFromGlobal( QCursor::pos() ) );
    } else {
        position = pos;
    }

    QClipboard* clipboard = QApplication::clipboard();
    const QMimeData* mimedata = clipboard->mimeData();

    // If this is a list of files, try to open them
    if ( mimedata->hasUrls() ) {
        QList<QUrl> urls = mimedata->urls();
        getGui()->handleOpenFilesFromUrls( urls, QCursor::pos() );
        return true;
    }

    if ( !mimedata->hasFormat( QLatin1String("text/plain") ) ) {
        return false;
    }
    QByteArray data = mimedata->data( QLatin1String("text/plain") );
    std::string s = QString::fromUtf8(data).toStdString();
    std::istringstream ss(s);
    return tryReadClipboard(position, ss);
    
}
Exemplo n.º 13
0
void
ScriptEditor::onSourceScriptClicked()
{
    std::vector<std::string> filters;

    filters.push_back("py");
    SequenceFileDialog dialog(this, filters, false, SequenceFileDialog::eFileDialogModeOpen, getGui()->getLastLoadProjectDirectory().toStdString(),
                              getGui(), false);

    if ( dialog.exec() ) {
        QDir currentDir = dialog.currentDirectory();
        getGui()->updateLastOpenedProjectPath( currentDir.absolutePath() );

        QString fileName( QString::fromUtf8( dialog.selectedFiles().c_str() ) );
        sourceScript(fileName);
    }
}
Exemplo n.º 14
0
	void CSLevel::createGUIBaseWindow()
	{
		destroyGUIBaseWindow();

		// create the base gui element
		m_GUIBaseWindow = new CSGUI_Window(getApplication()->getDesktop(), getGui(), getApplication()->getDesktop(),getId(),L"CSLevel",rect<s32>(0,0,1024,768),CS_VISIBLE|CS_BORDER|CS_CAPTION|CS_TRANSPARENT,CSGUI_Layout(layoutStyle::REST),0);
		getApplication()->getDesktop()->addCSChild(m_GUIBaseWindow);
	}
Exemplo n.º 15
0
void
KnobGui::onShowInCurveEditorActionTriggered()
{
    KnobPtr knob = getKnob();

    assert( knob->getHolder()->getApp() );
    getGui()->setCurveEditorOnTop();
    std::vector<boost::shared_ptr<Curve> > curves;
    for (int i = 0; i < knob->getDimension(); ++i) {
        boost::shared_ptr<Curve> c = getCurve(ViewIdx(0), i);
        if ( c->isAnimated() ) {
            curves.push_back(c);
        }
    }
    if ( !curves.empty() ) {
        getGui()->getCurveEditor()->centerOn(curves);
    }
}
Exemplo n.º 16
0
/**
 * @brief Returns for a string the estimated pixel size it would take on the widget
 **/
int
KnobGui::getStringWidthForCurrentFont(const std::string& string) const
{
    if (_imp->customInteract) {
        return _imp->customInteract->getStringWidthForCurrentFont(string);
    }

    return getGui()->fontMetrics().width( QString::fromUtf8( string.c_str() ) );
}
Exemplo n.º 17
0
/**
 * @brief Returns the font height, i.e: the height of the highest letter for this font
 **/
int
KnobGui::getWidgetFontHeight() const
{
    if (_imp->customInteract) {
        return _imp->customInteract->getWidgetFontHeight();
    }

    return getGui()->fontMetrics().height();
}
	void MessageBoxContainer::showMessage( const std::string& title, const std::string& message, MessageBox::MessageType type, MessageBoxResultReceiver* rec, int tag )
	{
		if(getGui())
		{
			if(m_msg->getModalContainer()->getParent() == NULL)
				getGui()->add(m_msg->getModalContainer());

			m_msg->getModalContainer()->bringToFront();
			m_msg->getModalContainer()->setVisibility(true);
		}

		setGlobalOpacity(0.0f);
		bringToFront();
		m_msg->showMessage(title,message,m_frame,type,rec,tag);
		setSize(m_frame->getSize());
		recenter();
		setVisibility(true);
		bool gotFocus = requestModalFocus();
	}
Exemplo n.º 19
0
void
KnobGui::hide()
{
    if (!_imp->customInteract) {
        _hide();
    } else {
        _imp->customInteract->hide();
    }

    //also  hide the curve from the curve editor if there's any and the knob is not inside a group
    KnobPtr knob = getKnob();
    if ( knob && knob->getHolder() && knob->getHolder()->getApp() ) {
        KnobPtr parent = getKnob()->getParentKnob();
        bool isSecret = true;
        while (parent) {
            if ( !parent->getIsSecret() ) {
                isSecret = false;
                break;
            }
            parent = parent->getParentKnob();
        }
        if (isSecret) {
            getGui()->getCurveEditor()->hideCurves( shared_from_this() );
        }
    }

    ////In order to remove the row of the layout we have to make sure ALL the knobs on the row
    ////are hidden.
    bool shouldRemoveWidget = true;
    for (U32 i = 0; i < _imp->knobsOnSameLine.size(); ++i) {
        KnobGuiPtr sibling = _imp->container->getKnobGui( _imp->knobsOnSameLine[i].lock() );
        if ( sibling && !sibling->isSecretRecursive() ) {
            shouldRemoveWidget = false;
        }
    }

    if (shouldRemoveWidget) {
        if (_imp->field) {
            _imp->field->hide();
        }
        if (_imp->container) {
            _imp->container->refreshTabWidgetMaxHeight();
        }
    } else {
        if ( _imp->field && !_imp->field->isVisible() ) {
            _imp->field->show();
        }
    }
    if (_imp->labelContainer) {
        _imp->labelContainer->hide();
    } else if (_imp->descriptionLabel) {
        _imp->descriptionLabel->hide();
    }
} // KnobGui::hide
Exemplo n.º 20
0
void
ViewerTab::removeTrackerInterface(NodeGui* n,
                                  bool permanently,
                                  bool removeAndDontSetAnother)
{
    std::map<NodeGui*,TrackerGui*>::iterator it = _imp->trackerNodes.find(n);

    if ( it != _imp->trackerNodes.end() ) {
        if (!getGui()) {
            if (permanently) {
                delete it->second;
            }

            return;
        }

        if (_imp->currentTracker.first == n) {
            ///Remove the widgets of the current tracker node

            int buttonsBarIndex = _imp->mainLayout->indexOf( _imp->currentTracker.second->getButtonsBar() );
            assert(buttonsBarIndex >= 0);
            if (buttonsBarIndex >= 0) {
                QLayoutItem* buttonsBar = _imp->mainLayout->itemAt(buttonsBarIndex);
                assert(buttonsBar);
                if (buttonsBar) {
                    _imp->mainLayout->removeItem(buttonsBar);
                    buttonsBar->widget()->hide();
                }
            }
            if (!removeAndDontSetAnother) {
                ///If theres another tracker node, set it as the current tracker interface
                std::map<NodeGui*,TrackerGui*>::iterator newTracker = _imp->trackerNodes.end();
                for (std::map<NodeGui*,TrackerGui*>::iterator it2 = _imp->trackerNodes.begin(); it2 != _imp->trackerNodes.end(); ++it2) {
                    if ( (it2->second != it->second) && it2->first->isSettingsPanelVisible() ) {
                        newTracker = it2;
                        break;
                    }
                }

                _imp->currentTracker.first = 0;
                _imp->currentTracker.second = 0;

                if ( newTracker != _imp->trackerNodes.end() ) {
                    setTrackerInterface(newTracker->first);
                }
            }
        }

        if (permanently) {
            delete it->second;
            _imp->trackerNodes.erase(it);
        }
    }
}
Exemplo n.º 21
0
void
ScriptEditor::onSaveScriptClicked()
{
    std::vector<std::string> filters;

    filters.push_back("py");
    SequenceFileDialog dialog(this, filters, false, SequenceFileDialog::eFileDialogModeSave, getGui()->getLastSaveProjectDirectory().toStdString(),
                              getGui(), false);

    if ( dialog.exec() ) {
        QDir currentDir = dialog.currentDirectory();
        getGui()->updateLastSavedProjectPath( currentDir.absolutePath() );

        QString fileName( QString::fromUtf8( dialog.selectedFiles().c_str() ) );
        QFile file(fileName);
        if ( file.open(QIODevice::ReadWrite) ) {
            QTextStream ts(&file);
            ts << _imp->inputEdit->toPlainText();
        } else {
            Dialogs::errorDialog( tr("Operation failed").toStdString(), tr("Failure to save the file").toStdString() );
        }
    }
}
Exemplo n.º 22
0
void
KnobGui::setEnabledSlot()
{
    if ( !getGui() ) {
        return;
    }
    if (!_imp->customInteract) {
        setEnabled();
    }
    KnobPtr knob = getKnob();
    if (_imp->descriptionLabel) {
        _imp->descriptionLabel->setReadOnly( !knob->isEnabled(0) );
    }
    KnobGuiPtr thisShared = shared_from_this();
    if ( knob->getHolder() && knob->getHolder()->getApp() ) {
        for (int i = 0; i < knob->getDimension(); ++i) {
            if ( !knob->isEnabled(i) ) {
                getGui()->getCurveEditor()->hideCurve(thisShared, i);
            } else {
                getGui()->getCurveEditor()->showCurve(thisShared, i);
            }
        }
    }
}
Exemplo n.º 23
0
void
KnobGui::onSetExprActionTriggered()
{
    QAction* action = qobject_cast<QAction*>( sender() );

    assert(action);

    int dim = action->data().toInt();
    EditExpressionDialog* dialog = new EditExpressionDialog(getGui(), dim, shared_from_this(), _imp->field);
    dialog->create(QString::fromUtf8( getKnob()->getExpression(dim == -1 ? 0 : dim).c_str() ), true);
    QObject::connect( dialog, SIGNAL(accepted()), this, SLOT(onEditExprDialogFinished()) );
    QObject::connect( dialog, SIGNAL(rejected()), this, SLOT(onEditExprDialogFinished()) );

    dialog->show();
}
Exemplo n.º 24
0
void
GuiAppInstance::handleFileOpenEvent(const std::string &filename)
{
    QString fileCopy( QString::fromUtf8( filename.c_str() ) );

    fileCopy.replace( QLatin1Char('\\'), QLatin1Char('/') );
    QString ext = QtCompat::removeFileExtension(fileCopy);
    if ( ext == QString::fromUtf8(NATRON_PROJECT_FILE_EXT) ) {
        AppInstance* app = getGui()->openProject(filename);
        if (!app) {
            Dialogs::errorDialog(tr("Project").toStdString(), tr("Failed to open project").toStdString() + ' ' + filename);
        }
    } else {
        appPTR->handleImageFileOpenRequest(filename);
    }
}
Exemplo n.º 25
0
void
ViewerTab::keyReleaseEvent(QKeyEvent* e)
{
    // always running in the main thread
    assert( qApp && qApp->thread() == QThread::currentThread() );
    Gui* gui = getGui();
    if (!gui) {
        return QWidget::keyPressEvent(e);
    }
    double scale = 1. / ( 1 << _imp->viewer->getCurrentRenderScale() );
    if ( notifyOverlaysKeyUp(RenderScale(scale), e) ) {
        _imp->viewer->redraw();
    } else {
        handleUnCaughtKeyUpEvent(e);
        QWidget::keyReleaseEvent(e);
    }
}
Exemplo n.º 26
0
int
Control::unknownObjectMsg(emf_ObjectData_X* object_data, bool is_fatal)
{
  const int isOK = 0;

  UserInterface* gui = getGui();
  strstream strm;
  strm << "WARNING: Unknown object name: "
       << object_data->object_name
       << ends;

  gui->showMsg(strm.str());

  if (is_fatal)
    return !isOK;
  else
    return isOK;
}
Exemplo n.º 27
0
void
ViewerTab::onTimeLineTimeChanged(SequenceTime time,
                                 int reason)
{
    Gui* gui = getGui();
    if (!gui) {
        return;
    }
    ViewerNodePtr node = _imp->viewerNode.lock();
    ViewerInstancePtr viewerNode = node->getInternalViewerNode();
    if ((TimelineChangeReasonEnum)reason != eTimelineChangeReasonPlaybackSeek) {
        node->getCurrentFrameKnob()->setValue(time, ViewSetSpec::current(), DimIdx(0), eValueChangedReasonPluginEdited);
    }

    GuiAppInstancePtr app = gui->getApp();
    if ( app &&  _imp->timeLineGui->getTimeline() != app->getTimeLine() ) {
        viewerNode->renderCurrentFrame(true);
    }
}
Exemplo n.º 28
0
GuiType GuiManager::getGuiType(const std::string& guiPath)
{
	// Get the GUI (will load the file if necessary)
	GuiPtr gui = getGui(guiPath);

	GuiInfoMap::iterator found = _guis.find(guiPath);

	if (found == _guis.end())
	{
		return FILE_NOT_FOUND;
	}

	// Gui Info found, determine readable type if necessary
	if (found->second.type == UNDETERMINED)
	{
		found->second.type = determineGuiType(found->second.gui);
	}

	return found->second.type;
}
Exemplo n.º 29
0
void
NodeGraph::selectNode(const NodeGuiPtr & n,
                      bool addToSelection)
{
    if ( !n->isVisible() ) {
        return;
    }
    bool alreadyInSelection = std::find(_imp->_selection.begin(),_imp->_selection.end(),n) != _imp->_selection.end();


    assert(n);
    if (addToSelection && !alreadyInSelection) {
        _imp->_selection.push_back(n);
    } else if (!addToSelection) {
        clearSelection();
        _imp->_selection.push_back(n);
    }

    n->setUserSelected(true);

    ViewerInstance* isViewer =  n->getNode()->isEffectViewer();
    if (isViewer) {
        OpenGLViewerI* viewer = isViewer->getUiContext();
        const std::list<ViewerTab*> & viewerTabs = getGui()->getViewersList();
        for (std::list<ViewerTab*>::const_iterator it = viewerTabs.begin(); it != viewerTabs.end(); ++it) {
            if ( (*it)->getViewer() == viewer ) {
                setLastSelectedViewer( (*it) );
            }
        }
    }

    bool magnifiedNodeSelected = false;
    if (_imp->_magnifiedNode) {
        magnifiedNodeSelected = std::find(_imp->_selection.begin(),_imp->_selection.end(),_imp->_magnifiedNode)
                                != _imp->_selection.end();
    }
    if (magnifiedNodeSelected && _imp->_magnifOn) {
        _imp->_magnifOn = false;
        _imp->_magnifiedNode->setScale_natron(_imp->_nodeSelectedScaleBeforeMagnif);
    }
}
Exemplo n.º 30
0
void
ViewerTab::abortViewersAndRefresh()
{
    Gui* gui = getGui();
    if (!gui) {
        return;
    }
    const std::list<ViewerTab*> & activeNodes = gui->getViewersList();
    for (std::list<ViewerTab*>::const_iterator it = activeNodes.begin(); it != activeNodes.end(); ++it) {
        ViewerNodePtr viewer = (*it)->getInternalNode();
        if (viewer) {
            ViewerInstancePtr instance = viewer->getInternalViewerNode();
            if (instance) {
                RenderEnginePtr engine = instance->getRenderEngine();
                if ( engine ) {
                    engine->abortRenderingAutoRestart();
                    engine->renderCurrentFrame(false, true);
                }
            }
        }
    }
}