コード例 #1
0
ファイル: ccDBRoot.cpp プロジェクト: markgenemei/trunk
void ccDBRoot::selectEntity(int uniqueID)
{
	ccHObject* obj = 0;
    //minimum unqiue ID is 1 (0 means 'deselect')
    if (uniqueID>0)
        obj = find(uniqueID);

	selectEntity(obj);
}
コード例 #2
0
ファイル: newinvoicedialog.cpp プロジェクト: j2sg/JIM
void View::NewInvoiceDialog::createConnections()
{
    connect(_buyRadioButton, SIGNAL(toggled(bool)),
            this, SLOT(toggledOnRadioButton()));
    connect(_saleRadioButton, SIGNAL(toggled(bool)),
            this, SLOT(toggledOnRadioButton()));
    connect(_selectButton, SIGNAL(clicked()),
            this, SLOT(selectEntity()));
    connect(_createButton, SIGNAL(clicked()),
            this, SLOT(accept()));
    connect(_cancelButton, SIGNAL(clicked()),
            this, SLOT(reject()));
}
コード例 #3
0
ファイル: App.cpp プロジェクト: A7med-Shoukry/g3d
bool App::onEvent(const GEvent& event) {
    if (GApp::onEvent(event)) {
        return true;
    }

    if (event.type == GEventType::VIDEO_RESIZE) {
        // Example GUI dynamic layout code.  Resize the debugWindow to fill
        // the screen horizontally.
        debugWindow->setRect(Rect2D::xywh(0, 0, window()->width(), debugWindow->rect().height()));
    }


    if (! m_preventEntitySelect && (event.type == GEventType::MOUSE_BUTTON_DOWN) && (event.button.button == 0)) {
        // Left click: select by casting a ray through the center of the pixel
        const Ray& ray = defaultCamera.worldRay(event.button.x + 0.5f, event.button.y + 0.5f, renderDevice->viewport());
        
        float distance = finf();

        selectEntity(m_scene->intersect(ray, distance));
    }
    

    if (! m_preventEntitySelect && (event.type == GEventType::GUI_ACTION) && (event.gui.control == m_entityList)) {
        // User clicked on dropdown list
        selectEntity(m_scene->entity(m_entityList->selectedValue().text()));
    }

    // If you need to track individual UI events, manage them here.
    // Return true if you want to prevent other parts of the system
    // from observing this specific event.
    //
    // For example,
    // if ((event.type == GEventType::GUI_ACTION) && (event.gui.control == m_button)) { ... return true;}
    // if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey::TAB)) { ... return true; }

    return false;
}
コード例 #4
0
void
trimSurface()
{								  
    AcBr::ErrorStatus returnValue = AcBr::eOk;
    Acad::ErrorStatus acadReturnValue = eOk;

    // Get the subentity path for a face
	AcDbFullSubentPath subPath(kNullSubent);
	acadReturnValue = selectEntity(AcDb::kFaceSubentType, subPath);
	if (acadReturnValue != eOk) {
		acutPrintf(ACRX_T("\n Error in getPath: %d"), acadReturnValue);
		return;
	}

	// Make a face entity to access the surface
	AcBrFace faceEntity;
	returnValue = faceEntity.set(subPath);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrFace::set:"));
		errorReport(returnValue);
		return;
	}

	// Query the style for trimmed surface dump
	Adesk::Boolean trimmed = Adesk::kTrue;
    ACHAR opt[128];
   	while (Adesk::kTrue) {
		acutPrintf(ACRX_T("\nSelect Style for Trimmed Surface Dump: "));
		acedInitGet(NULL, ACRX_T("Nurb Trimmed"));
		if (acedGetKword(ACRX_T("Nurb/<Trimmed>: "), opt) == RTCAN) return;

        // Map the user input to a valid dump style
		if ((_tcscmp(opt, ACRX_T("Trimmed")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) {
            trimmed = Adesk::kTrue;
            break;
        } else if ((_tcscmp(opt, ACRX_T("Nurb")) == 0)) {
            trimmed = Adesk::kFalse;
            break;
	    }
    }

	(trimmed) ? faceToTrimmedSurface(faceEntity) : faceToNurbSurface(faceEntity);

	return;
}
コード例 #5
0
EditorWindow::EditorWindow() : QMainWindow(), newmap(this), editgroup(this)
{
	ui.setupUi(this);

	// Set up input
	QObject::connect(ui.ActionNew, SIGNAL(activated()), &newmap, SLOT(exec()));
	QObject::connect(ui.ActionOpen, SIGNAL(activated()), this, SLOT(openDialog()));
	QObject::connect(ui.ActionSave, SIGNAL(activated()), this, SLOT(save()));
	QObject::connect(ui.ActionSaveAs, SIGNAL(activated()), this, SLOT(saveAs()));
	QObject::connect(ui.ActionCompile, SIGNAL(activated()), this, SLOT(compile()));
	QObject::connect(ui.ActionAbout, SIGNAL(activated()), this, SLOT(about()));
	QObject::connect(&newmap, SIGNAL(accepted()), this, SLOT(newMap()));
	QObject::connect(&openmap, SIGNAL(accepted()), this, SLOT(open()));
	QObject::connect(ui.ActionGrid, SIGNAL(toggled(bool)), ui.levelview, SLOT(showGrid(bool)));
	ui.ActionGrid->setChecked(true);
	QObject::connect(ui.ActionMiniMap, SIGNAL(toggled(bool)), ui.levelview, SLOT(showMiniMap(bool)));
	ui.ActionMiniMap->setChecked(true);
	QObject::connect(ui.resize, SIGNAL(clicked()), this, SLOT(resize()));
	QObject::connect(ui.tilelist, SIGNAL(clicked(QModelIndex)), this, SLOT(selectTile(QModelIndex)));
	QObject::connect(ui.entitylist, SIGNAL(clicked(QModelIndex)), this, SLOT(selectEntity(QModelIndex)));
	QObject::connect(ui.toolbox, SIGNAL(currentChanged(int)), this, SLOT(selectPanel(int)));
	// Create edit input group
	editgroup.addAction(ui.ActionDraw);
	editgroup.addAction(ui.ActionErase);
	editgroup.addAction(ui.ActionSelect);
	editgroup.setExclusive(true);
	ui.ActionSelect->setChecked(true);
	QObject::connect(&editgroup, SIGNAL(triggered(QAction*)), this, SLOT(setAction(QAction*)));
	// Fill tile list
	std::vector<std::string> tilenames = TileSet::getTiles();
	for (unsigned int i = 0; i < tilenames.size(); i++)
	{
		tilelist.appendRow(new QStandardItem(tilenames[i].c_str()));
	}
	ui.tilelist->setModel(&tilelist);
	// Fill entity list
	std::vector<std::string> entitynames = Game::get().getEntities();
	for (unsigned int i = 0; i < entitynames.size(); i++)
	{
		entitylist.appendRow(new QStandardItem(entitynames[i].c_str()));
	}
	ui.entitylist->setModel(&entitylist);
}
コード例 #6
0
ファイル: CRenderWidget.cpp プロジェクト: Jirachi/Nyuu
//---------------------------------------------------------------------------
void CRenderWidget::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton)
    {
        mIsLeftMouseDown = true;
        mMouseDownPosition = event->pos();

        QGraphicsItem* item = itemAt(event->pos());

        // if we pressed control key, duplicate the selection
        // if user drags mouse
        if (mIsCtrlKeyDown)
        {
            mDoCopySelection = true;
        }

        selectEntity(item);
    }
}
コード例 #7
0
ファイル: CRenderWidget.cpp プロジェクト: Jirachi/Nyuu
//---------------------------------------------------------------------------
void CRenderWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (mIsLeftMouseDown && mSelectedItems.size() > 0)
    {
        // Lookup the entity
        CEntity* entity = Globals::getCurrentScene()->getEntityFromGraphicsView(mSelectedItems.first());

        if (!entity)
        {
            QMessageBox::critical(this, "Erreur!", "Impossible de retrouver l'entité attachée au graphique sélectionné!");
            return;
        }

        QPoint delta = event->pos() - mMouseDownPosition;

        if (mDoCopySelection)
        {
            // Hep, stop right there! We want to duplicate the selection, and switch our current pick to the copied
            // entity, and move it.
            entity = Globals::getCurrentScene()->cloneEntity(entity);
            selectEntity(entity->getSceneItem());

            mDoCopySelection = false;
        }

        // Move the entity
        QPoint gridDelta = delta;//QPoint(ceil(delta.x() / 16.f) * 16.f, ceil(delta.y() / 16.f) * 16.f);
        Vector2D finalPos = mOriginalPosition + Vector2D(gridDelta.x(), gridDelta.y());

        entity->setPosition(finalPos);

        emit itemChanged();

        // Move selection rects
        for (QList<QGraphicsItem*>::iterator it = mSelectionRects.begin(); it != mSelectionRects.end(); ++it)
        {
            QGraphicsItem* rect = (*it);
            rect->setPos(gridDelta);
        }
    }
}
コード例 #8
0
AcBr::ErrorStatus
selectEntityByType(AcBrEntity*& pEnt, AcDb::SubentType& subType)
{
	Acad::ErrorStatus acadReturnValue = Acad::eOk;
	AcBr::ErrorStatus returnValue = AcBr::eOk;

	// Query validation level
	AcBr::ValidationLevel vlevel = validationLevel();

	// Query the subentity type
	subType = subtype();

	// Query whether to select a database entity or create a new one
	Adesk::Boolean context = (subType != AcDb::kNullSubentType)
		? Adesk::kFalse : localContext();

	if (!context) {
		// Query the subentity by AutoCAD pick and get the subentity path
		AcDbFullSubentPath subPath(kNullSubent);
		acadReturnValue = selectEntity(subType, subPath);
		if (acadReturnValue != Acad::eOk) {
			acutPrintf(ACRX_T("\n Error in selectEntity: %d"), acadReturnValue);
			return (AcBr::ErrorStatus)acadReturnValue;
		}

		// Call the appropriate subentity constructor
		switch (subType) {
		case AcDb::kNullSubentType:
    		pEnt = new AcBrBrep();
			break;
		case AcDb::kFaceSubentType:
    		pEnt = new AcBrFace();
			break;
		case AcDb::kEdgeSubentType:
    		pEnt = new AcBrEdge();
			break;  
		default:
			acutPrintf(ACRX_T("\n selectEntityByType: unsupported subentity type: %d\n"), subType);
			returnValue = (AcBr::ErrorStatus)Acad::eWrongSubentityType;
			return returnValue;
		}
		if (pEnt == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

		returnValue = pEnt->set(subPath);
		if (returnValue != AcBr::eOk) {
    		acutPrintf(ACRX_T("\n Error in AcBrEntity::set:"));
    		errorReport(returnValue);
    		return returnValue;
		}
	} else {
		// Create the entity as a local object
		AcDbEntity* pEntity;
		acadReturnValue = createEntity(pEntity);
		if (acadReturnValue != Acad::eOk) {
			acutPrintf(ACRX_T("\n Error in createEntity: %d"), acadReturnValue);
			return (AcBr::ErrorStatus)acadReturnValue;
		}
		if (pEntity == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

    	pEnt = new AcBrBrep();
		if (pEnt == NULL) {
			acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n"));
			returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory;
			return returnValue;
		}

		returnValue = ((AcBrBrep*)pEnt)->set((const AcDbEntity&)*pEntity);
		if (returnValue != AcBr::eOk) {
    		acutPrintf(ACRX_T("\n Error in AcBrEntity::set:"));
    		errorReport(returnValue);
    		return returnValue;
		}
	}

	returnValue = pEnt->setValidationLevel(vlevel);
	if (returnValue != AcBr::eOk) {
    	acutPrintf(ACRX_T("\n Error in AcBrEntity::setValidationLevel:"));
    	errorReport(returnValue);
    	return returnValue;
	}

	return returnValue;
}
コード例 #9
0
ファイル: brcount.cpp プロジェクト: Bohr27/ObjectARXCore
void
countSubents()
{
    AcBr::ErrorStatus returnValue = AcBr::eOk;
    Acad::ErrorStatus acadReturnValue = eOk;

    // Get the subentity path for a brep
	AcDbFullSubentPath subPath(kNullSubent);
	acadReturnValue = selectEntity(AcDb::kNullSubentType, subPath);
	if (acadReturnValue != eOk) {
		acutPrintf(ACRX_T("\n Error in getPath: %d"), acadReturnValue);
		return;
	}

	// Make a brep entity to access the solid
	AcBrBrep brepEntity;
	returnValue = ((AcBrEntity*)&brepEntity)->set(subPath);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in AcBrBrep::set:"));
		errorReport(returnValue);
		return;
	}

	// count the unique complexes in the brep
	returnValue = countComplexes(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in countComplexes:"));
		errorReport(returnValue);
		return;
	}

	// count the unique shells in the brep
	returnValue = countShells(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in countShells:"));
		errorReport(returnValue);
		return;
	}

	// count the unique faces in the brep
	returnValue = countFaces(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in countFaces:"));
		errorReport(returnValue);
		return;
	}

	// count the unique edges in the brep
	returnValue = countEdges(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in countEdges:"));
		errorReport(returnValue);
		return;
	}

	// count the unique vertices in the brep
	returnValue = countVertices(brepEntity);
	if (returnValue != AcBr::eOk) {
		acutPrintf(ACRX_T("\n Error in countVertices:"));
		errorReport(returnValue);
		return;
	}

	return;
}