Esempio n. 1
0
 /// Less operator, needed for maps
 bool operator<(const port<Alloc>& rhs) const {
     int n = node().compare(rhs.node());
     if (n > 0)                       return true;
     if (n < 0)                       return false;
     if (id()   < rhs.id())           return true;
     if (id()   > rhs.id())           return false;
     if (creation() < rhs.creation()) return true;
     if (creation() > rhs.creation()) return false;
     return false;
 }
void RS_ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent* e) {
//    RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent begin");
    if(getStatus() != SetCircle2) return;
    circle2= catchEntity(e, circleType, RS2::ResolveAll);
    if(circle2==NULL) return;
    if(circle2->rtti()!=RS2::EntityCircle &&
            circle2->rtti()!=RS2::EntityEllipse &&
            circle2->rtti()!=RS2::EntityArc
            ) {
        circle2=NULL;
        return;
    }
    RS_Creation creation(NULL, NULL);
    RS_Vector mouse(graphicView->toGraphX(e->x()),
                    graphicView->toGraphY(e->y()));
    tangent.reset(creation.createTangent2(mouse,
                                          circle1,
                                          circle2));
    if(tangent.get()==NULL) {
        valid=false;
        return;
    }
    valid=true;
	lineData.reset(new RS_LineData(tangent->getData()));

    deletePreview();
	preview->addEntity(new RS_Line(preview.get(), *lineData));
    drawPreview();
}
ContinuousExtendedKalmanFilter::ContinuousExtendedKalmanFilter(int numSystemStatesIn,int numSystemInputsIn,int numSystemMeasuresIn)
{
	creation(numSystemStatesIn,numSystemInputsIn,numSystemMeasuresIn);
	initTime=0.0;
	actualTime=0.0;
	return;
}
//////// Continuous EKF ///////
ContinuousExtendedKalmanFilter::ContinuousExtendedKalmanFilter(void)
{
	creation(0,0,0);
	initTime=0.0;
	actualTime=0.0;
	return;
}
Esempio n. 5
0
void RS_ActionDrawLinePolygon::mouseMoveEvent(RS_MouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLinePolygon::mouseMoveEvent begin");

    RS_Vector mouse = snapPoint(e);

    switch (getStatus()) {
    case SetCenter:
        break;

    case SetCorner:
        if (center.valid) {
            corner = mouse;
            deletePreview();
            clearPreview();

            RS_Creation creation(preview, NULL, false);
            creation.createPolygon(center, corner, number);

            drawPreview();
        }
        break;

    default:
        break;
    }
}
void RS_ActionDrawLineOrthTan::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLineOrthTan::mouseMoveEvent begin");
    if( getStatus() != SetCircle ) return;

    RS_Vector mouse(graphicView->toGraphX(e->x()),
                    graphicView->toGraphY(e->y()));

    RS_Entity* en ;
    en = catchEntity(e, circleList, RS2::ResolveAll);
    if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
                     en->rtti()==RS2::EntityArc ||
                     en->rtti()==RS2::EntityEllipse)) {
        circle = en;

        RS_Creation creation(NULL, NULL);
        RS_Line* t = creation.createLineOrthTan(mouse,
                                                normal,
                                                circle);

        if (t!=NULL) {
            if (tangent!=NULL) {
                delete tangent;
                    tangent=NULL;
            }
            tangent = (RS_Line*)t->clone();

            deletePreview();
            preview->addEntity(t);
            drawPreview();
        }
    }
    RS_DEBUG->print("RS_ActionDrawLineOrthTan::mouseMoveEvent end");
}
Esempio n. 7
0
static int gLoadMultiBodyFromUrdf(lua_State *L)
{
	int argc = lua_gettop(L);
	if (argc==4)
	{

		if (!lua_isuserdata(L,1))
		{
			std::cerr << "error: first argument to b3CreateRigidbody should be world";
			return 0;
		}

		luaL_checktype(L,3, LUA_TTABLE);

		btVector3 pos = getLuaVectorArg(L,3);

		btQuaternion orn = getLuaQuaternionArg(L,4);


		btDiscreteDynamicsWorld* world = (btDiscreteDynamicsWorld*) lua_touserdata(L,1);
		if (world != sLuaDemo->m_dynamicsWorld)
		{
			std::cerr << "error: first argument expected to be a world";
			return 0;
		}
		const char* fileName = lua_tostring(L,2);
#if 1
		BulletURDFImporter u2b(sLuaDemo->m_guiHelper);
		bool loadOk =  u2b.loadURDF(fileName);
		if (loadOk)
		{
			b3Printf("loaded %s OK!", fileName);

			btTransform tr;
			tr.setIdentity();
			tr.setOrigin(pos);
			tr.setRotation(orn);
			int rootLinkIndex = u2b.getRootLinkIndex();
//			printf("urdf root link index = %d\n",rootLinkIndex);
			MyMultiBodyCreator creation(sLuaDemo->m_guiHelper);
			bool m_useMultiBody = true;
			ConvertURDF2Bullet(u2b,creation, tr,sLuaDemo->m_dynamicsWorld,m_useMultiBody,u2b.getPathPrefix());
			btMultiBody* mb = creation.getBulletMultiBody();

			if (mb)
			{
				lua_pushlightuserdata (L, mb);
				return 1;
			}


		} else
		{
			b3Printf("can't find %s",fileName);
		}
#endif
	}

	return 0;
}
void RS_ActionDrawLinePolygonCorCor::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLinePolygon2::mouseMoveEvent begin");

    RS_Vector mouse = snapPoint(e);

    switch (getStatus()) {
    case SetCorner1:
        break;

    case SetCorner2:
        if (corner1.valid) {
            corner2 = mouse;
            deletePreview();

			RS_Creation creation(preview.get(), NULL, false);
            creation.createPolygon2(corner1, corner2, number);

            drawPreview();
        }
        break;

    default:
        break;
    }
}
QgsProcessingAlgorithm *QgsProcessingAlgorithm::create( const QVariantMap &configuration ) const
{
  std::unique_ptr< QgsProcessingAlgorithm > creation( createInstance() );
  creation->setProvider( provider() );
  creation->initAlgorithm( configuration );
  return creation.release();
}
Esempio n. 10
0
void RS_ActionBlocksCreate::trigger() {
    //deletePreview();

    //RS_Modification m(*container, graphicView);
    //m.paste(data.insertionPoint);
    //std::cout << *RS_Clipboard::instance();

    if (graphic!=NULL) {
        RS_BlockList* blockList = graphic->getBlockList();
        if (blockList!=NULL) {
            RS_BlockData d =
                RS_DIALOGFACTORY->requestNewBlockDialog(blockList);

            if (!d.name.isEmpty()) {
                RS_Creation creation(container, graphicView);
                creation.createBlock(d, referencePoint, true);

                RS_InsertData id(
                    d.name,
                    referencePoint,
                    RS_Vector(1.0,1.0),
                    0.0,
                    1, 1, RS_Vector(0.0,0.0)
                );
                creation.createInsert(id);
            }
        }
    }

	graphicView->redraw(RS2::RedrawDrawing); 

    finish();
    graphicView->killSelectActions();
}
void RS_ActionDrawLineParallel::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent begin");

    coord = RS_Vector(graphicView->toGraphX(e->x()),
                      graphicView->toGraphY(e->y()));

    entity = catchEntity(e, RS2::ResolveAll);

    switch (getStatus()) {
    case SetEntity: {
            deletePreview();

			RS_Creation creation(preview.get(), nullptr, false);
            creation.createParallel(coord,
                                    distance, number,
                                    entity);

            drawPreview();
        }
        break;

    default:
        break;
    }

    RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent end");
}
Esempio n. 12
0
bool PhysicsServer::loadUrdf(const char* fileName, const btVector3& pos, const btQuaternion& orn,
                             bool useMultiBody, bool useFixedBase)
{
 
    MyURDFImporter u2b(m_guiHelper);
    bool loadOk =  u2b.loadURDF(fileName);
    if (loadOk)
    {
        b3Printf("loaded %s OK!", fileName);
        
        btTransform tr;
        tr.setIdentity();
        tr.setOrigin(pos);
        tr.setRotation(orn);
        int rootLinkIndex = u2b.getRootLinkIndex();
        //                      printf("urdf root link index = %d\n",rootLinkIndex);
        MyMultiBodyCreator creation(m_guiHelper);
        
        ConvertURDF2Bullet(u2b,creation, tr,m_dynamicsWorld,useMultiBody,u2b.getPathPrefix());
        btMultiBody* mb = creation.getBulletMultiBody();

        return true;
    }
    
    return false;
}
Esempio n. 13
0
void RS_ActionBlocksCreate::trigger() {
	if (graphic!=nullptr) {
        RS_BlockList* blockList = graphic->getBlockList();
		if (blockList!=nullptr) {
            RS_BlockData d =
                RS_DIALOGFACTORY->requestNewBlockDialog(blockList);

            if (!d.name.isEmpty()) {
                RS_Creation creation(container, graphicView);
				creation.createBlock(&d, referencePoint, true);

                RS_InsertData id(
                    d.name,
                    referencePoint,
                    RS_Vector(1.0,1.0),
                    0.0,
                    1, 1, RS_Vector(0.0,0.0)
                );
				creation.createInsert(&id);
            }
        }
    }

    graphicView->redraw(RS2::RedrawDrawing);

    setStatus(getStatus()+1); // clear mouse button hints
    updateMouseButtonHints();
//    if(RS_DIALOGFACTORY!=nullptr){
//        RS_DIALOGFACTORY->requestPreviousToolBar();
//    }
    graphicView->killSelectActions();
    finish(false);
}
Esempio n. 14
0
void RS_ActionDrawLinePolygonCenCor::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLinePolygon::mouseMoveEvent begin");

    RS_Vector mouse = snapPoint(e);

    switch (getStatus()) {
    case SetCenter:
        break;

    case SetCorner:
		if (pPoints->center.valid) {
			pPoints->corner = mouse;
            deletePreview();

			RS_Creation creation(preview.get(), nullptr, false);
			creation.createPolygon(pPoints->center, pPoints->corner, number);

            drawPreview();
        }
        break;

    default:
        break;
    }
}
void RS_ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent* e) {
//    RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent begin");
	e->accept();
    if(getStatus() != SetCircle2) return;
	RS_Entity* en= catchEntity(e, circleType, RS2::ResolveAll);
	if(!en || en==circle1) return;
	if(circle2){
		circle2->setHighlighted(false);
		graphicView->drawEntity(circle2);
	}
	circle2=en;
	circle2->setHighlighted(true);
	graphicView->drawEntity(circle2);
	RS_Creation creation(nullptr, nullptr);
    RS_Vector mouse(graphicView->toGraphX(e->x()),
                    graphicView->toGraphY(e->y()));
    tangent.reset(creation.createTangent2(mouse,
                                          circle1,
                                          circle2));
	if(!tangent.get()){
        valid=false;
        return;
    }
    valid=true;
	lineData.reset(new RS_LineData(tangent->getData()));

    deletePreview();
	preview->addEntity(new RS_Line(preview.get(), *lineData));
    drawPreview();
}
Esempio n. 16
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
ui(new Ui::MainWindow) {
    ui->setupUi(this);
    creation();
    configuration();
    loadSettings();
}
Esempio n. 17
0
QgsProcessingAlgorithm *QgsProcessingAlgorithm::create( const QVariantMap &configuration ) const
{
  std::unique_ptr< QgsProcessingAlgorithm > creation( createInstance() );
  if ( ! creation )
    throw QgsProcessingException( QObject::tr( "Error creating algorithm from createInstance()" ) );
  creation->setProvider( provider() );
  creation->initAlgorithm( configuration );
  return creation.release();
}
void RS_ActionLibraryInsert::trigger() {
    deletePreview();

    RS_Creation creation(container, graphicView);
    creation.createLibraryInsert(data);

    graphicView->redraw(RS2::RedrawDrawing);

}
Esempio n. 19
0
int Matrix::deletion(void)
{
	if(data!=0)
	{
		delete[] data;
	}
	creation(0,0);
	return 1;
	
}
Esempio n. 20
0
void RS_ActionDrawImage::trigger() {
    deletePreview();

	if (!pImg->data.file.isEmpty()) {
        RS_Creation creation(container, graphicView);
		creation.createImage(& pImg->data);
    }

    graphicView->redraw(RS2::RedrawDrawing);
    finish(false);
}
void RS_ActionDrawLinePolygonCorCor::trigger() {
    RS_PreviewActionInterface::trigger();

    deletePreview();

    RS_Creation creation(container, graphicView);
    bool ok = creation.createPolygon2(corner1, corner2, number);

    if (!ok) {
        RS_DEBUG->print("RS_ActionDrawLinePolygon2::trigger:"
                        " No polygon added\n");
    }
}
void RS_ActionDrawLineParallel::trigger() {
    RS_PreviewActionInterface::trigger();

    RS_Creation creation(container, graphicView);
    RS_Entity* e = creation.createParallel(coord,
                                           distance, number,
                                           entity);

	if (e==nullptr) {
        RS_DEBUG->print("RS_ActionDrawLineParallel::trigger:"
                        " No parallels added\n");
    }
}
void RS_ActionDrawLineRelAngle::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent begin");

    RS_Vector mouse(graphicView->toGraphX(e->x()),
                    graphicView->toGraphY(e->y()));

    switch (getStatus()) {
    case SetEntity:
        entity = catchEntity(e, RS2::ResolveAll);
        break;

    case SetPos: {
            //length = graphicView->toGraphDX(graphicView->getWidth());
            //RS_Vector mouse = snapPoint(e);
            pos = snapPoint(e);

            /*RS_Creation creation(NULL, NULL);
            RS_Line* l = creation.createLineRelAngle(mouse,
                         entity,
                         angle,
                         length);*/

            deletePreview();

            RS_Creation creation(preview, NULL, false);
            creation.createLineRelAngle(pos,
                                        entity,
                                        angle,
                                        length);

            drawPreview();

            /*if (l!=NULL) {
                if (line!=NULL) {
                    delete line;
                }
                line = (RS_Line*)l->clone();

                deletePreview();
                preview->addEntity(l);
                drawPreview();
        }*/
        }
        break;

    default:
        break;
    }

    RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent end");
}
Esempio n. 24
0
void RS_ActionDrawImage::trigger() {
    deletePreview();

    if (!data.file.isEmpty()) {
        RS_Creation creation(container, graphicView);
        creation.createImage(data);
    }

	graphicView->redraw(RS2::RedrawDrawing); 

    //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
    finish();
	updateToolBar();
}
Esempio n. 25
0
/* ---------------------------------------------------------------------- */
int main()
{
  Noeud* rezo[] = {
    creation(192, 168,  1, 1),
    creation(192, 168,  1, 2),
    creation(192, 168,  1, 3),
    creation(192, 168, 10, 1),
    creation(192, 168, 10, 2),
    creation(192, 168, 20, 1),
    creation(192, 168, 20, 2)
  };
 
  for (size_t i = 0 ; i < sizeof(rezo) / sizeof(rezo[0]); ++i) {
    if (NULL == rezo[i]) {
      fprintf(stderr, "pas assez de mémoire\n");
      exit(-1);
    }
  }    
 
  sont_voisins(rezo[0], rezo[1]);
  sont_voisins(rezo[0], rezo[2]);
 
  sont_voisins(rezo[1], rezo[2]);
  sont_voisins(rezo[1], rezo[3]);
  sont_voisins(rezo[1], rezo[5]);
 
  sont_voisins(rezo[2], rezo[3]);
  sont_voisins(rezo[2], rezo[5]);
 
  sont_voisins(rezo[3], rezo[4]);
  sont_voisins(rezo[3], rezo[5]);
 
  sont_voisins(rezo[5], rezo[6]);
 
  affiche(rezo[3]);
 
  affiche_simple(rezo[0]);
  printf(" et ");
  affiche_simple(rezo[5]);
  printf(" ont %u voisins communs.\n", voisins_communs(rezo[0], rezo[5]));
 
  affiche_simple(rezo[1]);
  printf(" et ");
  affiche_simple(rezo[2]);
  printf(" ont %u voisins communs.\n", voisins_communs(rezo[1], rezo[2]));
 
  /* garbage collecting */
  for (size_t i = 0 ; i < sizeof(rezo) / sizeof(rezo[0]); ++i) {
    libere(rezo[i]);
  }
  return 0;
}
void RS_ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent begin");

    RS_Vector mouse(graphicView->toGraphX(e->x()),
                    graphicView->toGraphY(e->y()));

    switch (getStatus()) {
    case SetCircle1: {
            RS_Entity* en = catchEntity(e, circleType, RS2::ResolveAll);
            if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
                             en->rtti()==RS2::EntityEllipse ||
                             en->rtti()==RS2::EntityArc)) {
                circle1 = en;
            }
        }
        break;

    case SetCircle2: {
            RS_Entity* en = catchEntity(e, circleType, RS2::ResolveAll);
            if (en!=NULL && (en->rtti()==RS2::EntityCircle ||
                             en->rtti()==RS2::EntityEllipse ||
                             en->rtti()==RS2::EntityArc)) {
                circle2 = en;

                RS_Creation creation(NULL, NULL);
                RS_Line* t = creation.createTangent2(mouse,
                                                     circle1,
                                                     circle2);

                if (t!=NULL) {
                    if (tangent!=NULL) {
                        delete tangent;
                    }
                    tangent = (RS_Line*)t->clone();

                    deletePreview();
                    preview->addEntity(t);
                    drawPreview();
                }
            }
        }
        break;

    default:
        break;
    }

    RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent end");
}
void RS_ActionDrawLineBisector::mouseMoveEvent(QMouseEvent* e) {
    RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent begin");

    RS_Vector mouse = RS_Vector(graphicView->toGraphX(e->x()),
                                graphicView->toGraphY(e->y()));

    switch (getStatus()) {
    case SetLine1:
        break;

    case SetLine2: {
            coord2 = mouse;
            RS_Entity* en = catchEntity(e, RS2::ResolveAll);
			if(en==line1) break;
			if (en && en->rtti()==RS2::EntityLine) {
				if(line2 && line2->isHighlighted()){
					line2->setHighlighted(false);
				}
				line2 = static_cast<RS_Line*>(en);
				line2->setHighlighted(true);
				graphicView->redraw(RS2::RedrawDrawing);

                deletePreview();

				RS_Creation creation(preview.get(), nullptr, false);
                creation.createBisector(coord1,
                                        coord2,
                                        length,
                                        number,
                                        line1,
                                        line2);
                drawPreview();
			}else{
				if(line2 && line2->isHighlighted()){
					line2->setHighlighted(false);
					graphicView->redraw(RS2::RedrawDrawing);
				}
				line2=nullptr;

			}
        }
        break;

    default:
        break;
    }

    RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent end");
}
void RS_ActionDrawLineParallelThrough::trigger() {
    RS_PreviewActionInterface::trigger();

    if (entity!=NULL) {
        RS_Creation creation(container, graphicView);
        RS_Entity* e = creation.createParallelThrough(coord,
                       number,
                       entity);

        if (e==NULL) {
            RS_DEBUG->print("RS_ActionDrawLineParallelThrough::trigger:"
                            " No parallels added\n");
        }
    }
}
Esempio n. 29
0
void RS_ActionBlocksInsert::trigger() {
    deletePreview();

    //RS_Modification m(*container, graphicView);
	//m.paste(img->insertionPoint);
    //std::cout << *RS_Clipboard::instance();

	if (block) {
        RS_Creation creation(container, graphicView);
		data->updateMode = RS2::Update;
		creation.createInsert(data.get());
    }

	graphicView->redraw(RS2::RedrawDrawing); 

    //finish();
}
void RS_ActionDrawLineBisector::trigger() {
    RS_PreviewActionInterface::trigger();

	for(auto p: {line1, line2}){
		if(p && p->isHighlighted()){
			p->setHighlighted(false);
		}
	}
	graphicView->redraw(RS2::RedrawDrawing);

    RS_Creation creation(container, graphicView);
    creation.createBisector(coord1,
                            coord2,
                            length,
                            number,
                            line1,
							line2);
}