Cfg::CheckBox
FormCheckBox::cfg() const
{
	Cfg::CheckBox c;

	c.setWidth( d->m_width );

	c.setIsChecked( d->m_checked );
	c.setObjectId( objectId() );
	c.setLink( link() );
	c.setPen( Cfg::pen( objectPen() ) );

	Cfg::Point p;
	p.setX( pos().x() );
	p.setY( pos().y() );

	c.setPos( p );

	Cfg::Size s;
	s.setWidth( d->m_rect.width() );
	s.setHeight( d->m_rect.height() );

	c.setSize( s );

	c.setText( text() );

	return c;
}
Exemple #2
0
void FlowSensorGE::writePropertyDataToGEDraw( MineGEDraw* pGEDraw ) const
{
	AcDbObjectId gID = getRelatedGE();
	AcDbObjectId objID = objectId();
	ReadWriteData(gID,_T("瓦斯管中的瓦斯流量"),objID,_T("流量"));
	MineGE::writePropertyDataToGEDraw(pGEDraw);
}
Exemple #3
0
//------------------------------------------------------------------------------
int lookup(int *typeOfObject)
{
  int i;
  gettoken(yytext, sizeof yytext);

  if (!strnicmp(yytext,"reg",3) && strlen(yytext) == 5 && isdigit(yytext[3]) && isdigit(yytext[4]) && (i=atoi(yytext+3))>=0 && i<100)
  {
    *typeOfObject=IDENTIFIER;
    return i+EVAL_MAX_VARS;
  }

  for (i=0;i<EVAL_MAX_VARS;i++)
    if (!strnicmp(varTable[i].name, yytext,sizeof(varTable[i].name)))
    {
      *typeOfObject = IDENTIFIER;
      return i;
    }

  for (i=0;getFunctionFromTable(i);i++)
  {
    functionType *f=getFunctionFromTable(i);
    if (!strcmpi(f->name, yytext))
    {
      *typeOfObject = objectId(f->nParams);
      return i;
    }
  }
  *typeOfObject = IDENTIFIER;
  setLastVar();
  i = setVar(-1, 0);
  return i;
}
Exemple #4
0
void DifferPressSensorGE::writePropertyDataToGEDraw( MineGEDraw* pGEDraw ) const
{
	AcDbObjectId gID = getRelatedGE();
	AcDbObjectId objID = objectId();
	ReadWriteData(gID,_T("¹Ü·ѹ²î"),objID,_T("ѹ²î"));
	MineGE::writePropertyDataToGEDraw(pGEDraw);
}
QSharedPointer<QEnginioOperationShared> QEnginioObjectShared::save(QSharedPointer<QEnginioObjectShared> aSelf)
{
    if (!isModified()) {
        return QSharedPointer<QEnginioOperationShared>();
    }

    QJsonObject update;
    QJsonObject::iterator i;

    for (i = iJsonObject.begin(); i != iJsonObject.end(); ++i) {
        if (i.key() == QtCloudServicesConstants::id ||
                i.key() == QtCloudServicesConstants::objectType) {
            update.insert(i.key(), i.value());
            continue;
        }

        if (iPersistentJsonObject.contains(i.key()) &&
                iPersistentJsonObject[i.key()] == i.value()) {
            continue;
        }

        update.insert(i.key(), i.value());
    }

    return iEnginioCollection->update(iEnginioCollection,
                                      objectId(), update,
                                      SaveCompletedFunctor(aSelf));
}
QJSValue EnginioQmlFileOperation::object() const
{
    QJSValue object = g_qmlEngine->newObject();
    object.setProperty(QStringLiteral("id"), objectId());
    object.setProperty(QStringLiteral("objectType"), objectType());
    return object;
}
Exemple #7
0
Acad::ErrorStatus
AsdkBody::dwgOutFields(AcDbDwgFiler* filer) const
{
    assertReadEnabled();
    Acad::ErrorStatus es;

    if ((es = AcDbEntity::dwgOutFields(filer)) != Acad::eOk)
        return es;

    switch (filer->filerType()) 
    {
    case AcDb::kCopyFiler:     
    case AcDb::kDeepCloneFiler:
    case AcDb::kWblockCloneFiler:
        
        filer->writeAddress( objectId() );
        filer->writeAddress( this );
        break;
        
    case AcDb::kFileFiler:     
    case AcDb::kUndoFiler:
    case AcDb::kPageFiler:
        
        m_3dGeom.save( &DwgFilerCallBack( filer ) );
        break;
        
    default:
        break;
    }
    return filer->filerStatus();
}
bool QEnginioObjectShared::isPersistent() const
{
    if (!isValid()) {
        return false;
    }

    return !objectId().isEmpty();
}
 void checkObjectId( std::istream& in, const State& state )
 {
     // read id and compare with object
     int id = -1;
     readValue( in, id );
     if( id != objectId( state ) ) {
         OPM_THROW(std::logic_error,"backup-restore object type mismatch");
     }
 }
Exemple #10
0
void
Id::setSystemId(fixed id)
{
    assert(id < 1000);
    if (isNull())
	_id = (id * systemStart).toInt64();
    else
	_id = (id * systemStart + objectId()).toInt64();
}
Exemple #11
0
void TagGE::setRelatedGE( const AcDbObjectId& objId )
{
    assertWriteEnabled();
    if( objId.isNull() || ( objId == m_objId ) ) return;
    if( objId == objectId() ) return;                            // 不能和图元自身关联
    if( !ArxUtilHelper::IsEqualType( _T( "MineGE" ), objId ) ) return; // 必须从MineGE派生

    m_objId = objId;
}
/* static */ ObjectId ObjectId::newObjectId()
{
	std::lock_guard<std::mutex> lock(newObjectIdMutex);

	static time_t seconds = 0;
	static unsigned long fraction = 0;

	time_t newSeconds = 0;
	struct timeb timeBuffer;

	ftime(&timeBuffer);
	newSeconds = timeBuffer.time;

	// Reset seconds and fraction if in a new seconds
	if (seconds < newSeconds) {
		seconds = newSeconds;
		fraction = 0;
	}

	// Prevent overflow to 0 within the second. This should only happen on
	// fast machines
	// as the creation of the fraction part is processor speed dependend
	if (fraction == ULONG_MAX) {
		ftime(&timeBuffer);
		newSeconds = timeBuffer.time;

		if (seconds < newSeconds) {
			seconds = newSeconds;
			fraction = 0;
		} else {
			while (seconds >= newSeconds) {
				ftime(&timeBuffer);
				newSeconds = timeBuffer.time;
			}
			seconds = newSeconds;
			fraction = 0;
		}
	}

	time_t sec = seconds;
	struct tm* timeStruct = gmtime(&sec);
	if (!timeStruct) {
		fprintf(stderr, "timeStruct is NULL, seconds were %lu\n", seconds);
		throw std::invalid_argument("timeStruct is NULL");
	}

	char* objectIdString = new char[27];
	sprintf(objectIdString, "%04d-%02d-%02d-%02d-%02d-%02d-%06lu", timeStruct->tm_year + 1900,
	        timeStruct->tm_mon + 1, timeStruct->tm_mday, timeStruct->tm_hour,
	        timeStruct->tm_min, timeStruct->tm_sec, fraction);

	ObjectId objectId(objectIdString, objectIdString + 26);
	delete[] objectIdString;
	fraction++;
	return objectId;
}
void
FormCheckBox::setPosition( const QPointF & pos, bool pushUndoCommand )
{
	if( pushUndoCommand )
		form()->undoStack()->push( new UndoMove< FormCheckBox > ( form(),
			objectId(), pos - position() ) );

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

	d->setRect( r );
}
Exemple #14
0
  qi::AnyObject ObjectRegistrar::registeredServiceObject(const std::string &service) {
    unsigned int serviceId = objectId(service);
    if (!serviceId)
      return qi::AnyObject();

    {
      boost::mutex::scoped_lock sl(_servicesMutex);
      BoundServiceMap::iterator it = _services.find(serviceId);
      if (it != _services.end())
        return it->second.object;
    }
    return AnyObject();
  }
Exemple #15
0
void Screen::save(QTextStream &stream) {
	stream << "<objects>\n";
	for (int i = 0; i < m_objects.size(); ++i) {
		stream << "<object id='" << i << "' type='" << m_objects[i]->type();
		stream << "' interface='" + m_objects[i]->interface() + "' name='" + m_objects[i]->name() + "'>\n";
		m_objects[i]->save(stream);
		stream << "</object>\n";
	}
	stream << "</objects>\n";

	stream << "<trackedpins>\n";
	for (std::map<ScreenObject *, QList<int> >::iterator it = m_trackedPins.begin(); it != m_trackedPins.end(); ++it) {
		foreach(int pin, it->second) {
			stream << "<object id='" << objectId(it->first) << "' pin='" << pin << "'/>\n";
		}
	}
	stream << "</trackedpins>\n";

	m_conns->save(stream);
}
void
FormCheckBox::properties()
{
	CheckBoxProperties dlg;

	dlg.setCfg( cfg() );

	if( dlg.exec() == QDialog::Accepted )
	{
		Cfg::CheckBox c = dlg.cfg();

		form()->undoStack()->push( new UndoChangeTextWithOpts( form(),
			objectId(), text(), c.text() ) );

		setText( c.text() );

		d->m_checked = c.isChecked();

		update();
	}
}
Cfg::Text
FormText::cfg() const
{
	Cfg::Text c;

	c.setObjectId( objectId() );

	Cfg::Point p;
	p.setX( pos().x() );
	p.setY( pos().y() );

	c.setPos( p );

	c.setTextWidth( textWidth() );

	c.setText( Cfg::text( textCursor(), toPlainText() ) );

	c.setLink( link() );

	return c;
}
Exemple #18
0
// Sets the value of the ownership ID data member.
//
Acad::ErrorStatus
AsdkOwnerDemo::setIdData(const AcDbHardOwnershipId& ownedId)
{
    if (ownedId.asOldId() == 0L) {
        return Acad::eInvalidInput;
    }
    assertWriteEnabled();

    mObjId = ownedId;

    // Now set the backpointer.  A transaction is used for
    // opening the object, so if the object is already
    // open it won't prevent this setting from taking place.
    //
    AcDbObject *pObj;
    AcTransaction *pTrans
        = actrTransactionManager->startTransaction();
    pTrans->getObject(pObj, ownedId, AcDb::kForWrite);
    pObj->setOwnerId(objectId());
    actrTransactionManager->endTransaction();

    return Acad::eOk;
}
Exemple #19
0
//------------------------------------------------------------------------------
int lookup(int *typeOfObject)
{
  int i;
  gettoken(yytext, sizeof yytext);
  for (i=0;i<EVAL_MAX_VARS;i++)
    if (!strcmpi(varTable[i].name, yytext))
    {
      *typeOfObject = IDENTIFIER;
      return i;
    }
  for (i=0;i<sizeof(fnTable)/sizeof(functionType);i++)
  {
    if (!strcmpi(fnTable[i].name, yytext))
    {
      *typeOfObject = objectId(fnTable[i].nParams);
      return i;
    }
  }
  *typeOfObject = IDENTIFIER;
  setLastVar();
  i = setVar(-1, 0);
  //(*errPtr)++;
  return i;
}
Exemple #20
0
const QString Audio::file() const
{
    return CoreSettings::getAudioDir() + ownerId() + QString("-") + objectId() + QString(".mp3");
}
Acad::ErrorStatus
ArxDbgDbEntity::deepClone(AcDbObject* pOwner,
              AcDbObject*& pClonedObject,
              AcDbIdMapping& idMap,
              Adesk::Boolean isPrimary) const
{
        // You should always pass back pClonedObject == NULL
        // if, for any reason, you do not actually clone it
        // during this call.  The caller should pass it in
        // as NULL, but to be safe, we set it here as well.
    pClonedObject = NULL;

	if (ArxDbgOptions::m_instance.m_showDeepCloneDetails) {
		CString titleStr, tmpStr;
		titleStr.Format(_T("Beginning -- deepClone: %s"),
				ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr));
		ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr);
		dbox.DoModal();
	}

    AcDb::DeepCloneType type = idMap.deepCloneContext();

        // if we know everything will be cloned for us, just let
		// the base class do everything for us.
    if ((type == AcDb::kDcInsert) ||
		(type == AcDb::kDcInsertCopy) ||
		(type == AcDb::kDcExplode))
        return AcDbEntity::deepClone(pOwner, pClonedObject, idMap, isPrimary);

        // following case happens when doing a AcDbDatabase::deepCloneObjects()
        // and the owner happens to be the same... then its really like a
        // kDcCopy, otherwise deepCloneObjects() is like a kDcBlock
    if (type == AcDb::kDcObjects) {
		if (ownerId() == pOwner->objectId())
			type = AcDb::kDcCopy;
		else
			type = AcDb::kDcBlock;
	}

		// now ask derived classes what references they want cloned for them
	AcDbObjectIdArray refEntIds;
	AcDbIntArray refTypes;
	getCloneReferences(type, refEntIds, refTypes);
	ASSERT(refEntIds.length() == refTypes.length());

		// if derived class doesn't have any references to take care of, then
		// we will just let the AcDbEntity::deepClone() take care of things.
	if (refEntIds.isEmpty())
		return AcDbEntity::deepClone(pOwner, pClonedObject, idMap, isPrimary);

        // If this object is in the idMap and is already
        // cloned, then return.
	bool tmpIsPrimary = isPrimary ? true : false;	// get around compiler performance warning
    AcDbIdPair idPair(objectId(), AcDbObjectId::kNull, false, tmpIsPrimary);
    if (idMap.compute(idPair) && (idPair.value() != NULL))
        return Acad::eOk;

    // STEP 1:
    // Create the clone
    //
    AcDbObject *pClone = (AcDbObject*)isA()->create();
    if (pClone != NULL)
        pClonedObject = pClone;    // set the return value
    else
        return Acad::eOutOfMemory;

    // STEP 2:
    // Append the clone to its new owner.  In this example,
    // we know that we are derived from AcDbEntity, so we
    // can expect our owner to be an AcDbBlockTableRecord,
    // unless we have set up an ownership relationship with
    // another of our objects.  In that case, we need to
    // establish how we connect to that owner in our own
    // way.  This sample shows a generic method using
    // setOwnerId().
    //
    AcDbBlockTableRecord *pBTR = AcDbBlockTableRecord::cast(pOwner);
    if (pBTR != NULL) {
        AcDbEntity* ent = AcDbEntity::cast(pClone);
        pBTR->appendAcDbEntity(ent);
    }
    else {
        if (isPrimary)
            return Acad::eInvalidOwnerObject;

        // Some form of this code is only necessary if
        // anyone has set up an ownership for our object
        // other than with an AcDbBlockTableRecord.
        //
        pOwner->database()->addAcDbObject(pClone);
        pClone->setOwnerId(pOwner->objectId());
    }

    // STEP 3:
    // Now we copy our contents to the clone.  This is done
    // using an AcDbDeepCloneFiler.  This filer keeps a
    // list of all AcDbHardOwnershipIds and
    // AcDbSoftOwnershipIds we, and any classes we derive
    // from,  have.  This list is then used to know what
    // additional, "owned" objects need to be cloned below.
    //
    AcDbDeepCloneFiler filer;
    dwgOut(&filer);

    // STEP 4:
    // Rewind the filer and read the data into the clone.

    //
    filer.seek(0L, AcDb::kSeekFromStart);
    pClone->dwgIn(&filer);

    // STEP 5:
    // This must be called for all newly created objects
    // in deepClone.  It is turned off by endDeepClone()
    // after it has translated the references to their
    // new values.
    //
    pClone->setAcDbObjectIdsInFlux();

    // STEP 6:
    // Add the new information to the idMap.  We can use
    // the idPair started above.
    //
    idPair.setValue(pClonedObject->objectId());
    idPair.setIsCloned(Adesk::kTrue);
    idMap.assign(idPair);

    // STEP 7:
    // Using the filer list created above, find and clone
    // any owned objects.
    //
    AcDbObject *pSubObject;
    AcDbObject *pClonedSubObject;
    AcDbObjectId id;
    Acad::ErrorStatus es;
    while (filer.getNextOwnedObject(id)) {
            // Open the object and clone it.  Note that we now
            // set "isPrimary" to kFalse here because the object
            // is being cloned, not as part of the primary set,
            // but because it is owned by something in the
            // primary set.
        es = acdbOpenAcDbObject(pSubObject, id, AcDb::kForRead);
        if (es != Acad::eOk)
            continue;   // could have been NULL or erased

        pClonedSubObject = NULL;
        pSubObject->deepClone(pClonedObject, pClonedSubObject, idMap, Adesk::kFalse);

            // If this is a kDcInsert context, the objects
            // may be "cheapCloned".  In this case, they are
            // "moved" instead of cloned.  The result is that
            // pSubObject and pClonedSubObject will point to
            // the same object.  So, we only want to close
            // pSubObject if it really is a different object
            // than its clone.
        if (pSubObject != pClonedSubObject)
            pSubObject->close();

            // The pSubObject may either already have been
            // cloned, or for some reason has chosen not to be
            // cloned.  In that case, the returned pointer will
            // be NULL.  Otherwise, since we have no immediate
            // use for it now, we can close the clone.
        if (pClonedSubObject != NULL)
            pClonedSubObject->close();
    }

        // clone the referenced entities
    AcDbObject* ent;
	int len = refEntIds.length();
	for (int i=0; i<len; i++) {
		if (refTypes[i] == kClone) {
			es = acdbOpenAcDbObject(ent, refEntIds[i], AcDb::kForRead);
			if (es == Acad::eOk) {
				pClonedSubObject = NULL;
				es = ent->deepClone(pOwner, pClonedSubObject, idMap, Adesk::kTrue);
				if (es == Acad::eOk) {
						// see comment above about cheap clone
					if (ent != pClonedSubObject)
						ent->close();

					if (pClonedSubObject != NULL)
						pClonedSubObject->close();
				}
			}
		}
			// this case is needed for RefEdit so we can pass its validation
			// test when editing a blockReference.  We don't actually clone it
			// but we add it to the map so it thinks it got cloned and is therefore
			// a valid "Closed Set" of objects.
		else if (refTypes[i] == kFakeClone) {
            AcDbIdPair idPair(refEntIds[i], refEntIds[i], false, false, true);
            idMap.assign(idPair);
		}
	}

	if (ArxDbgOptions::m_instance.m_showDeepCloneDetails) {
		CString titleStr, tmpStr;
		titleStr.Format(_T("End -- deepClone: %s"),
				ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr));
		ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr);
		dbox.DoModal();
	}

        // Leave pClonedObject open for the caller
    return Acad::eOk;
}
TEST(SaveLoadTest, SaveLoadLatestVersion)
{
    // Use the temp application.
    TaskSystem *pTempApp1 = new TaskSystem();
    TaskSystem* pPreviousApp = SetWorkingBrain(pTempApp1);

    {
        Parameter para(_T("OS"), _T("Windows7"));
        para.SetComments(_T("global"));
        GetWorkingBrain()->GetVariableManager()->AddUserParameter(para);
    }

    CString conditionId = _T("DoesRegExist");
    {
        ConditionPtr pRegCondition = Condition::Create(_T("RegisterKeyExistsCondition"), GetWorkingBrain()->GetBehaviorManager());
        Parameter objectId(OBJECT_ID, conditionId);
        Parameter para1(_T("RootKey"), _T("HKEY_LOCAL_MACHINE"));
        Parameter para2(_T("SubKey"), _T("Software\\Microsoft"));

        pRegCondition->GetParameterTable().AddParameter(objectId);
        pRegCondition->GetParameterTable().AddParameter(para1);
        pRegCondition->GetParameterTable().AddParameter(para2);

        //GetWorkingBrain()->GetBehaviorManager()->RegisterCondition(pRegCondition);
    }

    CString actionId = _T("DemoToRunSysCmd");
    {
        ActionPtr pNewAction = Action::Create(_T("RunSystemCommandAction"), GetWorkingBrain()->GetBehaviorManager());
        Parameter objectId(OBJECT_ID, actionId);
        objectId.SetComments(_T("Object Id is used to reference this object everywhere."));
        Parameter objectType;
        pNewAction->GetParameterTable().GetParameter(OBJECT_TYPE, objectType);
        objectType.SetComments(_T("Object type indicates which behavior body will this action invokes."));
        Parameter cmd(APPLICATION_NAME, _T("regedit.exe"));
        cmd.SetComments(_T("Indicate which command will be run"));
        pNewAction->GetParameterTable().AddParameter(objectId);
        pNewAction->GetParameterTable().AddParameter(objectType);
        pNewAction->GetParameterTable().AddParameter(cmd);

        //GetWorkingBrain()->GetBehaviorManager()->RegisterAction(pNewAction);
        GetWorkingBrain()->GetBehaviorManager()->AddActionTask(pNewAction);
    }

    CString fileName(_T("C:\\braintest.xml"));

    // Save
    bool ret = GetWorkingBrain()->XmlOut(fileName);
    EXPECT_EQ(true, ret);

    // Load
    TaskSystem *pTempApp2 = new TaskSystem();

    SetWorkingBrain(pTempApp2);

    ret = GetWorkingBrain()->XmlIn(fileName);
    EXPECT_EQ(true, ret);

    {
        ActionPtr pAction = GetWorkingBrain()->GetBehaviorManager()->GetActionById(actionId);
        EXPECT_EQ(true, (pAction != NULL));
    }

    {
        ConditionPtr pCondition = GetWorkingBrain()->GetBehaviorManager()->GetConditionById(conditionId);
        EXPECT_EQ(true, (pCondition != NULL));
    }

    // Recover
    SetWorkingBrain(pPreviousApp);
}
Acad::ErrorStatus
ArxDbgDbEntity::wblockClone(AcRxObject* pOwner, AcDbObject*& pClone,
                    AcDbIdMapping& idMap, Adesk::Boolean isPrimary) const
{
	if (ArxDbgOptions::m_instance.m_showWblockCloneDetails) {
		CString titleStr, tmpStr;
		titleStr.Format(_T("Beginning -- wblockClone: %s"),
				ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr));
		ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr);
		dbox.DoModal();
	}

    AcDb::DeepCloneType type = idMap.deepCloneContext();

        // if xrefInsert or xrefBind, we know everything will
        // be cloned, so just let normal routine handle this
    if ((type == AcDb::kDcXrefBind) || (type == AcDb::kDcXrefInsert)) {
        return AcDbEntity::wblockClone(pOwner, pClone, idMap, isPrimary);
    }
		// if we've already been cloned, just return
	AcDbIdPair idPair(objectId(), AcDbObjectId::kNull, true);
    if (idMap.compute(idPair) && (idPair.value() != AcDbObjectId::kNull)) {
        return Acad::eOk;
    }

        // If isPrimary is kTrue, then override the default cloning
        // within our own cloning, which would set it to kFalse,
        // by cloning our referenced entity first.
    if (isPrimary) {
			// now ask derived classes what references they want cloned for them
		AcDbObjectIdArray refEntIds;
		AcDbIntArray refTypes;
		getCloneReferences(type, refEntIds, refTypes);

		ASSERT(refEntIds.length() == refTypes.length());

            // clone each entity we reference first and change the value
            // of isPrimary to fake it out.  Since we clone these first,
            // when the normal wblockClone is called, it will see that
            // they are already in the set of cloned objects and will not
            // try to clone it again.
        AcDbEntity* ent;
        Acad::ErrorStatus es;
		int len = refEntIds.length();
		for (int i=0; i<len; i++) {
			if (refTypes[i] == kClone) {
				es = acdbOpenAcDbEntity(ent, refEntIds[i], AcDb::kForRead);
				if (es == Acad::eOk) {
						// this method only works if they come from the same block
						// (which SHOULD always be the case!)
					if (blockId() == ent->blockId()) {
							// Use the same owner, and pass in the same isPrimary value
						AcDbObject* pSubClone = NULL;
						es = ent->wblockClone(pOwner, pSubClone, idMap, Adesk::kTrue);
						if (pSubClone != NULL)
							pSubClone->close();

						if (es != Acad::eOk) {
							ASSERT(0);
						}
					}
					else {
						ASSERT(0);
					}

					ent->close();
				}
			}
		}
    }
        // Now we can clone ourselves via calling our parent's method.
	Acad::ErrorStatus es =  AcDbEntity::wblockClone(pOwner, pClone, idMap, isPrimary);

	if (ArxDbgOptions::m_instance.m_showWblockCloneDetails) {
		CString titleStr, tmpStr;
		titleStr.Format(_T("End -- wblockClone: %s"),
				ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr));
		ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr);
		dbox.DoModal();
	}

	return es;
}
void ScreenshotService::getScreenshot(TasCommandModel& model, TasResponse& response)
{
    QListIterator<TasTarget*> i(model.targetList());
    QString errorMsg = PARSE_ERROR;
    QImage screenshot;
    QString pictureFormat = "PNG";
    while (i.hasNext()) {
        TasTarget* commandTarget = i.next();
        QString targetId = commandTarget->id();
        QString targetType = commandTarget->type();
        TasCommand* command = commandTarget->findCommand("Screenshot");

        // are required for command completion
        if (targetId.isEmpty() || targetType.isEmpty() || !command) {
            continue;
        }

        if (!command->parameter("format").isEmpty()) {
            pictureFormat = command->parameter("format");
        }

        if (!isFormatSupported(pictureFormat)) {
            errorMsg = "Given format " + pictureFormat + "is not supported. Supported formats are: PNG, JPEG and BMP.";
            break;
        }

        bool draw = (command->parameter("draw") == "true");

        QWidget* widget = 0;
        QQuickWindow* qtQuickWindow = 0;
        WId winId = 0;
        QRect rect(0,0,-1,-1);

        errorMsg = "Taking screenshot failed!";

        if (targetType == TYPE_GRAPHICS_VIEW) {
            //TasLogger::logger()->debug("TYPE_GRAPHICS_VIEW Target id:" + targetId);
            QGraphicsItem* item = findGraphicsItem(targetId);

            if (item) {
                QGraphicsView* view = getViewForItem(item);
                if(view) {
                    ItemLocationDetails locationDetails = TestabilityUtils::getItemLocationDetails(item);
                    rect = QRect(locationDetails.windowPoint.x(),
                                 locationDetails.windowPoint.y(),
                                 locationDetails.width,
                                 locationDetails.height);

                    if (draw) {
                        widget = view->window();
                    } else {
                        winId = view->window()->winId();
                    }
                } else {
                    errorMsg = "Could not find a GraphicsView for the GraphicsItem!";
                }
            } else {
                errorMsg = "Could not find the GraphicsItem!";
            }
        } else if (targetType == TYPE_STANDARD_VIEW) {
            //TasLogger::logger()->debug("TYPE_STANDARD_VIEW about to find widget Target id:" + targetId);
            widget = findWidget(targetId);

            if (widget) {
                if ((widget->isWindow() && !draw) || widget->inherits("QDesktopWidget")) {
                    winId = widget->winId();
                    widget = 0;
                } else if (!draw) {
                    QPoint point = widget->mapToGlobal(QPoint(0,0));
                    QPoint windowPoint = widget->window()->mapFromGlobal(point);

                    rect = QRect(windowPoint.x(),
                                 windowPoint.y(),
                                 widget->rect().width(),
                                 widget->rect().width());
                    winId = widget->window()->winId();
                    widget = 0;
                }
            } else {
                TasLogger::logger()->debug("ScreenshotService::executeService application has no visible ui!");
                errorMsg = "Application has no visible ui!";
            }
        } else if (targetType == TYPE_QSCENEGRAPH) {
            QQuickItem* item = TestabilityUtils::findQuickItem(targetId);

            if (item) {
                QPointF offset = item->mapToScene(QPointF(0,0));
                rect = QRect(-offset.x(), -offset.y(), item->width(), item->height());
                qtQuickWindow = item->window();
            }
        } else {
            //TasLogger::logger()->debug("TYPE_APPLICATION_VIEW about to find application window Target id:" + targetId);
            widget = getApplicationWidget();

            if (!widget) {
                QWindow *window = getApplicationWindow();
                //in case no window false, return the desktop
                qtQuickWindow = qobject_cast<QQuickWindow *>(window);

                if (!window) {
                    widget = qApp->desktop();
                }
            }
        }

        if (widget) {
            screenshot = widget->grab(rect).toImage();

            if (!screenshot.isNull()) {
                screenshot.setText("tas_id", objectId(widget));
            }
        } else if (qtQuickWindow) {
            screenshot = qtQuickWindow->grabWindow();
            if (!screenshot.isNull()) {
                screenshot.setText("tas_id", objectId(qtQuickWindow));
            }
        } else if (winId) {
            screenshot = QPixmap::grabWindow(winId, rect.x(), rect.y(), rect.width(), rect.height()).toImage();

            if (!screenshot.isNull()) {
                screenshot.setText("tas_id", QString::number(winId));
            }
        }

        break;
    }

    if (!screenshot.isNull()) {
        QByteArray bytes;
        QBuffer buffer(&bytes);
        buffer.open(QIODevice::WriteOnly);
        screenshot.save(&buffer, pictureFormat.toLatin1());
        response.setData(bytes);
        buffer.close();
    } else {
        response.setErrorMessage(errorMsg);
    }

}
Exemple #25
0
// Getters
const QString Audio::audioId() const { return objectId(); }
Exemple #26
0
bool 
AcRectangle::updateDimensions(AcDbDimDataPtrArray* pDimData)
{
    if (!pDimData || (pDimData->length() <= 0))
        return false;		

    int numDims = pDimData->length();
    AcDbObjectId entId = objectId();
    AcGeVector3d vertDir = mNormal.crossProduct(mHorizDir);

    AcGePoint3d pt1, pt2, pt3, pt4, dimPt, textPt;
    pt1 = mCenter + 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
    pt2 = mCenter - 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
    pt3 = mCenter - 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;
    pt4 = mCenter + 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir; 

    AcDbObjectId ownerId;

    for (int i = 0; i < numDims; i++) {
         AcDbDimData *pData = (*pDimData)[i];
         ownerId = pData->ownerId();
         if (!entId.isNull() && (entId != ownerId))
             continue;

         AppData *pDimAppData = (AppData*)pData->appData();
         int dimIndex = pDimAppData ? pDimAppData->index() : 0;
         double dimScale = pDimAppData->dimScale();
         AcDbDimension *pDim = (AcDbDimension*)pData->dimension();

         if (pDim->isKindOf(AcDbAlignedDimension::desc())) {
             AcDbAlignedDimension *pAlnDim = AcDbAlignedDimension::cast(pDim);
             //pAlnDim->setDimjust(1);

             switch (dimIndex) {
             case 1:
                 textPt = pt2 + 1.0 * vertDir;
                 dimPt = mCenter + (0.5 * mHeight + 0.5 * dimScale) * vertDir;
                 pAlnDim->setXLine1Point(pt1);
                 pAlnDim->setXLine2Point(pt2);
                 pAlnDim->setDimLinePoint(dimPt);
                 //pAlnDim->setTextPosition(textPt);
                 break;

             case 2:
				 textPt = pt1 + 1.0 * mHorizDir;
                 dimPt = mCenter + (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
                 pAlnDim->setXLine1Point(pt1);
                 pAlnDim->setXLine2Point(pt4);
                 pAlnDim->setDimLinePoint(dimPt);
                 //pAlnDim->setTextPosition(textPt);
                 break;

             case 3:
				 textPt = pt2 + 1.0 * vertDir;
                 dimPt = mCenter + (0.5 * mHeight + 0.5 * dimScale) * vertDir;
                 pAlnDim->setXLine1Point(pt1);
                 pAlnDim->setXLine2Point(pt2);
                 pAlnDim->setDimLinePoint(dimPt);
                 //pAlnDim->setTextPosition(textPt);
                 break;

             case 4:
				 textPt = pt1 + 1.0 * mHorizDir;
                 dimPt = mCenter + (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
                 pAlnDim->setXLine1Point(pt1);
                 pAlnDim->setXLine2Point(pt4);
                 pAlnDim->setDimLinePoint(dimPt);
                 //pAlnDim->setTextPosition(textPt);
                 break;

             case 5:
                 dimPt = mCenter + (0.5 * mHeight + 0.5 * dimScale) * vertDir;
                 pAlnDim->setXLine1Point(pt1);
                 pAlnDim->setXLine2Point(pt2);
                 pAlnDim->setDimLinePoint(dimPt);
                 break;

             case 6:
                 dimPt = mCenter - (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
                 pAlnDim->setXLine1Point(pt2);
                 pAlnDim->setXLine2Point(pt3);
                 pAlnDim->setDimLinePoint(dimPt);
                 break;

             case 7:
                 dimPt = mCenter - (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
                 pAlnDim->setXLine1Point(pt2);
                 pAlnDim->setXLine2Point(pt3);
                 pAlnDim->setDimLinePoint(dimPt);
                 break;

             case 8:
                 dimPt = mCenter - (0.5 * mHeight + 0.5 * dimScale) * vertDir;
                 pAlnDim->setXLine1Point(pt3);
                 pAlnDim->setXLine2Point(pt4);
                 pAlnDim->setDimLinePoint(dimPt);
                 break;

             case 9:
                 dimPt = mCenter - (0.5 * mHeight + 0.5 * dimScale) * vertDir;
                 pAlnDim->setXLine1Point(pt3);
                 pAlnDim->setXLine2Point(pt4);
                 pAlnDim->setDimLinePoint(dimPt);
                 break;

             case 10:
                 dimPt = mCenter + (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
                 pAlnDim->setXLine1Point(pt4);
                 pAlnDim->setXLine2Point(pt1);
                 pAlnDim->setDimLinePoint(dimPt);
                 break;
             }
         }
    }

    return true;
}
// -----------------------------------------------------------------------------
// CContextEnginePluginTest::CreateObjects
// -----------------------------------------------------------------------------
//
TInt CContextEnginePluginTest::CreateObjectsL( CStifItemParser& aItem )
    {
	CMdENamespaceDef& defaultNamespace = iMdEClient->GetDefaultNamespaceDefL();
	CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject );
	
	// Mandatory parameters for any object.
	CMdEPropertyDef& creationDef = imageDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty );
	CMdEPropertyDef& modifiedDef = imageDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
	CMdEPropertyDef& sizeDef = imageDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
	CMdEPropertyDef& itemTypeDef = imageDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
	
	CMdEPropertyDef& descriptionPropertyDef = imageDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty );
	CMdEPropertyDef& widthDef = imageDef.GetPropertyDefL( MdeConstants::MediaObject::KWidthProperty ); 
	CMdEPropertyDef& heightDef = imageDef.GetPropertyDefL( MdeConstants::MediaObject::KHeightProperty ); 
	CMdEPropertyDef& makeDef = imageDef.GetPropertyDefL( MdeConstants::Image::KMakeProperty );
	CMdEPropertyDef& modelDef = imageDef.GetPropertyDefL( MdeConstants::Image::KModelProperty );
    
	CMdEObject* object = NULL;
	TItemId objectId(0);
	TTime currTime;
	TPtrC inputFile;
	TInt count(0);
	TBuf <100> msg;
	
	iIds.Reset();
	
	User::LeaveIfError( aItem.GetNextInt( count ));
	
	for ( TInt i = 0; i < count; ++i )
		{			
		User::LeaveIfError( aItem.GetNextString( inputFile ));
		
		// create object
		iMdEClient->RemoveObjectL(inputFile);
		object = iMdEClient->NewObjectLC(imageDef, inputFile);
		
		currTime.HomeTime();
		object->AddTimePropertyL(creationDef, currTime);
		object->AddTimePropertyL(modifiedDef, currTime);
		object->AddUint32PropertyL( sizeDef, 0 );
		object->AddTextPropertyL( itemTypeDef, MdeConstants::Image::KImageObject );
		
		objectId = iMdEClient->AddObjectL(*object);
		iIds.Append(objectId);
		
		CleanupStack::PopAndDestroy(object);
		object = NULL;
		
		// open object for modification
		TRAPD( openError, object = iMdEClient->OpenObjectL(objectId) );
			
		if ( !object || openError != KErrNone )
			{
			_LIT( KOpenErr, "        ModifyObjects - Open error : %d" );
		    msg.Format(KOpenErr, openError);
		    iLog->Log( msg );
		    RDebug::Print(msg);
		    
		    User::LeaveIfError(openError);
			}

		CleanupStack::PushL( object );		
		
		// add properties
   		CMdEProperty* property = NULL;
   		
   		// Description
   		_LIT( KDesc, "Description" );
		object->Property( descriptionPropertyDef, property );
		
		if ( property )
			{					
			property->SetTextValueL( KDesc );
			}
		else
			{
			object->AddTextPropertyL( descriptionPropertyDef, KDesc );
			}
		
		property = NULL;
		
		// Width
		object->Property( widthDef, property );
		
		if ( property )
			{
			property->SetUint16ValueL( 100 );
			}
		else
			{
			object->AddUint16PropertyL( widthDef, 100 );
			}
		
		property = NULL;
			
		// Height
		object->Property( heightDef, property );
		
		if ( property )
			{
			property->SetUint16ValueL( 100 );
			}
		else
			{
			object->AddUint16PropertyL( heightDef, 100 );
			}
		
		property = NULL;
		
		// Maker
		object->Property( makeDef, property );
		
        _LIT( KOnkia, "Maker" );
		if ( property )
			{
			property->SetTextValueL( KOnkia );
			}
		else
			{
			object->AddTextPropertyL( makeDef, KOnkia );
			}
			
		property = NULL;
			
		// Model
		object->Property( modelDef, property );
        _LIT( KModel, "Model" );
		if ( property )
			{					
			property->SetTextValueL( KModel );
			}
		else
			{
			object->AddTextPropertyL( modelDef, KModel );
			}
		
		// Commit object
		TRAPD( commitError, iMdEClient->CommitObjectL(*object) );
		if ( commitError != KErrNone )
			{		
			_LIT( KCommErr, "        CreateObjects - Commit error : %d" );
		    msg.Format(KCommErr, commitError);
		    iLog->Log( msg );
		    RDebug::Print(msg);
		    
		    User::LeaveIfError(commitError);
			}
		
		CleanupStack::PopAndDestroy(object);
		object = NULL;
		}
	
    _LIT( KMsg, "Exit    EndCreateObjects" );
    iLog->Log( KMsg );  
    RDebug::Print( KMsg );
	
    return KErrNone;
    }