Пример #1
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 *
 *  @author OLiver
 */
bool ctrlScrollBar::Draw_()
{
    // Leiste
    Draw3D(GetX(), GetY() + button_height - 2, width_, height_ - button_height * 2 + 4, tc, 2);

    // Buttons
    DrawControls();

    // Scrollbar
    Draw3D(GetX(), GetY() + button_height + scrollbar_pos, width_, scrollbar_height, tc, 0);

    return true;
}
Пример #2
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 */
bool ctrlScrollBar::Draw_()
{
    DrawPoint pos = GetDrawPos();
    // Leiste
    Draw3D(pos + DrawPoint(0, button_height - 2), width_, height_ - button_height * 2 + 4, tc, 2);

    // Buttons
    DrawControls();

    // Scrollbar
    Draw3D(pos + DrawPoint(0, button_height + scrollbar_pos), width_, scrollbar_height, tc, 0);

    return true;
}
Пример #3
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 */
void ctrlPercent::Draw_()
{
    // Wenn der Prozentsatzpointer = 0, dann wird 0 angezeigt und es soll nich abstürzen!
    unsigned short percentage = (this->percentage_ ? *this->percentage_ : 0);

    if(percentage > 100)
        percentage = 100;

    // Farbe wählen je nachdem wie viel Prozent
    unsigned color;
    if(percentage >= 60)
        color = COLOR_60_PERCENT;
    else if(percentage >= 30)
        color = COLOR_30_PERCENT;
    else if(percentage >= 20)
        color = COLOR_20_PERCENT;
    else
        color = COLOR_0_PERCENT;

    // Box zeichnen
    Draw3D(Rect(GetDrawPos(), GetSize()), tc, false);

    // Fortschritt zeichnen
    Extent progSize = GetSize() - Extent(8, 8);
    progSize.x = (progSize.x * percentage) / 100;
    DrawRectangle(Rect(GetDrawPos() + DrawPoint(4, 4), progSize), color);

    // Text zeichnen
    std::string caption = helpers::toString(percentage) + "%";
    font->Draw(GetDrawPos() + DrawPoint(GetSize()) / 2, caption, FontStyle::CENTER | FontStyle::VCENTER, text_color);
}
Пример #4
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 */
bool ctrlPercent::Draw_()
{
    // Wenn der Prozentsatzpointer = 0, dann wird 0 angezeigt und es soll nich abstürzen!
    unsigned short percentage = (this->percentage_ ?  *this->percentage_ : 0);

    // Farbe herausfinden
    unsigned int color = 0xFFFF0000;

    if(percentage > 100)
        percentage = 100;

    // Farbe wählen je nachdem wie viel Prozent
    if(percentage >= 60)
        color = 0xFF00E000;
    else if(percentage >= 30)
        color = 0xFFFFFF00;
    else if(percentage >= 20)
        color = 0xFFFF8000;

    // Box zeichnen
    Draw3D(GetX(), GetY(), width_, height_, tc, 2);

    // Fortschritt zeichnen
    DrawRectangle(GetX() + 4, GetY() + 4, (width_ - 8)*percentage / 100, height_ - 8, color);

    // Text zeichnen
    char caption[256];
    sprintf(caption, "%u%%", percentage);
    font->Draw(GetX() + width_ / 2, GetY() + height_ / 2, caption, glArchivItem_Font::DF_CENTER | glArchivItem_Font::DF_VCENTER, text_color);

    return true;
}
Пример #5
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 *
 *  @author OLiver
 */
bool ctrlList::Draw_()
{
    ctrlScrollBar* scrollbar = GetCtrl<ctrlScrollBar>(0);

    // Box malen
    Draw3D(GetX(), GetY(), width_, height_, tc, 2);

    // Scrolleiste zeichnen
    DrawControls();

    // Wieviele Linien anzeigen?
    unsigned show_lines = (pagesize > lines.size() ? unsigned(lines.size()) : pagesize);

    // Listeneinträge zeichnen
    for(unsigned short i = 0; i < show_lines; ++i)
    {
        // Schwarze Markierung, wenn die Maus drauf ist
        if(i == mouseover)
            DrawRectangle(GetX() + 2, GetY() + 2 + i * font->getHeight(), width_ - 22, font->getHeight(), 0x80000000);

        // Text an sich
        font->Draw(GetX() + 2, GetY() + 2 + i * font->getHeight(), lines[i + scrollbar->GetPos()], 0, (selection_ == i + scrollbar->GetPos() ? 0xFFFFAA00 : 0xFFFFFF00), 0, width_ - 22);
    }

    return true;
}
Пример #6
0
/**
 *  zeichnet das Fenster.
 * 
 *  @author OLiver
 */
bool ctrlButton::Draw_(void)
{
	if(width == 0 || height == 0)
		return true;

	// Prüfen, ob bei gehighlighteten Button die Maus auch noch über dem Button ist
	TestMouseOver();

	Rect buttonrect = { 
		GetX(), 
		GetY(), 
		GetX() + width, 
		GetY() + height 
	};

	if(tc != TC_INVISIBLE)
	{
		if(border)
			Draw3D(buttonrect.left, buttonrect.top, width, height, tc, (unsigned short)((check) ? 2 : state), illuminated);
		else
		{
			if(state == BUTTON_UP || state == BUTTON_PRESSED)
				LOADER.GetImageN("io", tc*2 + 1)->Draw(buttonrect.left, buttonrect.top, 0, 0, 0, 0, width, height);
			else
				LOADER.GetImageN("io", tc*2)->Draw(buttonrect.left, buttonrect.top,  0, 0, 0, 0, width, height);
		}
	}

	/// Inhalt malen (Text, Bilder usw.)
	DrawContent();

	return true;
}
Пример #7
0
/**
 *  Zeichenmethode
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 *
 *  @author FloSoft
 */
bool ctrlTable::Draw_(void)
{
	Draw3D(GetX(), GetY(), width, height, tc, 2);

	DrawControls();

	unsigned short lines = static_cast<unsigned short>((line_count > rows.size() ? rows.size() : line_count));
	ctrlScrollBar *scroll = GetCtrl<ctrlScrollBar>(0);

	for(unsigned short i = 0; i < lines; ++i)
	{
		if(row_l_selection == i + scroll->GetPos())
		{
			// durchsichtig schwarze Markierung malen
			DrawRectangle(GetX() + 2, GetY() + 2 + header_height + i*font->getHeight(), width - 4 - (scroll->GetVisible() ? 24 : 0), font->getHeight(), 0x80000000);
		}

		unsigned short pos = 0;
		for(unsigned short c = 0; c < columns.size(); ++c)
		{
			if(columns.at(c).width == 0)
				continue;

			font->Draw(GetX()+2+pos, GetY()+2 + header_height + i*font->getHeight(),rows.at(i+scroll->GetPos()).columns.at(c), 0, (row_l_selection == i + scroll->GetPos() ? 0xFFFFAA00 : COLOR_YELLOW), 0, GetCtrl<ctrlButton>(c+1)->GetWidth(), "");
			pos += GetCtrl<ctrlButton>(c+1)->GetWidth();
		}
	}

	return true;
}
Пример #8
0
void init(){
  glfwInit();
  
  ctx = new libfreenect2::Freenect2;
  listener = new libfreenect2::SyncMultiFrameListener(libfreenect2::Frame::Color 
                                                      | libfreenect2::Frame::Ir 
                                                      | libfreenect2::Frame::Depth); 
  frames = new libfreenect2::FrameMap;

  dev = ctx->openDefaultDevice();

  if(!dev){
    throw ICLException("no device connected or failure opening the default one!");
  }
  
  dev->setColorFrameListener(listener);
  dev->setIrAndDepthFrameListener(listener);
  dev->start();

  std::cout << "device serial: " << dev->getSerialNumber() << std::endl;
  std::cout << "device firmware: " << dev->getFirmwareVersion() << std::endl;

  gui << ( VBox() 
           << Image().handle("hdepth").minSize(10,8)
           << Image().handle("hcolor").minSize(10,8)
           << Image().handle("hir").minSize(10,8)
         )
      << ( HSplit() 
           << Draw3D().handle("draw3D").minSize(40,30)
           )
      << Show();
}
Пример #9
0
/**
 *  zeichnet das Fenster.
 *
 *  @author FloSoft
 */
bool ctrlVarDeepening::Draw_(void)
{
    Draw3D(x_, y_, width_, height_, tc, 2);

    font->Draw(x_ + width_ / 2, y_ + height_ / 2, GetFormatedText(), glArchivItem_Font::DF_CENTER | glArchivItem_Font::DF_VCENTER, color_);

    return true;
}
Пример #10
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 */
bool ctrlScrollBar::Draw_()
{
    RTTR_Assert(scroll_range > pagesize); // Don't show unneccessary scrollbars, otherwise invariants might be violated.
    if(scroll_height == 0)
        return true;
    DrawPoint pos = GetDrawPos();
    // Leiste
    Draw3D(pos + DrawPoint(0, button_height - 2), width_, height_ - button_height * 2 + 4, tc, 2);

    // Buttons
    DrawControls();

    // Scrollbar
    Draw3D(pos + DrawPoint(0, button_height + sliderPos), width_, sliderHeight, tc, 0);

    return true;
}
Пример #11
0
/**
 *  zeichnet das Fenster.
 *
 *  @author OLiver
 */
bool ctrlCheck::Draw_()
{
    const unsigned short box_size = 20;
    unsigned short distance = (height_ - box_size) / 2;

    Draw3D(GetX(), GetY(), width_, height_, tc, 2);

    if(font)
        font->Draw(GetX() + 4, GetY() + height_ / 2, text, glArchivItem_Font::DF_VCENTER, (check ? COLOR_YELLOW : 0xFFBBBBBB) );

    Draw3D(GetX() + width_ - distance - box_size, GetY() + distance, box_size, box_size, tc, 2);

    if(check)
        LOADER.GetImageN("io", 32)->Draw(GetX() + width_ - distance - box_size / 2, GetY() + distance + box_size / 2, 0, 0, 0, 0, 0, 0);

    return true;
}
Пример #12
0
void DrawGLScene()
{
    if( CurrMode == M_2D )
        Draw2D();
    if( CurrMode == M_3D )
        Draw3D();
 
    glutSwapBuffers(); 	
}
Пример #13
0
/**
 *  zeichnet das Fenster.
 *
 *  @author OLiver
 */
bool ctrlDeepening::Draw_(void)
{
    Draw3D(GetX(), GetY(), width_, height_, tc, 2);

    font->Draw(GetX() + width_ / 2, GetY() + height_ / 2, text.c_str(), glArchivItem_Font::DF_CENTER | glArchivItem_Font::DF_VCENTER, color_);

    DrawContent();

    return true;
}
Пример #14
0
/**
 *  zeichnet das Fenster.
 */
bool ctrlDeepening::Draw_()
{
    Draw3D(GetDrawPos(), width_, height_, tc, 2);

    font->Draw(GetDrawPos() + DrawPoint(width_, height_) / 2, text, glArchivItem_Font::DF_CENTER | glArchivItem_Font::DF_VCENTER, color_);

    DrawContent();

    return true;
}
Пример #15
0
/**
 *  Zeichenmethode
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 *
 *  @author OLiver
 */
bool ctrlTab::Draw_(void)
{
    DrawControls();

    LOADER.GetImageN("io", 3)->Draw(GetX() + tab_count * 36, GetY(), 0, 0, 0, 0, width - tab_count * 36, 45);

    Draw3D(GetX(), GetY() + 32, width, 13, TC_GREEN1, 0);

    ctrlButton* button = GetCtrl<ctrlButton>(tab_selection);
    if(button)
        button->Draw();

    return true;
}
Пример #16
0
void  PFO_CovarLimitsGL :: DrawPlotObject()
{
    if (!InitDrawObject())
        return;

    if (is3DObject)
    {
        Draw3D();
    }
    else
    {
        Draw2D();
    }

    CloseDrawObject();
}
Пример #17
0
/**
 *  zeichnet das Fenster.
 *
 *  @author FloSoft
 */
bool ctrlVarDeepening::Draw_(void)
{
    Draw3D(x, y, width, height, tc, 2);

    char buffer[1025];

    // variablen Inhalt erzeugen
    for(unsigned int i = 0, j = 0, k = 0; i < text.length() && j < 1024; ++i)
    {
        if(text[i] == '%')
        {
            ++i;
            char temp[1025];
            switch(text[i])
            {
                case 'd':
                {
                    snprintf(temp, 1024, "%d", *(int*)vars[k++]);
                    for(unsigned int x = 0; x < strlen(temp); ++x)
                        buffer[j++] = temp[x];
                } break;
                case 's':
                {
                    snprintf(temp, 1024, "%s", (char*)vars[k++]);
                    for(unsigned int x = 0; x < strlen(temp); ++x)
                        buffer[j++] = temp[x];
                } break;
                default:
                {
                    buffer[j++] = text[i - 1];
                    buffer[j++] = text[i];
                } break;
            }
        }
        else
            buffer[j++] = text[i];
        buffer[j] = '\0';
    }
    //vsnprintf(buffer, 1024, text, *(va_list*)&vars);

    // letzte byte nullen (safety, vsnprintf schreibt bei zu großem string kein null-terminator)
    buffer[1024] = '\0';

    font->Draw(x + width / 2, y + height / 2, buffer, glArchivItem_Font::DF_CENTER | glArchivItem_Font::DF_VCENTER, color);

    return true;
}
Пример #18
0
/**
 *  zeichnet das Fenster.
 */
bool ctrlComboBox::Draw_()
{
    ctrlList* liste = GetCtrl<ctrlList>(0);

    // Box
    Draw3D(GetDrawPos(), width_, height_, tc, 2);

    // Namen des selektierten Strings in der Box anzeigen
    if(liste->GetLineCount() > 0)
        font->Draw(GetDrawPos() + DrawPoint(2, height_ / 2), liste->GetSelItemText(), glArchivItem_Font::DF_VCENTER, COLOR_YELLOW, 0, width_ - 2 - height_, "");

    // Male restliche Controls per Hand, denn ein einfaches DrawControls() würde
    // auch die Liste malen, die bei Msg_PaintAfter() sowieso gemalt wird.
    ctrlImageButton* button = GetCtrl<ctrlImageButton>(1);
    if(button)
        button->Draw();

    return true;
}
Пример #19
0
/**
 *  zeichnet das Fenster.
 */
bool ctrlMultiline::Draw_()
{
    if(draw_box)
        Draw3D(GetDrawPos(), width_, height_, tc, 2);

    DrawControls();

    unsigned show_lines = std::min(lines_in_control, unsigned(lines.size()));

    unsigned scrollbarPos = GetCtrl<ctrlScrollBar>(0)->GetPos();
    DrawPoint curPos = GetDrawPos() + DrawPoint(2, 2);
    for(unsigned i = 0; i < show_lines; ++i)
    {
        font->Draw(curPos, lines[i + scrollbarPos].str, format, lines[i + scrollbarPos].color);
        curPos.y += font->getHeight();
    }

    return true;
}
Пример #20
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 */
bool ctrlProgress::Draw_()
{
    DrawPoint barPos = GetDrawPos() + padding;
    // Offset by button size
    barPos.x += height_;
    Draw3D(barPos, CalcBarWidth(), height_ - 2 * padding.y, tc, 2);

    // Buttons
    DrawControls();

    const DrawPoint innerPadding(4, 4);
    unsigned int percentage = position * 100 / maximum;
    unsigned int progress = (CalcBarWidth() - innerPadding.x * 2) * position / maximum;

    // Farbe herausfinden
    unsigned int color = 0xFFD70000;

    // Feste Farbe?
    if(force_color)
        color = force_color;
    else
    {
        // Farbe wählen je nachdem wie viel Prozent
        if(percentage >= 60)
            color = 0xFF71B63C;
        else if(percentage >= 30)
            color = 0xFFFFBF33;
        else if(percentage >= 20)
            color = 0xFFDB7428;
    }

    // Leiste
    DrawRectangle(barPos + innerPadding, progress, height_ - 2 * (innerPadding.y + padding.y), color);

    // Prozentzahlen zeichnen
    std::stringstream percent;
    percent << percentage << "%";
    SmallFont->Draw(GetDrawPos() + DrawPoint(width_, height_) / 2, percent.str(), glArchivItem_Font::DF_VCENTER | glArchivItem_Font::DF_CENTER, COLOR_YELLOW);

    return true;
}
Пример #21
0
/**
 *  Zeichenmethode.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 *
 *  @author Devil
 */
bool ctrlProgress::Draw_(void)
{
    Draw3D(GetX() + height_ - 2 + x_padding, GetY() + y_padding, width_ - (height_ * 2) + 4 - 2 * x_padding, height_ - 2 * y_padding, tc, 2);

    // Buttons
    DrawControls();

    unsigned int percentage = position * 100 / maximum;
    unsigned int progress = (width_ - height_ * 2 - 4 - 2 * x_padding) * position / maximum;

    // Farbe herausfinden
    unsigned int color = 0xFFFF0000;

    // Feste Farbe?
    if(force_color)
        color = force_color;
    else
    {
        // Farbe wählen je nachdem wie viel Prozent
        if(percentage >= 60)
            color = 0xFF00E000;
        else if(percentage >= 30)
            color = 0xFFFFFF00;
        else if(percentage >= 20)
            color = 0xFFFF8000;
    }

    // Leiste
    DrawRectangle(GetX() + height_ + 2 + x_padding, GetY() + 4 + y_padding, progress, height_ - 8 - 2 * y_padding, color);

    // Prozentzahlen zeichnen
    std::stringstream percent;
    percent << percentage << "%";
    SmallFont->Draw(GetX() + (width_ / 2), GetY() + height_ / 2, percent.str(), glArchivItem_Font::DF_VCENTER | glArchivItem_Font::DF_CENTER, COLOR_YELLOW);

    return true;
}
Пример #22
0
void init(){
  bool cOut = pa("-c"), dOut = pa("-d");
  
  if(cOut){
    colorOut.init(pa("-c"));
  }
  if(dOut){
    depthOut.init(pa("-d"));
  }
  
  if(cOut || dOut){
    prevGUI << (cOut ? Image().handle("color") : Dummy())
            << (dOut ? Image().handle("depth") : Dummy())
            << Create();
  }

  gui << Draw3D().handle("draw")
      << ( VBox().minSize(10,2)
           << FSlider(-10,10,0).out("x").label("translate x")
           << FSlider(-10,10,0).out("y").label("translate y")
           << FSlider(1.5,10,0).out("z").label("translate z")
           
           << FSlider(-4,4,0).out("rx").label("rotate x")
           << FSlider(-4,4,0).out("ry").label("rotate y")
           << FSlider(-4,4,0).out("rz").label("rotate z")

           << ((cOut||dOut) ? (const GUIComponent&)Button("show","hide").label("preview").handle("preview") 
               : (const GUIComponent&)Dummy() )
           << Button("reset view").handle("resetView")
         )
      << Show();

  
  if(cOut || dOut){
    gui["preview"].registerCallback(utils::function(&prevGUI,&GUI::switchVisibility));
    if(dOut){
      ImageHandle d = prevGUI["depth"];
      d->setRangeMode(ICLWidget::rmAuto);
    }
  }
  
  Camera defaultCam(Vec(4.73553,-3.74203,8.06666,1),
                    Vec(-0.498035,0.458701,-0.735904,1),
                    Vec(0.787984,-0.116955,-0.604486,1));
  scene.addCamera( !pa("-cam").as<bool>() ? defaultCam : Camera(*pa("-cam")));
  initDepthCam = scene.getCamera(0);
  
  if(pa("-ccam")){
    scene.addCamera(*pa("-ccam"));
    Mat D=scene.getCamera(0).getCSTransformationMatrix();
    Mat C=scene.getCamera(1).getCSTransformationMatrix();
    
    relTM = new Mat( C * D.inv() );
  }

  SceneObject* ground = SceneObject::cuboid(0,0,0,200,200,3);
  ground->setColor(Primitive::quad,GeomColor(100,100,100,255));
  
  scene.addObject(ground);
  if(pa("-object")){
    scene.addObject( (obj = new SceneObject(*pa("-object"))) );
  }else{
    scene.addObject( (obj = SceneObject::cube(0,0,3, 3) ) );
  }
  obj->setColor(Primitive::quad, GeomColor(0,100,255,255));
  obj->setColor(Primitive::triangle, GeomColor(0,100,255,255));
  obj->setColor(Primitive::polygon, GeomColor(0,100,255,255));
  obj->setVisible(Primitive::line | Primitive::vertex, false);
  
  gui["draw"].link(scene.getGLCallback(0));
  gui["draw"].install(scene.getMouseHandler(0));

  scene.setDrawCamerasEnabled(false);

  scene.addCamera(scene.getCamera(0));

}
Пример #23
0
void init(){
  
  ot.setRenderPoints(true);
  
  GRandClip r(0,100,Range64f(-500,500));

  DataSegment<float,3> ps = obj.selectXYZ();
  DataSegment<float,4> cs = obj.selectRGBA32f();
  
  std::vector<FixedColVector<int,4> > nn(1000),nnres(1000);
  for(int i=0;i<obj.getDim();++i){
    ps[i] = Vec3(r,r,r);
    cs[i] = GeomColor(0,100,255,255);
    
    if(i < (int)nn.size()){
      nn[i] = FixedColVector<int,4>(r,r,r);
    }
  }
  
  Time t = Time::now();
  for(int i=0;i<obj.getDim();++i){
    FixedColVector<float,3> p = ps[i];
    ot.insert(FixedColVector<int,4>(p[0],p[1],p[2],1));
  }
  t.showAge("insertion time");
  
  std::vector<FixedColVector<int,4> > q = ot.query(0,-500,-500,500,1000,1000);
  static PointCloudObject res(q.size(),1,false);
  ps = res.selectXYZ();
  cs = res.selectRGBA32f();
  for(size_t i=0;i<q.size();++i){
    ps[i] = Vec3(q[i][0],q[i][1],q[i][2],1);
    cs[i] = GeomColor(255,0,0,255);
  }

  PCL_PC pcl_pc(obj.getDim(),1);
  DataSegment<float,3> pcl_ps = pcl_pc.selectXYZ();
  for(int i=0;i<obj.getDim();++i){
    pcl_ps[i] = ps[i];
  }

  t = Time::now();
  PCL_OT pcl_ot(16);
  t.showAge("create pcl octree");
  static boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> > ptr(&pcl_pc.pcl());
  
  t = Time::now();
  pcl_ot.setInputCloud(ptr);

  t.showAge("set input cloud to pcl tree"); // 3 times faster!
  

  
  t = Time::now();
  for(size_t i=0;i<nn.size();++i){
    nnres[i] = ot.nn(nn[i]);
  }
  t.showAge("icl nn search");

  t = Time::now();
  for(size_t i=0;i<nn.size();++i){
    std::vector<int> dstIdx;
    std::vector<float> dstDist;
    pcl_ot.nearestKSearch(pcl::PointXYZ(nn[i][0],nn[i][1],nn[i][2]), 1, dstIdx,dstDist);
  }
  t.showAge("pcl nn search");



  t = Time::now();
  for(size_t i=0;i<nn.size();++i){
    nnres[i] = ot.nn_approx(nn[i]);
  }
  t.showAge("icl nn approx search");

#ifdef TRY_PCL_OCTREE
  t = Time::now();
  for(size_t i=0;i<nn.size();++i){
    int idx(0); float dist(0);
    pcl_ot.approxNearestSearch(pcl::PointXYZ(nn[i][0],nn[i][1],nn[i][2]), idx,dist);
  }
  t.showAge("pcl nn approx search");
#endif

  
  
  scene.addObject(&res);  
  //scene.addObject(&obj);
  scene.addObject(&ot);

  scene.addCamera(Camera(Vec(0,0,1500,1)));
  
  gui << Draw3D().handle("draw3D").minSize(32,24) << Show();
  
  gui["draw3D"].link(scene.getGLCallback(0));
  gui["draw3D"].install(scene.getMouseHandler(0));
}
Пример #24
0
void ShowSPDConfiguration(Int_t runNb=0, const char *ocdblocation="local://$ALICE_ROOT/OCDB", bool grid=kFALSE,bool threed=kFALSE){


  gStyle->SetOptStat(0);

  if(grid){
    TGrid::Connect("alien://");
    if(!gGrid){
      printf("no grid connection is available, exiting.\n");
      return;
    }
  }
  AliITSOnlineCalibrationSPDhandler *h = new AliITSOnlineCalibrationSPDhandler();
  h->ReadDeadFromDB(runNb,ocdblocation);
  AliCDBManager::Instance();
  AliCDBManager::Instance()->SetRun(runNb);
  AliCDBManager::Instance()->SetDefaultStorage(ocdblocation);
  AliGeomManager::LoadGeometry();

  if(threed) {
    Draw3D(h);  
    return;
  }

  Double_t nact[2]={0.,0.};

  TCanvas *c = new TCanvas("c","Active Modules ",500,700);
  c->Divide(1,2);
  c->cd(1);
  TH2D *hPhiZInner = new TH2D("hPhiZInner","Inner layer Active Modules ",200,-20,20,3,0,2*TMath::Pi());
  hPhiZInner->SetXTitle("Z (cm)");
  hPhiZInner->SetYTitle("#varphi (rad)");
  hPhiZInner->Draw();

  for(Int_t i=0; i<80; i++){
    if((h->GetNrBad(i))<1) {
      TGeoHMatrix matrix;
      int vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(i);
      AliITSAlignMille2Module::SensVolMatrix(vid,&matrix);
      Double_t local0[3],local1[3],local2[3],local3[3]; // local position of the four angles
      local0[0]=-0.6375; local0[1]=0; local0[2]= 3.48; 
      local1[0]=-0.6375; local1[1]=0; local1[2]= -3.48; 
      local2[0]=0.6375; local2[1]=0; local2[2]= -3.48; 
      local2[0]=0.6375; local3[1]=0; local3[2]= 3.48; 
      Double_t global0[3],global1[3],global2[3],global3[3];
      matrix.LocalToMaster(local0,global0);
      matrix.LocalToMaster(local1,global1);
      matrix.LocalToMaster(local2,global2);
      matrix.LocalToMaster(local3,global3);
      Double_t phiUp = atan2(global0[1],global0[0]);
      if(phiUp<0) phiUp+=2*TMath::Pi();
      Double_t phiDown = atan2(global2[1],global2[0]);
      if(phiDown<0) phiDown+=2*TMath::Pi();
      TLine *lhor1 = new TLine(global0[2],phiDown,global1[2],phiDown); lhor1->Draw("same");
      lhor1->SetLineColor(kBlue);
      lhor1->SetLineWidth(3); 
      TLine *lver1 = new TLine(global1[2],phiDown,global2[2],phiUp); lver1->Draw("same");
      lver1->SetLineColor(kBlue);
      lver1->SetLineWidth(3); 
      TLine *lhor2 = new TLine(global2[2],phiUp,global3[2],phiUp); lhor2->Draw("same");
      lhor2->SetLineColor(kBlue);
      lhor2->SetLineWidth(3); 
      TLine *lver2 = new TLine(global3[2],phiUp,global0[2],phiDown); lver2->Draw("same");
      lver2->SetLineColor(kBlue);
      lver2->SetLineWidth(3); 
      nact[0]++;
    } 
  }
  c->cd(2);

  TH2D *hPhiZOuter = new TH2D("hPhiZOuter","Outer layer Active Modules ",200,-20,20,3,0,2*TMath::Pi());
  hPhiZOuter->SetXTitle("Z (cm)");
  hPhiZOuter->SetYTitle("#varphi (rad)");
  hPhiZOuter->Draw();
  for(Int_t i=80; i<240; i++){
    TGeoHMatrix matrix;
    int vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(i);
    AliITSAlignMille2Module::SensVolMatrix(vid,&matrix);
    Double_t local[4][3]; // local position of the four angles
    local[0][0]=0.6375; local[0][1]=0; local[0][2]= -3.48;
    local[1][0]=0.6375; local[1][1]=0; local[1][2]= 3.48;
    local[2][0]=-0.6375; local[2][1]=0; local[2][2]= 3.48;
    local[2][0]=-0.6375; local[3][1]=0; local[3][2]= -3.48;
    Double_t global[4][3];
    for(Int_t j=0; j<4; j++){
      matrix.LocalToMaster(local[j],global[j]);
    }
    Double_t phiUp = atan2(global[0][1],global[0][0]);
    if(phiUp<0) phiUp+=2*TMath::Pi();
    Double_t phiDown = atan2(global[2][1],global[2][0]);
    if(phiDown<0) phiDown+=2*TMath::Pi();
    if(i>235) if(phiUp < 0.1) phiUp = TMath::Pi()*2;
    //  printf("module %i  -   phiDown %f   phiUp %f \n",i,phiDown,phiUp); 
    if((h->GetNrBad(i))<1) {
      TLine *lhor1 = new TLine(global[0][2],phiUp,global[1][2],phiUp); lhor1->Draw("same");
      lhor1->SetLineColor(kBlue);
      lhor1->SetLineWidth(2); 
      TLine *lver1 = new TLine(global[1][2],phiUp,global[2][2],phiDown); lver1->Draw("same");
      lver1->SetLineColor(kBlue);
      lver1->SetLineWidth(2); 
      TLine *lhor2 = new TLine(global[2][2],phiDown,global[3][2],phiDown); lhor2->Draw("same");
      lhor2->SetLineColor(kBlue);
      lhor2->SetLineWidth(2); 
      TLine *lver2 = new TLine(global[3][2],phiDown,global[0][2],phiUp); lver2->Draw("same");
      lver2->SetLineColor(kBlue);
      lver2->SetLineWidth(2); 
      nact[1]++; 
    } 
  }
  printf("  \n   Number of Active SPD modules (->Total)  : inner %3.0f (80) %f   -  outer %3.0f (160)  %f \n",nact[0],nact[0]/80.,nact[1],nact[1]/160.);
  c->SaveAs(Form("active%i.png",runNb));
}
Пример #25
0
void init(){

  //  scene.getLight(0).setOn(false);
  scene.getLight(0).setDiffuse(GeomColor(255,255,255,50));

  SceneLight &l = scene.getLight(1);
  static Camera cam(Vec(0,0,600,1),
                    Vec(0,0,-1,1),
                    Vec(0,-1,0,1));
  cam.setResolution(Size(1024,1024));
  scene.setGravity(Vec(0,0,-1000));

  l.setShadowCam(new Camera(cam));
  l.setShadowEnabled(true);
  l.setAnchorToWorld();
  l.setPosition(Vec(0,0,600,1));
  l.setOn(true);
  l.setSpecularEnabled(true);
  l.setDiffuseEnabled(true);
  l.setSpecular(GeomColor(0,100,255,255));
  l.setDiffuse(GeomColor(255,100,0,30));

  scene.setPropertyValue("shadows.use improved shading",true);
  scene.setPropertyValue("shadows.resolution",2048);
  scene.setPropertyValue("shadows.bias",10);


  //static const int W=20,H=13,DIM=W*H;
  static const int W=pa("-paper-dim",0), H=pa("-paper-dim",1);
  static Img8u frontFace = load<icl8u>(*pa("-ff"));
  static Img8u backFace = load<icl8u>(*pa("-bf"));

  const Size s(210,297);
  const Vec corners[4] = {
    Vec(-s.width/2, -s.height/2, 150,1),
    Vec(s.width/2, -s.height/2, 150,1),
    Vec(s.width/2, s.height/2, 150,1),
    Vec(-s.width/2, s.height/2, 150,1),
  };

  paper = new ManipulatablePaper(&scene,&scene,W,H,corners,true,&frontFace,&backFace);
  //scene.removeObject(paper);
  //paper->addShadow(-74.5);


  if(pa("-o")){
    std::vector<Camera> cams;
    for(int i=0;i<3;++i){
      cams.push_back(Camera(*pa("-c",i)));
    }
    capturer = new SceneMultiCamCapturer(scene, cams);
    //    Scene::enableSharedOffscreenRendering();
    scene.setDrawCamerasEnabled(false);
  }

  gui << Draw3D(Size::VGA).minSize(32,24).handle("draw")
      << (VBox().maxSize(12,100).minSize(12,1)
          << ( HBox()
               << Fps(10).handle("fps")
               << Button("add clutter").handle("add")
               )
          << ( HBox()
               << Button("stopped","running",true).out("run")
               << Button("paper ...").handle("props")
               )
          << ( HBox()
               << CheckBox("show cubes").out("showCubes")
               << CheckBox("show texture",false).out("showTexture")
               << CheckBox("show links",false).out("showLinks")
             )
          << FSlider(0,1,0.5).out("vertexMoveFactor").label("manual force")
          << FSlider(1,100,10).out("attractorStreangth").label("attractor force")
          << FSlider(0.0001,0.9999,0.9).handle("globalStiffness").label("global paper stiffness")
          << ( HBox()
               << Button("reset paper").handle("resetPaper")
               << Combo("1,5,10,25,!200,300,500").handle("maxFPS").label("max FPS")
               )
          << FSlider(0.1,20,2).handle("cm").label("collision margin")

          << ( HBox()
               << Button("memorize").handle("mem")
               << CheckBox("soften with mouse",true).handle("soften")
               << Button("test").handle("pct")
             )
          )

      << Show();

  propGUI << Prop("paper").minSize(16,1).maxSize(16,100) << Create();

  gui["pct"].registerCallback(paper_coords_test);
  gui["props"].registerCallback(utils::function((GUI&)propGUI,&GUI::switchVisibility));
  gui["resetPaper"].registerCallback(reset_paper);
  gui["globalStiffness"].registerCallback(change_global_stiffness);

  scene.PhysicsWorld::addObject(&ground);
  scene.Scene::addObject(&groundVis);

  DrawHandle3D draw = gui["draw"];
  draw->install(paper->createMouseHandler(0));
  draw->install(&foldLine);
  draw->link(scene.getGLCallback(0));

  foldLine.cb = utils::function(fold_line_cb);



}