ToolButton* Gui::findOrCreateToolButton(const PluginGroupNodePtr & treeNode) { // Do not create an action for non user creatable plug-ins bool isUserCreatable = true; PluginPtr internalPlugin = treeNode->getPlugin(); if (internalPlugin && treeNode->getChildren().empty() && !internalPlugin->getIsUserCreatable()) { isUserCreatable = false; } if (!isUserCreatable) { return 0; } // Check for existing toolbuttons for (std::size_t i = 0; i < _imp->_toolButtons.size(); ++i) { if (_imp->_toolButtons[i]->getPluginToolButton() == treeNode) { return _imp->_toolButtons[i]; } } // Check for parent toolbutton ToolButton* parentToolButton = NULL; if ( treeNode->getParent() ) { assert(treeNode->getParent() != treeNode); if (treeNode->getParent() != treeNode) { parentToolButton = findOrCreateToolButton( treeNode->getParent() ); } } QString resourcesPath; if (internalPlugin) { resourcesPath = QString::fromUtf8(internalPlugin->getProperty<std::string>(kNatronPluginPropResourcesPath).c_str()); } QString iconFilePath = resourcesPath; StrUtils::ensureLastPathSeparator(iconFilePath); iconFilePath += treeNode->getTreeNodeIconFilePath(); QIcon toolButtonIcon, menuIcon; // Create tool icon if ( !iconFilePath.isEmpty() && QFile::exists(iconFilePath) ) { QPixmap pix(iconFilePath); int menuSize = TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE); int toolButtonSize = !treeNode->getParent() ? TO_DPIX(NATRON_TOOL_BUTTON_ICON_SIZE) : TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE); QPixmap menuPix = pix, toolbuttonPix = pix; if ( (std::max( menuPix.width(), menuPix.height() ) != menuSize) && !menuPix.isNull() ) { menuPix = menuPix.scaled(menuSize, menuSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); } if ( (std::max( toolbuttonPix.width(), toolbuttonPix.height() ) != toolButtonSize) && !toolbuttonPix.isNull() ) { toolbuttonPix = toolbuttonPix.scaled(toolButtonSize, toolButtonSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); } menuIcon.addPixmap(menuPix); toolButtonIcon.addPixmap(toolbuttonPix); } else { // Set default icon only if it has no parent, otherwise leave action without an icon if ( !treeNode->getParent() ) { QPixmap toolbuttonPix, menuPix; getPixmapForGrouping( &toolbuttonPix, TO_DPIX(NATRON_TOOL_BUTTON_ICON_SIZE), treeNode->getTreeNodeName() ); toolButtonIcon.addPixmap(toolbuttonPix); getPixmapForGrouping( &menuPix, TO_DPIX(NATRON_TOOL_BUTTON_ICON_SIZE), treeNode->getTreeNodeName() ); menuIcon.addPixmap(menuPix); } } // If the tool-button has no children, this is a leaf, we must create an action // At this point any plug-in MUST be in a toolbutton, so it must have a parent. assert(!treeNode->getChildren().empty() || treeNode->getParent()); int majorVersion = internalPlugin ? internalPlugin->getProperty<unsigned int>(kNatronPluginPropVersion, 0) : 1; int minorVersion = internalPlugin ? internalPlugin->getProperty<unsigned int>(kNatronPluginPropVersion, 1) : 0; ToolButton* pluginsToolButton = new ToolButton(getApp(), treeNode, treeNode->getTreeNodeID(), majorVersion, minorVersion, treeNode->getTreeNodeName(), toolButtonIcon, menuIcon); if (!treeNode->getChildren().empty()) { // For grouping items, create the menu Menu* menu = new Menu(this); menu->setTitle( pluginsToolButton->getLabel() ); menu->setIcon(menuIcon); pluginsToolButton->setMenu(menu); pluginsToolButton->setAction( menu->menuAction() ); } else { // This is a leaf (plug-in) assert(internalPlugin); assert(parentToolButton); // If this is the highest major version for this plug-in use normal label, otherwise also append the major version bool isHighestMajorVersionForPlugin = internalPlugin->getIsHighestMajorVersion(); std::string pluginLabel = !isHighestMajorVersionForPlugin ? internalPlugin->getLabelVersionMajorEncoded() : internalPlugin->getLabelWithoutSuffix(); QKeySequence defaultNodeShortcut; QString shortcutGroup = QString::fromUtf8(kShortcutGroupNodes); std::vector<std::string> groupingSplit = internalPlugin->getPropertyN<std::string>(kNatronPluginPropGrouping); for (std::size_t j = 0; j < groupingSplit.size(); ++j) { shortcutGroup.push_back( QLatin1Char('/') ); shortcutGroup.push_back(QString::fromUtf8(groupingSplit[j].c_str())); } { // If the plug-in has a shortcut get it std::list<QKeySequence> keybinds = getKeybind(shortcutGroup, QString::fromUtf8(internalPlugin->getPluginID().c_str())); if (!keybinds.empty()) { defaultNodeShortcut = keybinds.front(); } } QAction* defaultPresetAction = new QAction(this); defaultPresetAction->setShortcut(defaultNodeShortcut); defaultPresetAction->setShortcutContext(Qt::WidgetShortcut); defaultPresetAction->setText(QString::fromUtf8(pluginLabel.c_str())); defaultPresetAction->setIcon( pluginsToolButton->getMenuIcon() ); QObject::connect( defaultPresetAction, SIGNAL(triggered()), pluginsToolButton, SLOT(onTriggered()) ); const std::vector<PluginPresetDescriptor>& presets = internalPlugin->getPresetFiles(); if (presets.empty()) { // If the node has no presets, just make an action, otherwise make a menu pluginsToolButton->setAction(defaultPresetAction); } else { Menu* menu = new Menu(this); menu->setTitle( pluginsToolButton->getLabel() ); menu->setIcon(menuIcon); pluginsToolButton->setMenu(menu); pluginsToolButton->setAction( menu->menuAction() ); defaultPresetAction->setText(QString::fromUtf8(pluginLabel.c_str()) + tr(" (Default)")); menu->addAction(defaultPresetAction); for (std::vector<PluginPresetDescriptor>::const_iterator it = presets.begin(); it!=presets.end(); ++it) { QKeySequence presetShortcut; { // If the preset has a shortcut get it std::string shortcutKey = internalPlugin->getPluginID(); shortcutKey += "_preset_"; shortcutKey += it->presetLabel.toStdString(); std::list<QKeySequence> keybinds = getKeybind(shortcutGroup, QString::fromUtf8(shortcutKey.c_str())); if (!keybinds.empty()) { presetShortcut = keybinds.front(); } } QString presetLabel = QString::fromUtf8(pluginLabel.c_str()); presetLabel += QLatin1String(" ("); presetLabel += it->presetLabel; presetLabel += QLatin1String(")"); QAction* presetAction = new QAction(this); QPixmap presetPix; if (getPresetIcon(it->presetFilePath, it->presetIconFile, TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE), &presetPix)) { presetAction->setIcon( presetPix ); } presetAction->setShortcut(presetShortcut); presetAction->setShortcutContext(Qt::WidgetShortcut); presetAction->setText(presetLabel); presetAction->setData(it->presetLabel); QObject::connect( presetAction, SIGNAL(triggered()), pluginsToolButton, SLOT(onTriggered()) ); menu->addAction(presetAction); } } } // if (!treeNode->getChildren().empty()) // If it has a parent, add the new tool button as a child if (parentToolButton) { parentToolButton->tryAddChild(pluginsToolButton); } _imp->_toolButtons.push_back(pluginsToolButton); return pluginsToolButton; } // findOrCreateToolButton
ActionRetCodeEnum RotoShapeRenderNode::getRegionOfDefinition(TimeValue time, const RenderScale& scale, ViewIdx view, RectD* rod) { RotoDrawableItemPtr item = getAttachedRotoItem(); assert(item); assert((isRenderClone() && item->isRenderClone()) || (!isRenderClone() && !item->isRenderClone())); const bool isPainting = isDuringPaintStrokeCreation(); RectD shapeRoD; getRoDFromItem(item, time, view, isPainting, &shapeRoD); bool clipToFormat = _imp->clipToFormatKnob.lock()->getValue(); RotoShapeRenderTypeEnum type = (RotoShapeRenderTypeEnum)_imp->renderType.lock()->getValue(); switch (type) { case eRotoShapeRenderTypeSmear: { RectD defaultRod; ActionRetCodeEnum stat = EffectInstance::getRegionOfDefinition(time, scale, view, &defaultRod); if (isFailureRetCode(stat)) { return stat; } if (!defaultRod.isNull()) { *rod = shapeRoD; rod->merge(defaultRod); } } break; case eRotoShapeRenderTypeSolid: { RotoPaintOutputRoDTypeEnum rodType = (RotoPaintOutputRoDTypeEnum)_imp->outputRoDTypeKnob.lock()->getValue(); switch (rodType) { case eRotoPaintOutputRoDTypeDefault: { *rod = shapeRoD; // No format is set, use the format from the input if (clipToFormat) { EffectInstancePtr inputEffect = getInputRenderEffectAtAnyTimeView(0); if (inputEffect) { RectI outputFormat = inputEffect->getOutputFormat(); RectD outputFormatCanonical; outputFormat.toCanonical_noClipping(scale, inputEffect->getAspectRatio(-1), &outputFormatCanonical); rod->intersect(outputFormatCanonical, rod); } } } break; case eRotoPaintOutputRoDTypeFormat: { KnobIntPtr sizeKnob = _imp->outputFormatSizeKnob.lock(); int w = sizeKnob->getValue(DimIdx(0)); int h = _imp->outputFormatSizeKnob.lock()->getValue(DimIdx(1)); double par = _imp->outputFormatParKnob.lock()->getValue(); RectI pixelFormat; pixelFormat.x1 = pixelFormat.y1 = 0; pixelFormat.x2 = w; pixelFormat.y2 = h; RenderScale renderScale(1.); pixelFormat.toCanonical_noClipping(renderScale, par, rod); if (!clipToFormat) { rod->merge(shapeRoD); } } break; case eRotoPaintOutputRoDTypeProject: { Format f; getApp()->getProject()->getProjectDefaultFormat(&f); f.toCanonical_noClipping(RenderScale(1.), f.getPixelAspectRatio(), rod); if (!clipToFormat) { rod->merge(shapeRoD); } } break; } } break; } return eActionStatusOK; }
// VFALCO NOTE Where's the thread object? It's not a data member... // void run () { // VFALCO TODO replace this with a beast Time object? // // Initialize the clock to the current time. boost::posix_time::ptime t = boost::posix_time::microsec_clock::universal_time (); while (! threadShouldExit ()) { { // VFALCO NOTE What is this lock protecting? ScopedLockType sl (mLock); // VFALCO NOTE I think this is to reduce calls to the operating system // for retrieving the current time. // // TODO Instead of incrementing can't we just retrieve the current // time again? // // Manually update the timer. UptimeTimer::getInstance ().incrementElapsedTime (); // Measure the amount of time we have been deadlocked, in seconds. // // VFALCO NOTE mDeadLock is a canary for detecting the condition. int const timeSpentDeadlocked = UptimeTimer::getInstance ().getElapsedSeconds () - mDeadLock; // VFALCO NOTE I think that "armed" refers to the deadlock detector // int const reportingIntervalSeconds = 10; if (mArmed && (timeSpentDeadlocked >= reportingIntervalSeconds)) { // Report the deadlocked condition every 10 seconds if ((timeSpentDeadlocked % reportingIntervalSeconds) == 0) { logDeadlock (timeSpentDeadlocked); } // If we go over 500 seconds spent deadlocked, it means that the // deadlock resolution code has failed, which qualifies as undefined // behavior. // assert (timeSpentDeadlocked < 500); } } bool change; // VFALCO TODO Eliminate the dependence on the Application object. // Choices include constructing with the job queue / feetracker. // Another option is using an observer pattern to invert the dependency. if (getApp().getJobQueue ().isOverloaded ()) { m_journal.info << getApp().getJobQueue ().getJson (0); change = getApp().getFeeTrack ().raiseLocalFee (); } else { change = getApp().getFeeTrack ().lowerLocalFee (); } if (change) { // VFALCO TODO replace this with a Listener / observer and subscribe in NetworkOPs or Application getApp().getOPs ().reportFeeChange (); } t += boost::posix_time::seconds (1); boost::posix_time::time_duration when = t - boost::posix_time::microsec_clock::universal_time (); if ((when.is_negative ()) || (when.total_seconds () > 1)) { m_journal.warning << "time jump"; t = boost::posix_time::microsec_clock::universal_time (); } else { boost::this_thread::sleep (when); } } stopped (); }
// =========================================================================== // method definitions // =========================================================================== GNETLSEditorFrame::GNETLSEditorFrame(FXComposite* parent, GNEViewNet* viewNet): GNEFrame(parent, viewNet, "Edit Traffic Light"), myTableFont(new FXFont(getApp(), "Courier New", 9)), myCurrentJunction(0), myHaveModifications(false), myEditedDef(0) { // heading myDescription = new FXLabel(myContentFrame, "", 0, JUSTIFY_LEFT); new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4); // create tlDef button new FXButton(myContentFrame, "Create TLS\t\tCreate a new traffic light program", 0, this, MID_GNE_DEF_CREATE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3); // delete tlDef button new FXButton(myContentFrame, "Delete TLS\t\tDelete a traffic light program. If all programs are deleted the junction turns into a priority junction.", 0, this, MID_GNE_DEF_DELETE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3); // definitions list new FXLabel(myContentFrame, "Name, Program"); myDefBox = new FXListBox(myContentFrame, this, MID_GNE_DEF_SWITCH, FRAME_SUNKEN | FRAME_THICK | LISTBOX_NORMAL | LAYOUT_FIX_WIDTH); // offset control new FXLabel(myContentFrame, "Offset"); myOffset = new FXTextField(myContentFrame, 6, this, MID_GNE_DEF_OFFSET, TEXTFIELD_NORMAL | TEXTFIELD_REAL, 0, 0, 0, 0, 4, 2, 0, 2); new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4); // phase table new FXLabel(myContentFrame, "Phases"); myPhaseTable = new FXTable(myContentFrame, this, MID_GNE_PHASE_TABLE, LAYOUT_FIX_HEIGHT | LAYOUT_FIX_WIDTH); myPhaseTable->setColumnHeaderMode(LAYOUT_FIX_HEIGHT); myPhaseTable->setColumnHeaderHeight(0); myPhaseTable->setRowHeaderMode(LAYOUT_FIX_WIDTH); myPhaseTable->setRowHeaderWidth(0); myPhaseTable->hide(); myPhaseTable->setFont(myTableFont); myPhaseTable->setHelpText("phase duration in seconds | phase state"); // total duration info myCycleDuration = new FXLabel(myContentFrame, ""); // insert new phase button new FXButton(myContentFrame, "Copy Phase\t\tInsert duplicate phase after selected phase", 0, this, MID_GNE_PHASE_CREATE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3); // delete phase button new FXButton(myContentFrame, "Delete Phase\t\tDelete selected phase", 0, this, MID_GNE_PHASE_DELETE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3); new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4); // buttons // "Cancel" new FXButton(myContentFrame, "Cancel\t\tDiscard program modifications (Esc)", 0, this, MID_CANCEL, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3); // "OK" new FXButton(myContentFrame, "Save\t\tSave program modifications (Enter)", 0, this, MID_OK, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3); new FXHorizontalSeparator(myContentFrame, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4); // "Add 'off' program" /* new FXButton(myContentFrame, "Add \"Off\"-Program\t\tAdds a program for switching off this traffic light", 0, this, MID_GNE_DEF_ADDOFF, ICON_BEFORE_TEXT|LAYOUT_FILL_X|FRAME_THICK|FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3); */ }
// The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CMyDlg::OnQueryDragIcon() { return (HCURSOR) getApp()->m_hIcon; }
bool TransactionStateSF::haveNode (SHAMapNodeID const& id, uint256 const& nodeHash, Blob& nodeData) { return getApp().getLedgerMaster ().getFetchPack (nodeHash, nodeData); }
FXLinkLabel::FXLinkLabel(FXComposite* p, const FXString& text, FXIcon* ic, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) : FXLabel(p, text, ic, opts, x, y, w, h, pl, pr, pt, pb) { setDefaultCursor(getApp()->getDefaultCursor(DEF_HAND_CURSOR)); setTextColor(FXRGB(0, 0, 255)); }
Handoff OverlayImpl::onHandoff (std::unique_ptr <beast::asio::ssl_bundle>&& ssl_bundle, beast::http::message&& request, endpoint_type remote_endpoint) { auto const id = next_id_++; beast::WrappedSink sink (deprecatedLogs()["Peer"], makePrefix(id)); beast::Journal journal (sink); Handoff handoff; if (processRequest(request, handoff)) return handoff; if (! isPeerUpgrade(request)) return handoff; handoff.moved = true; if (journal.trace) journal.trace << "Peer connection upgrade from " << remote_endpoint; error_code ec; auto const local_endpoint (ssl_bundle->socket.local_endpoint(ec)); if (ec) { if (journal.trace) journal.trace << remote_endpoint << " failed: " << ec.message(); return handoff; } auto consumer = m_resourceManager.newInboundEndpoint( beast::IPAddressConversion::from_asio(remote_endpoint)); if (consumer.disconnect()) return handoff; auto const slot = m_peerFinder->new_inbound_slot ( beast::IPAddressConversion::from_asio(local_endpoint), beast::IPAddressConversion::from_asio(remote_endpoint)); if (slot == nullptr) { // self-connect, close handoff.moved = false; return handoff; } // TODO Validate HTTP request { auto const types = beast::rfc2616::split_commas( request.headers["Connect-As"]); if (std::find_if(types.begin(), types.end(), [](std::string const& s) { return beast::ci_equal(s, "peer"); }) == types.end()) { handoff.moved = false; handoff.response = makeRedirectResponse(slot, request, remote_endpoint.address()); handoff.keep_alive = request.keep_alive(); return handoff; } } handoff.moved = true; bool success = true; protocol::TMHello hello; std::tie(hello, success) = parseHello (request, journal); if(! success) return handoff; uint256 sharedValue; std::tie(sharedValue, success) = makeSharedValue( ssl_bundle->stream.native_handle(), journal); if(! success) return handoff; RippleAddress publicKey; std::tie(publicKey, success) = verifyHello (hello, sharedValue, journal, getApp()); if(! success) return handoff; std::string name; bool const cluster = getApp().getUNL().nodeInCluster( publicKey, name); auto const result = m_peerFinder->activate (slot, publicKey.toPublicKey(), cluster); if (result != PeerFinder::Result::success) { if (journal.trace) journal.trace << "Peer " << remote_endpoint << " redirected, slots full"; handoff.moved = false; handoff.response = makeRedirectResponse(slot, request, remote_endpoint.address()); handoff.keep_alive = request.keep_alive(); return handoff; } auto const peer = std::make_shared<PeerImp>(id, remote_endpoint, slot, std::move(request), hello, publicKey, consumer, std::move(ssl_bundle), *this); { // As we are not on the strand, run() must be called // while holding the lock, otherwise new I/O can be // queued after a call to stop(). std::lock_guard <decltype(mutex_)> lock (mutex_); add(peer); peer->run(); } handoff.moved = true; return handoff; }
void doClean (Json::Value const& params) { LedgerIndex minRange; LedgerIndex maxRange; getApp().getLedgerMaster().getFullValidatedRange (minRange, maxRange); { SharedState::Access state (m_state); state->maxRange = maxRange; state->minRange = minRange; state->checkNodes = false; state->fixTxns = false; state->failures = 0; /* JSON Parameters: All parameters are optional. By default the cleaner cleans things it thinks are necessary. This behavior can be modified using the following options supplied via JSON RPC: "ledger" A single unsigned integer representing an individual ledger to clean. "min_ledger", "max_ledger" Unsigned integers representing the starting and ending ledger numbers to clean. If unspecified, clean all ledgers. "full" A boolean. When set to true, means clean everything possible. "fix_txns" A boolean value indicating whether or not to fix the transactions in the database as well. "check_nodes" A boolean, when set to true means check the nodes. "stop" A boolean, when set to true informs the cleaner to gracefully stop its current activities if any cleaning is taking place. */ // Quick way to fix a single ledger if (params.isMember(jss::ledger)) { state->maxRange = params[jss::ledger].asUInt(); state->minRange = params[jss::ledger].asUInt(); state->fixTxns = true; state->checkNodes = true; } if (params.isMember(jss::max_ledger)) state->maxRange = params[jss::max_ledger].asUInt(); if (params.isMember(jss::min_ledger)) state->minRange = params[jss::min_ledger].asUInt(); if (params.isMember(jss::full)) state->fixTxns = state->checkNodes = params[jss::full].asBool(); if (params.isMember(jss::fix_txns)) state->fixTxns = params[jss::fix_txns].asBool(); if (params.isMember(jss::check_nodes)) state->checkNodes = params[jss::check_nodes].asBool(); if (params.isMember(jss::stop) && params[jss::stop].asBool()) state->minRange = state->maxRange = 0; } notify(); }
PopupMenu getMenuForIndex (int /*topLevelMenuIndex*/, const String& menuName) override { PopupMenu menu; getApp().createMenu (menu, menuName); return menu; }
void menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/) override { getApp().handleMainMenuCommand (menuItemID); }
StringArray getMenuBarNames() override { return getApp().getMenuNames(); }
int getQueryString(HWND hParent, String title, String prompt, String& text) { TextPromptDlgParam param = {title, prompt, &text}; return DialogBoxParam(getApp()->getInstanceHandle(), MAKEINTRESOURCE(IDD_TEXTPROMPT), hParent, TextPromptDlgFunc, (LPARAM) ¶m); }
Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder) { // FIXME: This needs to release the master lock immediately // Subscriptions need to be protected by their own lock InfoSub::pointer ispSub; Json::Value jvResult (Json::objectValue); std::uint32_t uLedgerIndex = params.isMember (jss::ledger_index) && params[jss::ledger_index].isNumeric () ? params[jss::ledger_index].asUInt () : 0; if (!mInfoSub && !params.isMember ("url")) { // Must be a JSON-RPC call. WriteLog (lsINFO, RPCHandler) << boost::str (boost::format ("doSubscribe: RPC subscribe requires a url")); return rpcError (rpcINVALID_PARAMS); } if (params.isMember ("url")) { if (mRole != Config::ADMIN) return rpcError (rpcNO_PERMISSION); std::string strUrl = params["url"].asString (); std::string strUsername = params.isMember ("url_username") ? params["url_username"].asString () : ""; std::string strPassword = params.isMember ("url_password") ? params["url_password"].asString () : ""; // DEPRECATED if (params.isMember ("username")) strUsername = params["username"].asString (); // DEPRECATED if (params.isMember ("password")) strPassword = params["password"].asString (); ispSub = mNetOps->findRpcSub (strUrl); if (!ispSub) { WriteLog (lsDEBUG, RPCHandler) << boost::str (boost::format ("doSubscribe: building: %s") % strUrl); RPCSub::pointer rspSub = RPCSub::New (getApp ().getOPs (), getApp ().getIOService (), getApp ().getJobQueue (), strUrl, strUsername, strPassword); ispSub = mNetOps->addRpcSub (strUrl, boost::dynamic_pointer_cast<InfoSub> (rspSub)); } else { WriteLog (lsTRACE, RPCHandler) << boost::str (boost::format ("doSubscribe: reusing: %s") % strUrl); if (params.isMember ("username")) dynamic_cast<RPCSub*> (&*ispSub)->setUsername (strUsername); if (params.isMember ("password")) dynamic_cast<RPCSub*> (&*ispSub)->setPassword (strPassword); } } else { ispSub = mInfoSub; } if (!params.isMember ("streams")) { nothing (); } else if (!params["streams"].isArray ()) { WriteLog (lsINFO, RPCHandler) << boost::str (boost::format ("doSubscribe: streams requires an array.")); return rpcError (rpcINVALID_PARAMS); } else { for (Json::Value::iterator it = params["streams"].begin (); it != params["streams"].end (); it++) { if ((*it).isString ()) { std::string streamName = (*it).asString (); if (streamName == "server") { mNetOps->subServer (ispSub, jvResult); } else if (streamName == "ledger") { mNetOps->subLedger (ispSub, jvResult); } else if (streamName == "transactions") { mNetOps->subTransactions (ispSub); } else if (streamName == "transactions_rt" ) { mNetOps->subRTTransactions (ispSub); } else { jvResult[jss::error] = "unknownStream"; } } else { jvResult[jss::error] = "malformedStream"; } } } std::string strAccountsProposed = params.isMember ("accounts_rt") ? "accounts_proposed" : "rt_accounts"; // DEPRECATED if (!params.isMember (strAccountsProposed)) { nothing (); } else if (!params[strAccountsProposed].isArray ()) { return rpcError (rpcINVALID_PARAMS); } else { boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (params[strAccountsProposed]); if (usnaAccoundIds.empty ()) { jvResult[jss::error] = "malformedAccount"; } else { mNetOps->subAccount (ispSub, usnaAccoundIds, uLedgerIndex, true); } } if (!params.isMember ("accounts")) { nothing (); } else if (!params["accounts"].isArray ()) { return rpcError (rpcINVALID_PARAMS); } else { boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (params["accounts"]); if (usnaAccoundIds.empty ()) { jvResult[jss::error] = "malformedAccount"; } else { mNetOps->subAccount (ispSub, usnaAccoundIds, uLedgerIndex, false); WriteLog (lsDEBUG, RPCHandler) << boost::str (boost::format ("doSubscribe: accounts: %d") % usnaAccoundIds.size ()); } } bool bHaveMasterLock = true; if (!params.isMember ("books")) { nothing (); } else if (!params["books"].isArray ()) { return rpcError (rpcINVALID_PARAMS); } else { for (Json::Value::iterator it = params["books"].begin (); it != params["books"].end (); it++) { Json::Value& jvSubRequest = *it; if (!jvSubRequest.isObject () || !jvSubRequest.isMember (jss::taker_pays) || !jvSubRequest.isMember (jss::taker_gets) || !jvSubRequest[jss::taker_pays].isObject () || !jvSubRequest[jss::taker_gets].isObject ()) return rpcError (rpcINVALID_PARAMS); // VFALCO TODO Use RippleAsset here RippleCurrency pay_currency; RippleIssuer pay_issuer; RippleCurrency get_currency; RippleIssuer get_issuer; bool bBoth = (jvSubRequest.isMember ("both") && jvSubRequest["both"].asBool ()) || (jvSubRequest.isMember ("both_sides") && jvSubRequest["both_sides"].asBool ()); // DEPRECATED bool bSnapshot = (jvSubRequest.isMember ("snapshot") && jvSubRequest["snapshot"].asBool ()) || (jvSubRequest.isMember ("state_now") && jvSubRequest["state_now"].asBool ()); // DEPRECATED Json::Value taker_pays = jvSubRequest[jss::taker_pays]; Json::Value taker_gets = jvSubRequest[jss::taker_gets]; // Parse mandatory currency. if (!taker_pays.isMember (jss::currency) || !STAmount::currencyFromString (pay_currency, taker_pays[jss::currency].asString ())) { WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError (rpcSRC_CUR_MALFORMED); } // Parse optional issuer. else if (((taker_pays.isMember (jss::issuer)) && (!taker_pays[jss::issuer].isString () || !STAmount::issuerFromString (pay_issuer, taker_pays[jss::issuer].asString ()))) // Don't allow illegal issuers. || (!pay_currency != !pay_issuer) || ACCOUNT_ONE == pay_issuer) { WriteLog (lsINFO, RPCHandler) << "Bad taker_pays issuer."; return rpcError (rpcSRC_ISR_MALFORMED); } // Parse mandatory currency. if (!taker_gets.isMember (jss::currency) || !STAmount::currencyFromString (get_currency, taker_gets[jss::currency].asString ())) { WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError (rpcSRC_CUR_MALFORMED); } // Parse optional issuer. else if (((taker_gets.isMember (jss::issuer)) && (!taker_gets[jss::issuer].isString () || !STAmount::issuerFromString (get_issuer, taker_gets[jss::issuer].asString ()))) // Don't allow illegal issuers. || (!get_currency != !get_issuer) || ACCOUNT_ONE == get_issuer) { WriteLog (lsINFO, RPCHandler) << "Bad taker_gets issuer."; return rpcError (rpcDST_ISR_MALFORMED); } if (pay_currency == get_currency && pay_issuer == get_issuer) { WriteLog (lsINFO, RPCHandler) << "taker_gets same as taker_pays."; return rpcError (rpcBAD_MARKET); } RippleAddress raTakerID; if (!jvSubRequest.isMember ("taker")) { raTakerID.setAccountID (ACCOUNT_ONE); } else if (!raTakerID.setAccountID (jvSubRequest["taker"].asString ())) { return rpcError (rpcBAD_ISSUER); } if (!Ledger::isValidBook (pay_currency, pay_issuer, get_currency, get_issuer)) { WriteLog (lsWARNING, RPCHandler) << "Bad market: " << pay_currency << ":" << pay_issuer << " -> " << get_currency << ":" << get_issuer; return rpcError (rpcBAD_MARKET); } mNetOps->subBook (ispSub, pay_currency, get_currency, pay_issuer, get_issuer); if (bBoth) mNetOps->subBook (ispSub, get_currency, pay_currency, get_issuer, pay_issuer); if (bSnapshot) { if (bHaveMasterLock) { masterLockHolder.unlock (); bHaveMasterLock = false; } bool verbose = false; if (jvSubRequest.isMember("verbose")) verbose = true; loadType = Resource::feeMediumBurdenRPC; Ledger::pointer lpLedger = getApp().getLedgerMaster ().getPublishedLedger (); if (lpLedger) { const Json::Value jvMarker = Json::Value (Json::nullValue); if (bBoth) { Json::Value jvBids (Json::objectValue); Json::Value jvAsks (Json::objectValue); mNetOps->getBookPage (lpLedger, pay_currency, pay_issuer, get_currency, get_issuer, raTakerID.getAccountID (), false, verbose, 0, jvMarker, jvBids); if (jvBids.isMember (jss::offers)) jvResult[jss::bids] = jvBids[jss::offers]; mNetOps->getBookPage(lpLedger, get_currency, get_issuer, pay_currency, pay_issuer, raTakerID.getAccountID(), false, verbose, 0, jvMarker, jvAsks); if (jvAsks.isMember (jss::offers)) jvResult[jss::asks] = jvAsks[jss::offers]; } else { mNetOps->getBookPage(lpLedger, pay_currency, pay_issuer, get_currency, get_issuer, raTakerID.getAccountID(), false, verbose, 0, jvMarker, jvResult); } } } } } return jvResult; }
Json::Value RPCHandler::doStop (Json::Value, Resource::Charge& loadType, Application::ScopedLockType& masterLockHolder) { getApp().signalStop (); return SYSTEM_NAME " server stopping"; }
/** Run the ledger cleaner. */ void doLedgerCleaner() { Ledger::pointer goodLedger; while (! this->threadShouldExit()) { LedgerIndex ledgerIndex; LedgerHash ledgerHash; bool doNodes; bool doTxns; while (getApp().getFeeTrack().isLoadedLocal()) { m_journal.debug << "Waiting for load to subside"; std::this_thread::sleep_for(std::chrono::seconds(5)); if (this->threadShouldExit ()) return; } { SharedState::Access state (m_state); if ((state->minRange > state->maxRange) || (state->maxRange == 0) || (state->minRange == 0)) { state->minRange = state->maxRange = 0; return; } ledgerIndex = state->maxRange; doNodes = state->checkNodes; doTxns = state->fixTxns; } ledgerHash = getHash(ledgerIndex, goodLedger); bool fail = false; if (ledgerHash.isZero()) { m_journal.info << "Unable to get hash for ledger " << ledgerIndex; fail = true; } else if (!doLedger(ledgerIndex, ledgerHash, doNodes, doTxns)) { m_journal.info << "Failed to process ledger " << ledgerIndex; fail = true; } if (fail) { { SharedState::Access state (m_state); ++state->failures; } // Wait for acquiring to catch up to us std::this_thread::sleep_for(std::chrono::seconds(2)); } else { { SharedState::Access state (m_state); if (ledgerIndex == state->minRange) ++state->minRange; if (ledgerIndex == state->maxRange) --state->maxRange; state->failures = 0; } // Reduce I/O pressure and wait for acquiring to catch up to us std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } }
Json::Value doBookOffers (RPC::Context& context) { // VFALCO TODO Here is a terrible place for this kind of business // logic. It needs to be moved elsewhere and documented, // and encapsulated into a function. if (getApp().getJobQueue ().getJobCountGE (jtCLIENT) > 200) return rpcError (rpcTOO_BUSY); std::shared_ptr<ReadView const> lpLedger; auto jvResult = RPC::lookupLedger (lpLedger, context); if (!lpLedger) return jvResult; if (!context.params.isMember (jss::taker_pays)) return RPC::missing_field_error (jss::taker_pays); if (!context.params.isMember (jss::taker_gets)) return RPC::missing_field_error (jss::taker_gets); if (!context.params[jss::taker_pays].isObject ()) return RPC::object_field_error (jss::taker_pays); if (!context.params[jss::taker_gets].isObject ()) return RPC::object_field_error (jss::taker_gets); Json::Value const& taker_pays (context.params[jss::taker_pays]); if (!taker_pays.isMember (jss::currency)) return RPC::missing_field_error ("taker_pays.currency"); if (! taker_pays [jss::currency].isString ()) return RPC::expected_field_error ("taker_pays.currency", "string"); Json::Value const& taker_gets = context.params[jss::taker_gets]; if (! taker_gets.isMember (jss::currency)) return RPC::missing_field_error ("taker_gets.currency"); if (! taker_gets [jss::currency].isString ()) return RPC::expected_field_error ("taker_gets.currency", "string"); Currency pay_currency; if (!to_currency (pay_currency, taker_pays [jss::currency].asString ())) { WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return RPC::make_error (rpcSRC_CUR_MALFORMED, "Invalid field 'taker_pays.currency', bad currency."); } Currency get_currency; if (!to_currency (get_currency, taker_gets [jss::currency].asString ())) { WriteLog (lsINFO, RPCHandler) << "Bad taker_gets currency."; return RPC::make_error (rpcDST_AMT_MALFORMED, "Invalid field 'taker_gets.currency', bad currency."); } AccountID pay_issuer; if (taker_pays.isMember (jss::issuer)) { if (! taker_pays [jss::issuer].isString()) return RPC::expected_field_error ("taker_pays.issuer", "string"); if (!to_issuer( pay_issuer, taker_pays [jss::issuer].asString ())) return RPC::make_error (rpcSRC_ISR_MALFORMED, "Invalid field 'taker_pays.issuer', bad issuer."); if (pay_issuer == noAccount ()) return RPC::make_error (rpcSRC_ISR_MALFORMED, "Invalid field 'taker_pays.issuer', bad issuer account one."); } else { pay_issuer = xrpAccount (); } if (isXRP (pay_currency) && ! isXRP (pay_issuer)) return RPC::make_error ( rpcSRC_ISR_MALFORMED, "Unneeded field 'taker_pays.issuer' for " "XRP currency specification."); if (!isXRP (pay_currency) && isXRP (pay_issuer)) return RPC::make_error (rpcSRC_ISR_MALFORMED, "Invalid field 'taker_pays.issuer', expected non-XRP issuer."); AccountID get_issuer; if (taker_gets.isMember (jss::issuer)) { if (! taker_gets [jss::issuer].isString()) return RPC::expected_field_error ("taker_gets.issuer", "string"); if (! to_issuer ( get_issuer, taker_gets [jss::issuer].asString ())) return RPC::make_error (rpcDST_ISR_MALFORMED, "Invalid field 'taker_gets.issuer', bad issuer."); if (get_issuer == noAccount ()) return RPC::make_error (rpcDST_ISR_MALFORMED, "Invalid field 'taker_gets.issuer', bad issuer account one."); } else { get_issuer = xrpAccount (); } if (isXRP (get_currency) && ! isXRP (get_issuer)) return RPC::make_error (rpcDST_ISR_MALFORMED, "Unneeded field 'taker_gets.issuer' for " "XRP currency specification."); if (!isXRP (get_currency) && isXRP (get_issuer)) return RPC::make_error (rpcDST_ISR_MALFORMED, "Invalid field 'taker_gets.issuer', expected non-XRP issuer."); boost::optional<AccountID> takerID; if (context.params.isMember (jss::taker)) { if (! context.params [jss::taker].isString ()) return RPC::expected_field_error (jss::taker, "string"); takerID = parseBase58<AccountID>( context.params [jss::taker].asString()); if (! takerID) return RPC::invalid_field_error (jss::taker); } if (pay_currency == get_currency && pay_issuer == get_issuer) { WriteLog (lsINFO, RPCHandler) << "taker_gets same as taker_pays."; return RPC::make_error (rpcBAD_MARKET); } unsigned int iLimit; if (context.params.isMember (jss::limit)) { auto const& jvLimit (context.params[jss::limit]); if (! jvLimit.isIntegral ()) return RPC::expected_field_error (jss::limit, "unsigned integer"); iLimit = jvLimit.isUInt () ? jvLimit.asUInt () : std::max (0, jvLimit.asInt ()); } else { iLimit = 0; } bool const bProof (context.params.isMember (jss::proof)); Json::Value const jvMarker (context.params.isMember (jss::marker) ? context.params[jss::marker] : Json::Value (Json::nullValue)); context.netOps.getBookPage ( context.role == Role::ADMIN, lpLedger, {{pay_currency, pay_issuer}, {get_currency, get_issuer}}, takerID ? *takerID : zero, bProof, iLimit, jvMarker, jvResult); context.loadType = Resource::feeMediumBurdenRPC; return jvResult; }
// This interface is deprecated. Json::Value doRipplePathFind (RPC::Context& context) { RPC::LegacyPathFind lpf (context.role == Role::ADMIN); if (!lpf.isOk ()) return rpcError (rpcTOO_BUSY); context.loadType = Resource::feeHighBurdenRPC; RippleAddress raSrc; RippleAddress raDst; STAmount saDstAmount; Ledger::pointer lpLedger; Json::Value jvResult; if (getConfig().RUN_STANDALONE || context.params.isMember(jss::ledger) || context.params.isMember(jss::ledger_index) || context.params.isMember(jss::ledger_hash)) { // The caller specified a ledger jvResult = RPC::lookupLedger ( context.params, lpLedger, context.netOps); if (!lpLedger) return jvResult; } if (!context.params.isMember (jss::source_account)) { jvResult = rpcError (rpcSRC_ACT_MISSING); } else if (!context.params[jss::source_account].isString () || !raSrc.setAccountID ( context.params[jss::source_account].asString ())) { jvResult = rpcError (rpcSRC_ACT_MALFORMED); } else if (!context.params.isMember (jss::destination_account)) { jvResult = rpcError (rpcDST_ACT_MISSING); } else if (!context.params[jss::destination_account].isString () || !raDst.setAccountID ( context.params[jss::destination_account].asString ())) { jvResult = rpcError (rpcDST_ACT_MALFORMED); } else if ( // Parse saDstAmount. !context.params.isMember (jss::destination_amount) || ! amountFromJsonNoThrow(saDstAmount, context.params[jss::destination_amount]) || saDstAmount <= zero || (!isXRP(saDstAmount.getCurrency ()) && (!saDstAmount.getIssuer () || noAccount() == saDstAmount.getIssuer ()))) { WriteLog (lsINFO, RPCHandler) << "Bad destination_amount."; jvResult = rpcError (rpcINVALID_PARAMS); } else if ( // Checks on source_currencies. context.params.isMember (jss::source_currencies) && (!context.params[jss::source_currencies].isArray () || !context.params[jss::source_currencies].size ()) // Don't allow empty currencies. ) { WriteLog (lsINFO, RPCHandler) << "Bad source_currencies."; jvResult = rpcError (rpcINVALID_PARAMS); } else { context.loadType = Resource::feeHighBurdenRPC; RippleLineCache::pointer cache; if (lpLedger) { // The caller specified a ledger lpLedger = std::make_shared<Ledger> (std::ref (*lpLedger), false); cache = std::make_shared<RippleLineCache>(lpLedger); } else { // The closed ledger is recent and any nodes made resident // have the best chance to persist lpLedger = context.netOps.getClosedLedger(); cache = getApp().getPathRequests().getLineCache(lpLedger, false); } Json::Value jvSrcCurrencies; if (context.params.isMember (jss::source_currencies)) { jvSrcCurrencies = context.params[jss::source_currencies]; } else { jvSrcCurrencies = buildSrcCurrencies(raSrc, cache); } // Fill in currencies destination will accept Json::Value jvDestCur (Json::arrayValue); // TODO(tom): this could be optimized the same way that // PathRequest::doUpdate() is - if we don't obsolete this code first. auto usDestCurrID = accountDestCurrencies (raDst, cache, true); for (auto const& uCurrency: usDestCurrID) jvDestCur.append (to_string (uCurrency)); jvResult[jss::destination_currencies] = jvDestCur; jvResult[jss::destination_account] = raDst.humanAccountID (); int level = getConfig().PATH_SEARCH_OLD; if ((getConfig().PATH_SEARCH_MAX > level) && !getApp().getFeeTrack().isLoadedLocal()) { ++level; } if (context.params.isMember(jss::search_depth) && context.params[jss::search_depth].isIntegral()) { int rLev = context.params[jss::search_depth].asInt (); if ((rLev < level) || (context.role == Role::ADMIN)) level = rLev; } auto contextPaths = context.params.isMember(jss::paths) ? boost::optional<Json::Value>(context.params[jss::paths]) : boost::optional<Json::Value>(boost::none); auto pathFindResult = ripplePathFind(cache, raSrc, raDst, saDstAmount, lpLedger, jvSrcCurrencies, contextPaths, level); if (!pathFindResult.first) return pathFindResult.second; // Each alternative differs by source currency. jvResult[jss::alternatives] = pathFindResult.second; } WriteLog (lsDEBUG, RPCHandler) << boost::str (boost::format ("ripple_path_find< %s") % jvResult); return jvResult; }
long FXLinkLabel::onTimer(FXObject*, FXSelector, void*) { getApp()->endWaitCursor(); return 1; }
App* Server::getCurrentApp() { return getApp(Remote::Instance()->lastCommand->source); }
FXLinkLabel::~FXLinkLabel() { getApp()->removeTimeout(this, ID_TIMER); }
void GMSourceView::saveSettings(const FXString & key) const { getApp()->reg().writeBoolEntry(key.text(),"source-list-sort-reverse",sourcelist->getSortFunc()==source_list_sort_reverse); getApp()->reg().writeBoolEntry(key.text(),"source-list",getParent()->shown()); }
// Construct from components Foam::viewer::viewer(FXApp * a, IOdictionary& mD, Foam::Time& runTime) : FXMainWindow(a,"simpleViewer",NULL,NULL,DECOR_ALL,0,0,800,600) { geometry_ = new blockGeom(mD); menubar_=new FXMenuBar(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X); font_ = a->getNormalFont(); font_->create(); frame_=new FXHorizontalFrame ( this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0 ); glpanel_=new FXVerticalFrame ( frame_, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y |LAYOUT_TOP|LAYOUT_LEFT, 0,0,100,100, 0,0,0,0 ); glvisual_=new FXGLVisual(getApp(),VISUAL_DOUBLEBUFFER|VISUAL_STEREO); glviewer_=new FXGLViewer ( glpanel_, glvisual_, this, ID_CANVAS,LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT, 0,0,100,100 ); glviewer_->setBackgroundColor(FXVec4f(1.0,1.0,1.0,0.0)); scene_=new FXGLGroup; scene_->append(geometry_->displayVertices(font_)); scene_->append(geometry_->displayBlocks()); scene_->append(axes()); glviewer_->setScene(scene_); // File Menu filemenu_ = new FXMenuPane(this); filemenuQuit_ = new FXMenuCommand ( filemenu_, "&Quit\tCtl-Q", NULL, getApp(), FXApp::ID_QUIT ); parallelProj_ = new FXMenuRadio ( filemenu_, "Parallel projection", this, viewer::ID_PARALLEL ); perspectiveProj_ = new FXMenuRadio ( filemenu_, "Perspective projection", this, viewer::ID_PERSPECTIVE ); glviewer_->setProjection(FXGLViewer::PERSPECTIVE); parallelProj_->setCheck(FALSE); perspectiveProj_->setCheck(TRUE); filemenuTitle_ = new FXMenuTitle(menubar_,"&Actions",NULL,filemenu_); printIt_ = new FXButton ( menubar_, "&Print screen\tCtrl-p", NULL, this, viewer::ID_PRINT ); }
void GMSourceView::saveView() const { saveSettings("window"); if (source) { getApp()->reg().writeStringEntry("window","source-list-current",source->settingKey().text()); } }
ActionRetCodeEnum RotoShapeRenderNode::getTimeInvariantMetadata(NodeMetadata& metadata) { assert(_imp->renderType.lock()); RotoShapeRenderTypeEnum type = (RotoShapeRenderTypeEnum)_imp->renderType.lock()->getValue(); int nComps; if (type == eRotoShapeRenderTypeSolid) { // If there's an input to the RotoShapeRender node, pass-through the meta-data number of components so that downstream nodes // have a good default color plane. // E.g: if we have Constant--> RotoShapeRender --> Merge, we want the Merge to have the number of components of the Constant EffectInstancePtr inputEffect = getInputRenderEffectAtAnyTimeView(0); if (inputEffect) { ImagePlaneDesc inputPlane, paireInputPlane; inputEffect->getMetadataComponents(-1, &inputPlane, &paireInputPlane); nComps = inputPlane.getNumComponents(); } else { nComps = 1; } } else { nComps = 4; } metadata.setColorPlaneNComps(-1, nComps); metadata.setColorPlaneNComps(0, nComps); // The roto can be sampled at any non integer time metadata.setIsContinuous(true); RotoPaintOutputRoDTypeEnum rodType = (RotoPaintOutputRoDTypeEnum)_imp->outputRoDTypeKnob.lock()->getValue(); switch (rodType) { case eRotoPaintOutputRoDTypeDefault: // No format is set break; case eRotoPaintOutputRoDTypeFormat: { KnobIntPtr sizeKnob = _imp->outputFormatSizeKnob.lock(); int w = sizeKnob->getValue(DimIdx(0)); int h = _imp->outputFormatSizeKnob.lock()->getValue(DimIdx(1)); double par = _imp->outputFormatParKnob.lock()->getValue(); RectI pixelFormat; pixelFormat.x1 = pixelFormat.y1 = 0; pixelFormat.x2 = w; pixelFormat.y2 = h; metadata.setPixelAspectRatio(-1, par); metadata.setOutputFormat(pixelFormat); } break; case eRotoPaintOutputRoDTypeProject: { Format f; getApp()->getProject()->getProjectDefaultFormat(&f); metadata.setPixelAspectRatio(-1, f.getPixelAspectRatio()); metadata.setOutputFormat(f); } break; } return eActionStatusOK; }
static void parseWindow(){ // option defaults bool fullScreen = false; // should it be fullscreen? bool disabled = false; // what size? (default is fit around widgets. Ignored for fullscreen.) int width=-1,height=-1; // if set, move the window to a screen of the given dimensions int swidth=-1,sheight=-1; // title if any char title[256]; // "tab" number - used to generate a shortcut to pull this window // to the front int number=-1; title[0]=0; int screensetline=-1; // set this window to not inverse ConfigManager::inverse=false; // get window options bool done = false; while(!done){ switch(tok.getnext()){ case T_OCURLY: done = true; break; case T_TITLE: tok.getnextstring(title); break; case T_NUMBER: number = tok.getnextint(); break; case T_INVERSE: ConfigManager::inverse=true; break; case T_FULLSCREEN: fullScreen = true; break; case T_SIZE: // size of window if not fullscreen width = tok.getnextint(); tok.getnextcheck(T_COMMA); height = tok.getnextint(); break; case T_SCREEN: // move to a screen of given dimensions swidth = tok.getnextint(); tok.getnextcheck(T_COMMA); screensetline = tok.getline(); sheight = tok.getnextint(); break; case T_DISABLE: // the window is disabled and should be immediately closed disabled=true; break; } } // create a window Window *w = getApp()->createWindow(); if(number>=0) getApp()->setWindowKey(number,w); ConfigManager::setStyle(w); // and parse the contents parseContainer(w->centralWidget()); if(*title){ w->setWindowTitle(title); } // move the window if we want to if(swidth>0){ QDesktopWidget *dt = QApplication::desktop(); QRect r; int i; for(i=0;i<dt->screenCount();i++){ r = dt->screenGeometry(i); printf("Found display : %d x %d\n",r.width(),r.height()); if(r.width() == swidth && r.height()==sheight) break; } if(i==dt->screenCount()) throw Exception(screensetline).set("could not find display of %d x %d",swidth,sheight); w->move(r.topLeft()); } // finally show the window and resize if required if(disabled){ w->hide(); // marked "disabled" in the config } else { w->setWindowState(Qt::WindowActive); w->raise(); w->activateWindow(); if(fullScreen){ w->showFullScreen(); } else { if(width>0) w->resize(width,height); w->showNormal(); } } }
void AmendmentTableImpl::reportValidations (const AmendmentSet& set) { if (set.mTrustedValidations == 0) return; int threshold = (set.mTrustedValidations * mMajorityFraction) / 256; typedef std::map<uint256, int>::value_type u256_int_pair; ScopedLockType sl (mLock); if (m_firstReport == 0) m_firstReport = set.mCloseTime; std::vector<uint256> changedAmendments; changedAmendments.resize(set.mVotes.size()); for (auto const& e : set.mVotes) { AmendmentState& state = m_amendmentMap[e.first]; if (m_journal.debug) m_journal.debug << "Amendment " << to_string (e.first) << " has " << e.second << " votes, needs " << threshold; if (e.second >= threshold) { // we have a majority state.m_lastMajority = set.mCloseTime; if (state.m_firstMajority == 0) { if (m_journal.warning) m_journal.warning << "Amendment " << to_string (e.first) << " attains a majority vote"; state.m_firstMajority = set.mCloseTime; changedAmendments.push_back(e.first); } } else // we have no majority { if (state.m_firstMajority != 0) { if (m_journal.warning) m_journal.warning << "Amendment " << to_string (e.first) << " loses majority vote"; state.m_firstMajority = 0; state.m_lastMajority = 0; changedAmendments.push_back(e.first); } } } m_lastReport = set.mCloseTime; if (!changedAmendments.empty()) { auto sl (getApp().getWalletDB ().lock ()); auto db = getApp().getWalletDB ().getDB (); // db->executeSQL ("BEGIN TRANSACTION;"); db->beginTransaction(); for (auto const& hash : changedAmendments) { AmendmentState& fState = m_amendmentMap[hash]; db->executeSQL (boost::str (boost::format ( "UPDATE Features SET FirstMajority = %d WHERE Hash = '%s';") % fState.m_firstMajority % to_string (hash))); db->executeSQL (boost::str (boost::format ( "UPDATE Features SET LastMajority = %d WHERE Hash = '%s';") % fState.m_lastMajority % to_string(hash))); } // db->executeSQL ("END TRANSACTION;"); db->endTransaction(); changedAmendments.clear(); } }
void Viewport::init(FXComposite* p, FXGLVisual *vis, const char* title, bool bottomToolbar) { PM = PatchMgr::getInstance(); FXVerticalFrame *vf = new FXVerticalFrame(p, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN); vf->setPadLeft(0); vf->setPadTop(0); vf->setPadRight(0); vf->setPadBottom(0); vf->setHSpacing(0); vf->setVSpacing(0); if (bottomToolbar) reparent(vf); sideToolbar = new FXHorizontalFrame(vf,LAYOUT_SIDE_TOP|LAYOUT_FILL_X,0,0,0,0, 0,0,0,0, 0,0); if (!bottomToolbar) reparent(vf); new FXLabel(sideToolbar,title,NULL,LAYOUT_LEFT); butCPoints = new FXToggleButton(sideToolbar,"\tPunti di controllo\tMostra o nasconde tutti i punti di controllo.", NULL, new FXGIFIcon(getApp(),IconCpoints_off), new FXGIFIcon(getApp(),IconCpoints), this, ID_CONTROL_POINTS ,FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butCPolygon = new FXToggleButton(sideToolbar,"\tPoligono di controllo\tMostra o nasconde tutti i poligoni di controllo.", NULL, new FXGIFIcon(getApp(),IconCpoly_off),new FXGIFIcon(getApp(),IconCpoly), this, ID_CONTROL_POLYGON,FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butPatch = new FXToggleButton(sideToolbar,"\tSuperficie Patch\tMostra o nasconde la superficie di tutte le patch.", NULL, new FXGIFIcon(getApp(),IconDpatch_off), new FXGIFIcon(getApp(),IconDpatch), this,ID_PATCH,FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); TOOLBAR_SEPARATOR(sideToolbar); butSnapToGrid = new FXToggleButton(sideToolbar,"\tBlocca alla grigla\tSe attivato permette di muovere i punti solo lungo la griglia.", NULL, new FXGIFIcon(getApp(),IconSnap_off), new FXGIFIcon(getApp(),IconSnap), this,ID_SNAP,FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butCullFace = new FXToggleButton(sideToolbar,"\tCull faces\tSe attivato rimuove le facce posteriori.", NULL, new FXGIFIcon(getApp(),IconCull_off), new FXGIFIcon(getApp(),IconCull), this, ID_CULL, FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butGridMinus = new FXToggleButton(sideToolbar,"\tDiminuisci griglia\tDiminuisce la tassellazione della griglia.", NULL, new FXGIFIcon(getApp(),IconMinus), new FXGIFIcon(getApp(),IconMinus), this, ID_GRID_MINUS, FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butGridPlus = new FXToggleButton(sideToolbar,"\tAumenta griglia\tAumenta la tassellazione della griglia.", NULL, new FXGIFIcon(getApp(),IconPlus), new FXGIFIcon(getApp(),IconPlus), this, ID_GRID_PLUS, FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butSolid = new FXToggleButton(sideToolbar,"\tMostra la patch piena o in wireframe\tMostra la patch piena o in wireframe.", NULL, new FXGIFIcon(getApp(),IconSolid_off), new FXGIFIcon(getApp(),IconSolid), this, ID_SOLID, FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butTexture = new FXToggleButton(sideToolbar,"\tMostra o nasconde le textures\tMostra o nasconde le textures.", NULL, new FXGIFIcon(getApp(),IconTex_off), new FXGIFIcon(getApp(),IconTex), this, ID_TEXTURE, FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butShowGrid = new FXToggleButton(sideToolbar,"\tMostra o nasconde la griglia\tMostra o nasconde la griglia.", NULL, new FXGIFIcon(getApp(),IconGrid_off), new FXGIFIcon(getApp(),IconGrid), this, ID_SHOW_GRID, FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); TOOLBAR_SEPARATOR(sideToolbar); butCameraTrackball = new FXToggleButton(sideToolbar,"\tTrackball\tControllo telecamera con trackball.", "\tTelecamera\tControllo telecamera libero.", new FXGIFIcon(getApp(),IconTrackball),new FXGIFIcon(getApp(),IconCam), this, ID_CAMERA_TRACKBALL,FRAME_RAISED|LAYOUT_TOP|LAYOUT_RIGHT|TOGGLEBUTTON_TOOLBAR); butCullFace->hide(); butShowGrid->hide(); butSolid->hide(); butTexture->hide(); butCameraTrackball->hide(); dragCursor = getApp()->getDefaultCursor(DEF_CROSSHAIR_CURSOR); Operation = OP_IDLE; Tool = TOOL_SELECTOR; reproject = true; LeftBtn = false; RightBtn = false; zoom = 50.0f; xpos = 0.0f; ypos = 0.0f; gridSize = 1.0f; }
bool AccountStateSF::haveNode (SHAMapNode const& id, uint256 const& nodeHash, Blob& nodeData) { return getApp().getOPs ().getFetchPack (nodeHash, nodeData); }
void Gui::removeViewerTab(ViewerTab* tab, bool initiatedFromNode, bool deleteData) { assert(tab); unregisterTab(tab); if (tab == _imp->_activeViewer) { _imp->_activeViewer = 0; } NodeGraph* graph = 0; NodeGroupPtr isGrp; NodeCollectionPtr collection; if ( tab->getInternalNode() && tab->getInternalNode()->getNode() ) { NodeCollectionPtr collection = tab->getInternalNode()->getNode()->getGroup(); isGrp = toNodeGroup(collection); } if (isGrp) { NodeGraphI* graph_i = isGrp->getNodeGraph(); assert(graph_i); graph = dynamic_cast<NodeGraph*>(graph_i); } else { graph = getNodeGraph(); } assert(graph); if (!graph) { throw std::logic_error(""); } ViewerTab* lastSelectedViewer = graph->getLastSelectedViewer(); if (lastSelectedViewer == tab) { bool foundOne = false; NodesList nodes; if (collection) { nodes = collection->getNodes(); } for (NodesList::iterator it = nodes.begin(); it != nodes.end(); ++it) { ViewerNodePtr isViewer = (*it)->isEffectViewerNode(); if ( !isViewer || ( isViewer == tab->getInternalNode() ) || !(*it)->isActivated() ) { continue; } OpenGLViewerI* viewerI = isViewer->getUiContext(); assert(viewerI); ViewerGL* glViewer = dynamic_cast<ViewerGL*>(viewerI); assert(glViewer); if (glViewer) { graph->setLastSelectedViewer( glViewer->getViewerTab() ); } foundOne = true; break; } if (!foundOne) { graph->setLastSelectedViewer(0); } } ViewerNodePtr viewerNode = tab->getInternalNode(); ViewerInstancePtr internalViewer; if (viewerNode) { internalViewer = viewerNode->getInternalViewerNode(); } if (internalViewer) { internalViewer->abortAnyEvaluation(); if (getApp()->getLastViewerUsingTimeline() == internalViewer) { getApp()->discardLastViewerUsingTimeline(); } } if (!initiatedFromNode) { assert(_imp->_nodeGraphArea); ///call the deleteNode which will call this function again when the node will be deactivated. NodePtr internalNode = tab->getInternalNode()->getNode(); NodeGuiIPtr guiI = internalNode->getNodeGui(); NodeGuiPtr gui = boost::dynamic_pointer_cast<NodeGui>(guiI); assert(gui); NodeGraphI* graph_i = internalNode->getGroup()->getNodeGraph(); assert(graph_i); NodeGraph* graph = dynamic_cast<NodeGraph*>(graph_i); assert(graph); if (graph) { graph->removeNode(gui); } } else { tab->hide(); TabWidget* container = dynamic_cast<TabWidget*>( tab->parentWidget() ); if (container) { container->removeTab(tab, false); } if (deleteData) { QMutexLocker l(&_imp->_viewerTabsMutex); std::list<ViewerTab*>::iterator it = std::find(_imp->_viewerTabs.begin(), _imp->_viewerTabs.end(), tab); if ( it != _imp->_viewerTabs.end() ) { _imp->_viewerTabs.erase(it); } tab->notifyGuiClosingPublic(); tab->deleteLater(); } } Q_EMIT viewersChanged(); } // Gui::removeViewerTab