本文整理汇总了C++中MgShape::getID方法的典型用法代码示例。如果您正苦于以下问题:C++ MgShape::getID方法的具体用法?C++ MgShape::getID怎么用?C++ MgShape::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MgShape
的用法示例。
在下文中一共展示了MgShape::getID方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _click
bool MgCommandDraw::_click(const MgMotion* sender)
{
Box2d limits(sender->pointM, sender->displayMmToModel(10.f), 0);
MgHitResult res;
MgShape* shape = sender->view->shapes()->hitTest(limits, res);
if (shape) {
sender->view->setNewShapeID(shape->getID());
sender->toSelectCommand();
LOGD("Command (%s) cancelled after the shape #%d clicked.", getName(), shape->getID());
}
return shape || (sender->view->useFinger() && longPress(sender));
}
示例2: eraseWnd
void MgCmdManagerImpl::eraseWnd(const MgMotion* sender)
{
Box2d snap(sender->view->xform()->getWndRectM());
std::vector<int> delIds;
void *it = NULL;
MgShapes* s = sender->view->shapes();
for (MgShape* shape = s->getFirstShape(it); shape; shape = s->getNextShape(it)) {
if (shape->shape()->hitTestBox(snap)) {
delIds.push_back(shape->getID());
}
}
s->freeIterator(it);
if (!delIds.empty()
&& sender->view->shapeWillDeleted(s->findShape(delIds.front()))) {
MgShapesLock locker(MgShapesLock::Remove, sender->view);
for (std::vector<int>::iterator i = delIds.begin(); i != delIds.end(); ++i) {
MgShape* shape = s->findShape(*i);
if (shape && sender->view->removeShape(shape)) {
shape->release();
}
}
sender->view->regenAll();
}
}
示例3: addImageShape
MgShape* MgCmdManagerImpl::addImageShape(const MgMotion* sender,
const char* name, float width, float height)
{
if (!name || *name == 0 || width < 1 || height < 1)
return NULL;
Vector2d size(Vector2d(width, height) * sender->view->xform()->displayToWorld());
while (fabsf(size.x) > 200.f || fabsf(size.y) > 200.f) {
size *= 0.95f;
}
Box2d rect(sender->view->xform()->getWndRectW() + Vector2d(10.f, -10.f));
rect = Box2d(rect.leftTop(), rect.leftTop() + size);
rect *= sender->view->xform()->worldToModel();
MgShapeT<MgImageShape> shape;
MgImageShape* imagesp = (MgImageShape*)shape.shape();
shape.context()->setLineStyle(kGiLineNull); // 默认没有边框
shape.context()->setFillColor(GiColor::White()); // 设为实填充,避免在中心无法点中
imagesp->setName(name);
imagesp->setRect2P(rect.leftTop(), rect.rightBottom());
MgShapesLock locker(MgShapesLock::Add, sender->view);
if (sender->view->shapeWillAdded(&shape)) {
MgShape* newsp = sender->view->shapes()->addShape(shape);
sender->view->shapeAdded(newsp);
sender->view->setNewShapeID(newsp->getID());
sender->view->cancel(sender);
return newsp;
}
return NULL;
}
示例4: _hitTest
float MgComposite::_hitTest(const Point2d& pt, float tol, MgHitResult& res) const
{
void* it;
MgHitResult tmpRes;
Box2d limits(pt, 2 * tol, 0);
res.segment = 0;
res.dist = _FLT_MAX;
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it))
{
if (limits.isIntersect(sp->shapec()->getExtent())) {
float d = sp->shapec()->hitTest(pt, tol, tmpRes);
if (res.dist > d - _MGZERO)
{
res = tmpRes;
res.dist = d;
res.segment = sp->getID();
}
}
}
_shapes->freeIterator(it);
return res.segment != 0;
}
示例5: _hitTest
float MgComposite::_hitTest(const Point2d& pt, float tol, Point2d& nearpt,
int& segment, bool& inside) const
{
void* it;
float mindist = 1e10f;
Point2d tmpNear;
int tmpseg;
bool tmpIn;
Box2d limits(pt, 2 * tol, 0);
segment = 0;
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it))
{
if (limits.isIntersect(sp->shapec()->getExtent())) {
float d = sp->shapec()->hitTest(pt, tol, tmpNear, tmpseg, tmpIn);
if (mindist > d - _MGZERO) {
mindist = d;
nearpt = tmpNear;
segment = sp->getID();
inside = tmpIn;
}
}
}
_shapes->freeIterator(it);
return mindist;
}
示例6: _click
bool MgCommandDraw::_click(const MgMotion* sender)
{
Box2d limits(sender->pointM, mgDisplayMmToModel(10, sender), 0);
Point2d nearpt;
MgShape* shape = sender->view->shapes()->hitTest(limits, nearpt);
if (shape) {
g_newShapeID = shape->getID();
mgGetCommandManager()->setCommand(sender, "select");
}
return shape || longPress(sender);
}
示例7: _addshape
MgShape* MgCommandDraw::_addshape(const MgMotion* sender, MgShape* shape)
{
MgShapesLock locker(sender->view->shapes(), MgShapesLock::Add);
shape = shape ? shape : m_shape;
MgShape* newsp = NULL;
if (locker.locked() && sender->view->shapeWillAdded(shape)) {
newsp = sender->view->shapes()->addShape(*shape);
sender->view->shapeAdded(newsp);
g_newShapeID = newsp->getID();
}
if (m_shape && sender->view->context()) {
*m_shape->context() = *sender->view->context();
}
return newsp;
}
示例8: touchMoved
bool MgCmdErase::touchMoved(const MgMotion* sender)
{
Box2d snap(sender->startPointM, sender->pointM);
void *it = NULL;
MgShape* shape = m_boxsel ? sender->view->shapes()->getFirstShape(it) : NULL;
m_delIds.clear();
for (; shape; shape = sender->view->shapes()->getNextShape(it)) {
if (isIntersectMode(sender) ? shape->shape()->hitTestBox(snap)
: snap.contains(shape->shape()->getExtent())) {
m_delIds.push_back(shape->getID());
}
}
sender->view->shapes()->freeIterator(it);
sender->view->redraw(false);
return true;
}
示例9: addShape
MgShape* MgCommandDraw::addShape(const MgMotion* sender, MgShape* shape, bool autolock)
{
MgShapesLock locker(MgShapesLock::Add, autolock ? sender->view : NULL);
shape = shape ? shape : m_shape;
MgShape* newsp = NULL;
if ((locker.locked() || !autolock) && sender->view->shapeWillAdded(shape)) {
newsp = sender->view->shapes()->addShape(*shape);
sender->view->shapeAdded(newsp);
sender->view->getCmdSubject()->onShapeAdded(sender, newsp);
if (strcmp(getName(), "splines") != 0) {
sender->view->setNewShapeID(newsp->getID());
}
}
if (m_shape && sender->view->context()) {
*m_shape->context() = *sender->view->context();
}
return newsp;
}
示例10: addImageShape
MgShape* MgCmdManagerImpl::addImageShape(const MgMotion* sender, const char* name,
float xc, float yc, float w, float h)
{
if (!name || *name == 0 || w < 1 || h < 1)
return NULL;
Vector2d size(Vector2d(w, h) * sender->view->xform()->displayToWorld());
while (fabsf(size.x) > 200.f || fabsf(size.y) > 200.f) {
size *= 0.95f;
}
size *= sender->view->xform()->worldToDisplay();
Box2d rect(xc - size.x / 2, yc - size.y / 2, xc + size.x / 2, yc + size.y / 2);
LOGD("addImageShape %s x:%.0f y:%.0f w:%.0f h:%.0f",
name, rect.xmin, rect.ymin, rect.width(), rect.height());
rect *= sender->view->xform()->displayToModel();
MgShapeT<MgImageShape> shape;
MgImageShape* imagesp = (MgImageShape*)shape.shape();
shape.context()->setLineStyle(kGiLineNull); // 默认没有边框
shape.context()->setFillColor(GiColor::White()); // 设为实填充,避免在中心无法点中
imagesp->setName(name);
imagesp->setRect2P(rect.leftTop(), rect.rightBottom());
MgShapesLock locker(MgShapesLock::Add, sender->view);
if (sender->view->shapeWillAdded(&shape)) {
MgShape* newsp = sender->view->shapes()->addShape(shape);
sender->view->shapeAdded(newsp);
sender->view->setNewShapeID(newsp->getID());
sender->toSelectCommand();
return newsp;
}
return NULL;
}
示例11: click
bool MgCmdDrawSplines::click(const MgMotion* sender)
{
if (m_freehand) {
MgShapeT<MgLine> line(*sender->view->context());
Point2d pt (sender->pointM);
if (sender->point.distanceTo(sender->startPt) < 1.f) {
pt = (sender->point + Vector2d(1.f, 1.f)) * sender->view->xform()->displayToModel();
}
line.shape()->setPoint(0, sender->startPtM);
line.shape()->setPoint(1, pt);
MgShape* newsp = addShape(sender, &line);
if (newsp) {
dynshape()->shape()->clear();
sender->view->regenAppend(newsp->getID());
}
return true;
}
return MgCommandDraw::click(sender);
}
示例12: addImageShape
int GiCoreView::addImageShape(const char* name, float xc, float yc, float w, float h)
{
MgShape* shape = impl->_cmds->addImageShape(&impl->motion, name, xc, yc, w, h);
return shape ? shape->getID() : 0;
}