Пример #1
0
ObjectReferenceEdit::ObjectReferenceEdit(QWidget *parent)
    : QWidget(parent),
      mErrorTextColor(Qt::red)
{
    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);

    mLineEdit = new QLineEdit(this);
    mLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));

    mOkTextColor = mLineEdit->palette().color(QPalette::Active, QPalette::Text);

    QToolButton *button = new QToolButton(this);
    button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
    button->setFixedWidth(20);
    button->setText(QLatin1String("..."));
    layout->addWidget(mLineEdit);
    layout->addWidget(button);

    connect(button, SIGNAL(clicked(bool)),
            SLOT(buttonClicked()));
    connect(mLineEdit, SIGNAL(textChanged(QString)),
            SLOT(validate()));
    connect(mLineEdit, SIGNAL(textEdited(QString)),
            SLOT(setObjectId(QString)));

    setFocusProxy(mLineEdit);
    setFocusPolicy(Qt::StrongFocus);
    setAttribute(Qt::WA_InputMethodEnabled);
}
Пример #2
0
void StaticObj::readObj(char* filename, object &comp)
{
  FILE *f = fopen(filename, "rb");
  if(f == NULL){
    std::cout<<"Error opening an object file";
    return;
  }
  int length;
  fread(&length, sizeof(int), 1, f);
  std::vector<Vector3> vertices(length);
  fread(&vertices[0], sizeof(Vector3)*length, 1, f);

  fread(&length, sizeof(int), 1, f);
  std::vector<Vector3> normals(length);
  fread(&normals[0], sizeof(Vector3)*length, 1, f);

  fread(&length, sizeof(int), 1, f);
  if(length >0){
    std::vector<Point2D> texMap(length);
    fread(&texMap[0], sizeof(Point2D)*length, 1, f);
  
    fread(&length, sizeof(int), 1, f);
    std::vector<Face> face(length);
    fread(&face[0], sizeof(Face)*length, 1, f);
    comp.texMap = texMap;
    comp.face = face;
  }

  comp.vertices = vertices;
  comp.normals = normals;
  fclose(f);
  setObjectId(comp);
}
Пример #3
0
void
FormComboBox::setCfg( const Cfg::ComboBox & c )
{
	setObjectId( c.objectId() );
	setLink( c.link() );
	setObjectPen( Cfg::fromPen( c.pen() ), false );
	d->setRect( QRectF( c.pos().x(), c.pos().y(),
		c.size().width(), c.size().height() ) );

	update();
}
Пример #4
0
void ObjectGroup::addObject(Object* object)
{
	mObjectList.push_back(object);
	object->setState(INGROUP);
	mModel->addObjectModel(object->getObjectModel());
	mObjectToObjectModel.insert(std::make_pair(object, object->getObjectModel()));
	mObjectModelToObject.insert(std::make_pair(object->getObjectModel(), object));
	std::string name;
	for(unsigned int i = 0; i < mObjectList.size(); ++i)	
		name += mObjectList[i]->getObjectId() + ", ";
	setObjectId(name);
}
Пример #5
0
void
FormCheckBox::setCfg( const Cfg::CheckBox & c )
{
	d->m_checked = c.isChecked();

	setObjectId( c.objectId() );
	setLink( c.link() );
	setObjectPen( Cfg::fromPen( c.pen() ), false );

	d->setRect( QRectF( c.pos().x(), c.pos().y(),
		c.width(), c.size().height() ) );

	setText( c.text() );

	update();
}
Пример #6
0
		void AlarmAddLinkAction::_setFromParametersMap(const ParametersMap& map)
		{
			// Recipient key
			_recipientKey = map.get<string>(PARAMETER_RECIPIENT_KEY);
			if (!Factory<AlarmRecipient>::contains(_recipientKey))
				throw ActionException("Specified recipient not found");

			// Alarm ID
			setAlarmId(map.get<RegistryKeyType>(PARAMETER_ALARM_ID));

			// Object ID
			setObjectId(map.get<RegistryKeyType>(PARAMETER_OBJECT_ID));

			// Parameter
			_parameter = map.getDefault<string>(PARAMETER_PARAMETER);
		}
Пример #7
0
AccessEventObject::AccessEventObject(int objectId, QString eventDate,
                                     QString physicianName, QString hospitalName,
                                     QString eventType, QString notes,
                                     int imageId, int documentId,
                                     int patientId, int accessId,
                                     QObject *parent) : QObject(parent)
{

    setObjectId(objectId);
    setEventDate(eventDate);
    setPhysicianName(physicianName);
    setHospitalName(hospitalName);
    setEventType(eventType);
    setNotes(notes);
    setImageId(imageId);
    setDocumentId(documentId);
    setPatientId(patientId);
    setAccessId(accessId);

}
Пример #8
0
/////////////////////////////////////////////////////////////
// class ex_tcb
/////////////////////////////////////////////////////////////
// Base class constructor
ex_tcb::ex_tcb( const ComTdb & tdb, const short in_version,
               ex_globals * g) :
  tdb(tdb),
  nodeType_((ComTdb::ex_node_type)tdb.getNodeType()),
  version_(in_version),
  globals_(g),
  statsEntry_(NULL),
  pool_(NULL)
  // QSTUFF
  , holdable_(FALSE)
  // QSTUFF
{
  str_cpy_all( (char *) &eyeCatcher_, (char *) &(tdb.eyeCatcher_), 4);

#ifdef NA_DEBUG_GUI
  increaseObjectcount();
  setObjectId(); 
#endif

  // Cleanup
  g->registerTcb(this);
};
Пример #9
0
// Setters
void Audio::setAudioId(const QString& v) { setObjectId(v); }
Пример #10
0
bool RMemoryStorage::saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion, bool keepHandles) {
    if (object.isNull()) {
        qWarning() << "RMemoryStorage::saveObject: object is NULL";
        return false;
    }

    //qDebug() << "saveObject: " << *object;

    // never allow two layers with identical names, update layer instead:
    QSharedPointer<RLayer> layer = object.dynamicCast<RLayer>();
    if (!layer.isNull()) {
        RLayer::Id id = getLayerId(layer->getName());
        if (id != RLayer::INVALID_ID && id != layer->getId()) {
            setObjectId(*layer, id);

            // never unprotect an existing protected layer:
            QSharedPointer<RLayer> existingLayer = queryLayerDirect(id);
            if (!existingLayer.isNull()) {
                if (existingLayer->isProtected()) {
                    layer->setProtected(true);
                }
            }
        }
    }

    // never allow two blocks with identical names, update block instead:
    QSharedPointer<RBlock> block = object.dynamicCast<RBlock> ();
    if (!block.isNull()) {
        RBlock::Id id = getBlockId(block->getName());
        if (id != RBlock::INVALID_ID && id != block->getId()) {
            setObjectId(*block, id);
        }
    }

    // never allow two linetypes with identical names, update linetype instead:
    QSharedPointer<RLinetype> linetype = object.dynamicCast<RLinetype> ();
    if (!linetype.isNull()) {
        RLinetype::Id id = getLinetypeId(linetype->getName());
        if (id != RLinetype::INVALID_ID && id != linetype->getId()) {
            setObjectId(*linetype, id);
        }
    }

    // avoid block recursions:
    if (checkBlockRecursion) {
        /*
        QSharedPointer<RBlockReferenceEntity> blockRef = object.dynamicCast<RBlockReferenceEntity> ();
        if (!blockRef.isNull()) {
            RBlock::Id id = blockRef->getBlockId();
            RBlock::Id refId = blockRef->getReferencedBlockId();
            // check if block with 'id' may contain a block reference which refers to
            // block with 'refid':
            // 201308: too slow for large, complex drawings:
            if (checkRecursion(id, refId)) {
                qCritical("RMemoryStorage::saveObject: recursion found");
                return false;
            }
        }
        */
    }

    QSharedPointer<REntity> entity = object.dynamicCast<REntity> ();

    if (!entity.isNull()) {
        Q_ASSERT_X(!queryLayerDirect(entity->getLayerId()).isNull(),
            "RMemoryStrorage::saveObject", "Layer of entity is NULL");
    }

    // assign new object ID to new objects:
    if (object->getId() == RObject::INVALID_ID) {
        setObjectId(*object, getNewObjectId());

        // only set new handle if handle is not set already:
        if (!keepHandles || object->getHandle()==RObject::INVALID_HANDLE) {
            setObjectHandle(*object, getNewObjectHandle());
        }

        // assign draw order to new entities:
        if (!entity.isNull() && entity->getDrawOrder()==0) {
            entity->setDrawOrder(getMaxDrawOrder());
            setMaxDrawOrder(getMaxDrawOrder()+1);
        }
    }

    // TODO: save original object for rollback:
    //if (inTransaction) {
        //transactionObjectMap[object->getId()] = object;
    //}

    objectMap[object->getId()] = object;
    objectHandleMap[object->getHandle()] = object;

    if (!entity.isNull()) {
        entityMap[entity->getId()] = entity;
        blockEntityMap.insert(entity->getBlockId(), entity);
        setMaxDrawOrder(qMax(entity->getDrawOrder()+1, getMaxDrawOrder()));
    }

    if (!layer.isNull()) {
        layerMap[object->getId()] = layer;
    }

    if (!block.isNull()) {
        blockMap[object->getId()] = block;
    }

    if (!linetype.isNull()) {
        linetypeMap[object->getId()] = linetype;
    }

    QSharedPointer<RDocumentVariables> docVars = object.dynamicCast<RDocumentVariables> ();
    if (!docVars.isNull()) {
        documentVariables = docVars;
    }

    return true;
}
Пример #11
0
bool RMemoryStorage::saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion, bool keepHandles) {
    if (object.isNull()) {
        return false;
    }

    // never allow two layers with identical names, update layer instead:
    QSharedPointer<RLayer> layer = object.dynamicCast<RLayer>();
    if (!layer.isNull()) {
        RLayer::Id id = getLayerId(layer->getName());
        if (id != RLayer::INVALID_ID) {
            setObjectId(*layer, id);
        }
    }

    // never allow two blocks with identical names, update block instead:
    QSharedPointer<RBlock> block = object.dynamicCast<RBlock> ();
    if (!block.isNull()) {
        RBlock::Id id = getBlockId(block->getName());
        if (id != RBlock::INVALID_ID) {
            setObjectId(*block, id);
        }
    }

    // avoid block recursions:
    if (checkBlockRecursion) {
        /*
        QSharedPointer<RBlockReferenceEntity> blockRef = object.dynamicCast<RBlockReferenceEntity> ();
        if (!blockRef.isNull()) {
            RBlock::Id id = blockRef->getBlockId();
            RBlock::Id refId = blockRef->getReferencedBlockId();
            // check if block with 'id' may contain a block reference which refers to
            // block with 'refid':
            // 201308: too slow for large, complex drawings:
            if (checkRecursion(id, refId)) {
                qCritical("RMemoryStorage::saveObject: recursion found");
                return false;
            }
        }
        */
    }

    QSharedPointer<REntity> entity = object.dynamicCast<REntity> ();

    // assign new object ID to new objects:
    if (object->getId() == RObject::INVALID_ID) {
        setObjectId(*object, getNewObjectId());

        // only set new handle if handle is not set already:
        if (!keepHandles || object->getHandle()==RObject::INVALID_HANDLE) {
            setObjectHandle(*object, getNewObjectHandle());
        }

        // assign draw order to new entities:
        if (!entity.isNull()) {
            entity->setDrawOrder(getMaxDrawOrder());
            setMaxDrawOrder(getMaxDrawOrder()+1);
        }
    }

    // TODO: save original object for rollback:
    //if (inTransaction) {
        //transactionObjectMap[object->getId()] = object;
    //}

    objectMap[object->getId()] = object;

    //QSharedPointer<REntity> entity = object.dynamicCast<REntity> ();
    if (!entity.isNull()) {
        entityMap[entity->getId()] = entity;
        blockEntityMap.insert(entity->getBlockId(), entity);
        //qDebug() << "added " << entity->getId() << " to block " << entity->getBlockId();
        setMaxDrawOrder(qMax(entity->getDrawOrder()+1, getMaxDrawOrder()));
    }

    if (!layer.isNull()) {
        layerMap[object->getId()] = layer;
    }

    if (!block.isNull()) {
        blockMap[object->getId()] = block;
    }

    return true;
}
Пример #12
0
void
FormText::setCfg( const Cfg::Text & c )
{
	setPlainText( QString() );

	QFont f = font();
	QTextCharFormat fmt = textCursor().charFormat();
	QTextBlockFormat b = textCursor().blockFormat();

	foreach( const Cfg::TextStyle & s, c.text() )
	{
		if( s.style().contains( Cfg::c_normalStyle ) )
		{
			f.setWeight( QFont::Normal );
			f.setItalic( false );
			f.setUnderline( false );

			fmt.setFontWeight( QFont::Normal );
			fmt.setFontItalic( false );
			fmt.setFontUnderline( false );
		}
		else
		{
			if( s.style().contains( Cfg::c_boldStyle ) )
			{
				f.setWeight( QFont::Bold );
				fmt.setFontWeight( QFont::Bold );
			}
			else
			{
				f.setWeight( QFont::Normal );
				fmt.setFontWeight( QFont::Normal );
			}

			if( s.style().contains( Cfg::c_italicStyle ) )
			{
				f.setItalic( true );
				fmt.setFontItalic( true );
			}
			else
			{
				f.setItalic( false );
				fmt.setFontItalic( false );
			}

			if( s.style().contains( Cfg::c_underlineStyle ) )
			{
				f.setUnderline( true );
				fmt.setFontUnderline( true );
			}
			else
			{
				f.setUnderline( false );
				fmt.setFontUnderline( false );
			}
		}

		Cfg::initBlockFormat( b, s );

		f.setPointSize( s.fontSize() );

		fmt.setFontPointSize( s.fontSize() );

		setFont( f );

		QTextCursor cursor = textCursor();
		cursor.movePosition( QTextCursor::End );
		cursor.setCharFormat( fmt );
		cursor.setBlockFormat( b );
		cursor.insertText( s.text() );
		setTextCursor( cursor );
	}

	document()->clearUndoRedoStacks();

	setObjectId( c.objectId() );

	setTextWidth( c.textWidth() );

	setPos( QPointF( c.pos().x(), c.pos().y() ) );

	setLink( c.link() );

	QRectF r = boundingRect();
	r.moveTo( pos() );

	d->m_proxy->setRect( r );
}