Example #1
0
// set source object
bool ImageBase::setSource (const char * id, PyImage *source)
{
	// find source
	ImageSourceList::iterator src = findSource(id);
	// check source loop
	if (source != NULL && source->m_image->loopDetect(this))
		return false;
	// if found, set new object
	if (src != m_sources.end())
		// if new object is not empty or sources are static
		if (source != NULL || m_staticSources)
			// replace previous source
			(*src)->setSource(source);
		// otherwise delete source
		else
			m_sources.erase(src);
	// if source is not found and adding is allowed
	else
		if (!m_staticSources)
		{
			// create new source
			ImageSource * newSrc = newSource(id);
			newSrc->setSource(source);
			// if source was created, add it to source list
			if (newSrc != NULL) m_sources.push_back(newSrc);
		}
		// otherwise source wasn't set
		else 
			return false;
	// source was set
	return true;
}
void ScatteredLineBrush::BrushMove(const Point source, const Point target)
{
    ImpressionistDoc* pDoc = GetDocument();
    ImpressionistUI* dlg = pDoc->m_pUI;

    if (pDoc == NULL) {
        printf("PointBrush::BrushMove  document is NULL\n");
        return;
    }

    int lineAmount = 4;
    int size = pDoc->getSize();

    for (int i = 0; i < lineAmount; i++) {
        // Get random numbers to set scatter location in the brush area
        int randomX = rand() % size + (-size / 2);
        int randomY = rand() % size + (-size / 2);

        // We need to set a new Point source for the brush as well to
        // match the location of the source and the target point
        Point newSource(source.x + randomX, source.y + randomY);
        Point newTarget(target.x + randomX, target.y + randomY);

        LineBrush::BrushMove(newSource, newTarget);
    }
}
sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
    sword::InstallSource newSource(""); //empty, invalid Source
    if (this->isRemote(m_protocolCombo->currentText())) {
        if (m_protocolCombo->currentText() == PROTO_FTP) {
            newSource.type = "FTP";
            }
            else if (m_protocolCombo->currentText() == PROTO_SFTP) {
                newSource.type = "SFTP";
            }
            else if (m_protocolCombo->currentText() == PROTO_HTTP) {
                newSource.type = "HTTP";
            }
            else if (m_protocolCombo->currentText() == PROTO_HTTPS) {
                newSource.type = "HTTPS";
            }
            newSource.source = m_serverEdit->text().toUtf8();
        //a message to the user would be nice, but we're in message freeze right now (1.5.1)
        if (m_serverEdit->text().right(1) == "/") { //remove a trailing slash
            newSource.source  = m_serverEdit->text().mid(0, m_serverEdit->text().length() - 1).toUtf8();
        }
    }
    else {
        newSource.type = "DIR";
        newSource.source = "local";
    }
    newSource.caption = m_captionEdit->text().toUtf8();
    newSource.directory = m_pathEdit->text().toUtf8();
    newSource.uid = newSource.source;

    return newSource;
}
bool OsmAnd::OnlineTileSources_P::deserializeFrom(QXmlStreamReader& xmlReader)
{
    QHash< QString, std::shared_ptr<const Source> > collection;

    while(!xmlReader.atEnd() && !xmlReader.hasError())
    {
        xmlReader.readNext();
        if (!xmlReader.isStartElement())
            continue;
        const auto tagName = xmlReader.name();
        if (tagName == QLatin1String("tile_source"))
        {
            // Original format of the tile sources, used in the Android application
            if (xmlReader.attributes().hasAttribute("rule"))
                continue; // Rules are not supported

            const auto name = xmlReader.attributes().value(QLatin1String("name")).toString();
            if (collection.contains(name))
            {
                LogPrintf(LogSeverityLevel::Warning, "Ignored duplicate online tile source with name '%s'", qPrintable(name));
                continue;
            }
            const auto originalUrlTemplate = xmlReader.attributes().value(QLatin1String("url_template")).toString();
            auto urlPattern = originalUrlTemplate;
            urlPattern = urlPattern.replace(QLatin1String("{0}"), QLatin1String("${osm_zoom}"));
            urlPattern = urlPattern.replace(QLatin1String("{1}"), QLatin1String("${osm_x}"));
            urlPattern = urlPattern.replace(QLatin1String("{2}"), QLatin1String("${osm_y}"));
            const auto minZoom = static_cast<ZoomLevel>(xmlReader.attributes().value(QLatin1String("min_zoom")).toUInt());
            const auto maxZoom = static_cast<ZoomLevel>(xmlReader.attributes().value(QLatin1String("max_zoom")).toUInt());
            const auto tileSize = xmlReader.attributes().value(QLatin1String("tile_size")).toUInt();
            
            std::shared_ptr<Source> newSource(new Source(name));
            newSource->urlPattern = urlPattern;
            newSource->minZoom = minZoom;
            newSource->maxZoom = maxZoom;
            newSource->maxConcurrentDownloads = 1;
            newSource->tileSize = tileSize;
            newSource->alphaChannelData = AlphaChannelData::Undefined;
            collection.insert(name, newSource);
        }
        else if (tagName == QLatin1String("tileSource"))
        {
            //TODO: parse new format, but create it first :)
        }
    }
    if (xmlReader.hasError())
    {
        LogPrintf(LogSeverityLevel::Warning, "XML error: %s (%d, %d)", qPrintable(xmlReader.errorString()), xmlReader.lineNumber(), xmlReader.columnNumber());
        return false;
    }

    _collection = collection;

    return true;
}
void KSettingsOnlineQuotes::slotNewEntry()
{
  WebPriceQuoteSource newSource(i18n("New Quote Source"));
  newSource.write();
  loadList();
  QListWidgetItem* item = m_quoteSourceList->findItems(i18n("New Quote Source"), Qt::MatchExactly).at(0);
  if (item) {
    m_quoteSourceList->setCurrentItem(item);
    slotLoadWidgets();
  }
}
Example #6
0
 bool addAliasFromSourceAndRelativeDest(PathNode &node,
                                        std::string const &source,
                                        std::string const &dest,
                                        AliasPriority priority) {
     auto &aliasNode = treePathRetrieve(node, dest);
     ParsedAlias newSource(source);
     if (!newSource.isValid()) {
         /// @todo signify invalid route in some other way?
         OSVR_DEV_VERBOSE("Could not parse source: " << source);
         return false;
     }
     auto absSource = getAbsolutePath(node, newSource.getLeaf());
     newSource.setLeaf(absSource);
     return addAliasImpl(aliasNode, newSource.getAlias(), priority);
 }
Example #7
0
 bool addAlias(PathNode &node, std::string const &source,
               AliasPriority priority) {
     ParsedAlias newSource(source);
     if (!newSource.isValid()) {
         /// @todo signify invalid route in some other way?
         OSVR_DEV_VERBOSE("Could not parse source: " << source);
         return false;
     }
     if (!isPathAbsolute(newSource.getLeaf())) {
         /// @todo signify not to pass relative paths here in some other way?
         OSVR_DEV_VERBOSE(
             "Source contains a relative path, not permitted: " << source);
         return false;
     }
     return addAliasImpl(node, newSource.getAlias(), priority);
 }
sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {

	boost::scoped_ptr<CSwordSetupInstallSourcesDialog> dlg( new CSwordSetupInstallSourcesDialog() );
	sword::InstallSource newSource(""); //empty, invalid Source

	if (dlg->exec() == QDialog::Accepted) {
		if (dlg->m_protocolCombo->currentText() == PROTO_FTP) {
			newSource.type = "FTP";
			newSource.source = dlg->m_serverEdit->text().toUtf8();

			//a message to the user would be nice, but we're in message freeze right now (1.5.1)
			if (dlg->m_serverEdit->text().right(1) == "/") { //remove a trailing slash
				newSource.source  = dlg->m_serverEdit->text().mid(0, dlg->m_serverEdit->text().length()-1).toUtf8();
			}
		}
		else {
			newSource.type = "DIR";
			newSource.source = "local";
		}
		newSource.caption = dlg->m_captionEdit->text().toUtf8();
		newSource.directory = dlg->m_pathEdit->text().toUtf8();
	}
	return newSource;
}
void ScatteredPointBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}

	int size = pDoc->getSize();
	//set random target coordinates
	//srand(time(NULL));
	int numOfPoints = rand() % (size/2)*(size/2) + 1;
	for (int i = 0; i < numOfPoints; i++){
		int xDisplacement = rand() % size;
		int yDisplacement = rand() % size;
		Point newSource(source.x + xDisplacement, source.y + yDisplacement);
		Point newTarget(target.x + xDisplacement, target.y + yDisplacement);

		PointBrush::BrushMove(newSource, newTarget);
	}

}