예제 #1
0
QString SvgSavingContext::getID(const KoShape *obj)
{
    QString id;
    // do we have already an id for this object ?
    if (d->shapeIds.contains(obj)) {
        // use existing id
        id = d->shapeIds[obj];
    } else {
        // initialize from object name
        id = obj->name();
        // if object name is not empty and was not used already
        // we can use it as is
        if (!id.isEmpty() && !d->uniqueNames.contains(id)) {
            // add to unique names so it does not get reused
            d->uniqueNames.insert(id, 1);
        } else {
            if (id.isEmpty()) {
                // differentiate a little between shape types
                if (dynamic_cast<const KoShapeGroup*>(obj))
                    id = "group";
                else if (dynamic_cast<const KoShapeLayer*>(obj))
                    id = "layer";
                else
                    id = "shape";
            }
            // create a compeletely new id based on object name
            // or a generic name
            id = createUID(id);
        }
        // record id for this shape
        d->shapeIds.insert(obj, id);
    }
    return id;
}
예제 #2
0
void PRINT_SCP_EMULATOR_CLASS::makeSopInstanceUid()

//  DESCRIPTION     : Generate a sop instance uid.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	char buffer[UI_LENGTH + 1];

	createUID(buffer, (char*) sessionM_ptr->getImplementationClassUid());
	sopInstanceUidM = buffer;
}
예제 #3
0
QString SvgSavingContext::createFileName(const QString &extension)
{
    QFile *file = qobject_cast<QFile*>(&d->output);
    if (!file)
        return QString();

    // get url of destination directory
    QUrl url(file->fileName());
    QString dstBaseFilename = QFileInfo(url.toLocalFile()).baseName();
    url.setPath(url.path());
    // create a filename for the image file at the destination directory
    QString fname = dstBaseFilename + '_' + createUID("file");
    url.fromLocalFile(fname + extension);
    // check if file exists already
    int i = 0;
    // change filename as long as the filename already exists
    //while (KIO::NetAccess::exists(url, KIO::NetAccess::DestinationSide, 0))
	while (QFile::exists(url.toLocalFile()))
        url.fromLocalFile(fname + QString("_%1").arg(++i) + extension);

    return url.toLocalFile();
}
예제 #4
0
char *OBJECT_WAREHOUSE_CLASS::setLabelledValue(char *name_ptr, UINT16 group, UINT16 element, LOG_CLASS *logger_ptr)

//  DESCRIPTION     : Method to checked if we are dealing with a labelled
//					: value. A labelled value is used to initialise the mapping
//					: of a Name to a Value. Each time a labelled Name is given,
//					: the Name / Value mapping must be reset so that a new Value
//					: can be mapped to the Name.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	char	*mapping_ptr = NULL;
	UINT	length = strlen(NEWKEYWORD);
	char	value[MAX_STRING_LEN];

	// check for "NEW:" mapping
	if ((strlen(name_ptr) > length)
		&& (strncmp(name_ptr, NEWKEYWORD, length) == 0))
	{
		// get the VR from the definitions
		if (DEFINITION->GetAttributeVr(group, element) == ATTR_VR_UI)
		{
			// create a new UID
			createUID(value, IMPLEMENTATION_CLASS_UID);
		}
		else
		{
			// generate a new Value - using the current time
			struct tm	*currentTime_ptr;
			time_t		clock;

			// get time is seconds and convert to struct tm
			time(&clock);
			currentTime_ptr = localtime(&clock);
			sprintf(value, "1%02d%02d%02d%02d", currentTime_ptr->tm_hour, currentTime_ptr->tm_min, currentTime_ptr->tm_sec, uniq8odd());
		}

		// add the mapping to the list
		mapping_ptr = name_ptr + length;
		addMappedValue(mapping_ptr, value, group, element, logger_ptr);

		// return new Name / Value mapping
		mapping_ptr = getMappedValue(mapping_ptr, logger_ptr);
	}
	else
	{
		length = strlen(LABELKEYWORD);

		// check for a "LABEL:" mapping
		if ((strlen(name_ptr) > length)
			&& (strncmp(name_ptr, LABELKEYWORD, length) == 0))
		{
			char name[MAX_STRING_LEN];

			// we've got a labelled name
			mapping_ptr = name_ptr + length;

			// copy the label name [and value]
			UINT i = 0;
			UINT index = 0;
			strcpy(value, UNDEFINED_MAPPING);
			while (*mapping_ptr != '\0')
			{
				if (*mapping_ptr == COLON)
				{
					if (index == 0)
					{
						// occurence of first colon indicates transition from
						// name to value
						name[i] = '\0';
						i = 0;
						index++;
						mapping_ptr++;
						continue;
					}
				}
				switch (index) 
				{
				case 0:
					name[i++] = *mapping_ptr;
					break;
				case 1:
					value[i++] = *mapping_ptr;
					break;
				}

				mapping_ptr++;
			}

			// terminate last copied string and setup return pointer
			if (index == 0)
			{
				name[i] = '\0';
				mapping_ptr = name;
			}
			else 
			{
				value[i] = '\0';
				mapping_ptr = value;
			}

			// let's check if we need to remove an existing Name / Value mapping for this label
			i = 0;
			while (i < mappingM.getSize())
			{
				// got match ?
				if (strcmp(mappingM[i].getName(), name) == 0)
				{
					// got an old mapping - remove it
					mappingM.removeAt(i);
				}

				// move to next entry
				i++;
			}

			// save label mapping - but first see if the value specified is already a label that
			// should be mapped
			char *existingMapping_ptr = getMappedValue(value, logger_ptr);
			if (existingMapping_ptr != NULL) 
			{
				addMappedValue(name, existingMapping_ptr, group, element, logger_ptr);
				mapping_ptr = existingMapping_ptr;
			}
			else 
			{
				addMappedValue(name, value, group, element, logger_ptr);
				mapping_ptr = refreshMappedName(name, logger_ptr);
			}
		}
		else 
		{
			// just check for normal (unlabelled) Name / Value mapping
			mapping_ptr = getMappedValue(name_ptr, logger_ptr);
		}
	}

	if ((mapping_ptr) &&
		(logger_ptr))
	{
		logger_ptr->text(LOG_DEBUG, 1, "OBJECT_WAREHOUSE_CLASS::setLabelledValue(name_ptr:= %s) -> mapping_ptr:= %s", name_ptr, mapping_ptr);
	}

	// return mapped label
	return mapping_ptr;
}