Ejemplo n.º 1
0
void userlayout::make_preview()
{
    kill_prv();
    QSize sz=set_size();
    QImage im(":/new/prefix1/nina");
    int x, y, x1, y1;
    float w = ui->label->width();
    float h = ui->label->height();
    x1=(w/ul_hor-sz.width())/2;
    y1=(h/ul_ver-sz.height())/2;
    int k=0; // просто для удобства
    ex=true;
    for(int i=0; i<ul_ver; i++)
        for(int j=0; j<ul_hor; j++)
        {
            k=i*ul_hor+j;
            // создать картинку
            prv.push_back(prw());
            prv[k].pct = new QLabel(ui->label);
            prv[k].pct->setBackgroundRole(QPalette::Base);
            prv[k].pct->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
            prv[k].pct->setScaledContents(true);
            prv[k].pct->setPixmap(QPixmap::fromImage(im));
            //prv[k].pct->setText(QString::number(k));  // для отладки
            prv[k].pct->setAttribute(Qt::WA_DeleteOnClose);
            // установить размер и позицию картинки
            x=(k%ul_hor)*(w/ul_hor)+x1;
            y=ceil(k/ul_hor)*(h/ul_ver)+y1;
            prv[k].pct->setGeometry(x, y, sz.width(), sz.height());
            // показать
            prv[k].pct->show();
        }
    cou=ul_hor*ul_ver;
}
Ejemplo n.º 2
0
void
TeamsWindow::FrameActiveTeam(
     unsigned short usNewActiveTeam
) {
     PaintRealWindow          prw(Handle());
     PaintCompatibleWindow    pcw(prw.DC());

     ASSERT(pClientBitmap != NULL);
     pcw.SelectBitmap(pClientBitmap);
     {
          FrameTeam(&prw, usSelectedTeam, FALSE);
          FrameTeam(&pcw, usSelectedTeam, FALSE);
          FrameTeam(&prw, usNewActiveTeam, TRUE);
          FrameTeam(&pcw, usNewActiveTeam, TRUE);
     }
     pcw.DeselectBitmap();
}
Ejemplo n.º 3
0
void
TeamsWindow::UpdateMemoryImage(
     void
) {
     PaintRealWindow          prw(Handle());
     PaintCompatibleWindow    pcw_client(prw.DC());
     PaintCompatibleWindow    pcw_car(prw.DC());
     HPALETTE                 hOldPalette;
     HPALETTE                 hOldPalette2;
     Cursor                   cursor(IDC_WAIT);
     unsigned short           usX;
     unsigned short           usY;
     unsigned short           usTmpX;
     unsigned short           usTmpY;
     unsigned short           usTeamIndex;
     unsigned short           i;

     cursor.Select();
     {
          hOldPalette = SelectPalette(pcw_client.DC(), hPalette, FALSE);
          hOldPalette2 = SelectPalette(pcw_car.DC(), hPalette, FALSE);

          ASSERT(pClientBitmap != NULL);
          pcw_client.SelectBitmap(pClientBitmap);
          ASSERT(pF1CarSmallBitmap != NULL);
          pcw_car.SelectBitmap(pF1CarSmallBitmap);
          {
               RECT           rRect;
               SolidBrush     GrayBrush(RGB(192,192,192));

               rRect.left    = 0;
               rRect.right   = usClientWidth;
               rRect.top     = 0;
               rRect.bottom  = usClientHeight;
               pcw_client.FillRect(&rRect, &GrayBrush);

               usTeamIndex = 0;
               for (usY = 0; usY < TEAMS_NUM_Y; usY++) {
                    for (usX = 0; usX < TEAMS_NUM_X; usX++) {
                         usTmpX = (usX % TEAMS_NUM_X) * usMiniCarWidth;
                         usTmpY = (usY % TEAMS_NUM_Y) * usMiniCarHeight;

                         for (i = 0; i < NUM_ELEMENTS(car_regions); i++) {
                              (void) SelectObject(pcw_car.DC(), car_regions[i].hRgn);
                              SolidBrush  brush(PALETTEINDEX(team_colours[usTeamIndex].usRegionColour[i]));

                              (void) FillRgn(pcw_car.DC(), car_regions[i].hRgn, (HBRUSH) brush.Handle());
                         }

                         BitBlt(   pcw_client.DC(),
                                   usTmpX, usTmpY,
                                   pF1CarSmallBitmap->Width(), pF1CarSmallBitmap->Height(),
                                   pcw_car.DC(),
                                   0, 0,
                                   SRCCOPY
                              );

                         (void) FrameTeam(&pcw_client, usTeamIndex, usTeamIndex == usSelectedTeam);
                         ++usTeamIndex;
                    }
               }
          }
          pcw_client.DeselectBitmap();
          pcw_car.DeselectBitmap();
          (void) SelectPalette(pcw_client.DC(), hOldPalette, FALSE);
          (void) SelectPalette(pcw_car.DC(), hOldPalette2, FALSE);
     }
     cursor.Deselect();

     RepaintWindow();
}
int main(int argc, char**argv) {
  Log::open();
  org::esb::io::File fbp(argv[0]);
  std::string base_path = org::esb::io::File(fbp.getParent()).getParent();

  org::esb::config::Config::setProperty("web.docroot",base_path);
  org::esb::api::ApiWebServer api_server(8888);
  org::esb::api::ProcessHandler proc_handler;
  api_server.addHandler(&proc_handler);
  org::esb::lang::CtrlCHitWaiter::wait();
  //return 0;

    /*first find out if there is running a server*/
  org::esb::grid::Node node;
  node.setData("type", "searcher");
  org::esb::grid::NodeResolver res(boost::asio::ip::address::from_string("0.0.0.0"), boost::asio::ip::address::from_string("239.255.0.1"), 6000, node);
  res.start();
  LOGDEBUG("Waiting 3 secs. to find all online nodes");
  org::esb::lang::Thread::sleep2(3000);
  org::esb::grid::NodeResolver::NodeList nodes = res.getNodes();
  org::esb::grid::NodeResolver::NodeList::iterator nodeit = nodes.begin();
  bool server_running = false;
  int client_count = 0;
  std::string host;
  int port=0;
  for (; nodeit != nodes.end(); nodeit++) {
    LOGDEBUG((*nodeit)->toString());
    LOGDEBUG("NodeType" << (*nodeit)->getData("type"));
    if ((*nodeit)->getData("type") == "server"){
      server_running = true;
      host = (*nodeit)->getIpAddress().to_string();
      port = atoi((*nodeit)->getData("port").c_str());
    }
    if ((*nodeit)->getData("type") == "client")
      client_count++;
  }
  res.stop();

  /**
   * needing the base path from the executable
   * */
  int mode = 0;
  org::esb::io::File f(argv[0]);
  std::cout << f.getParent() << std::endl;
  std::string path = f.getParent();
  std::string bpath = f.getParent();
  bpath.append("/..");
  std::string executable = path;
  std::list<std::string> arguments;
  
  org::esb::io::File file(path.append("/../hive"));
  if (!file.exists()) {
    file.mkdir();
    mode = 1;
  }

#ifdef WIN32
  executable.append("/mhive.exe ");
  //replacing all slashes with backslashes
  int position = executable.find("/"); // find first slash
  while (position != string::npos) {
    executable.replace(position, 1, "\\");
    position = executable.find("/", position + 1);
  }
#else
  executable.append("/mhive");
#endif
  PListener listener;

  /*create internal database*/
  if(mode==1){
    arguments.clear();
    arguments.push_back("--install");
    arguments.push_back("--base="+bpath);
    LOGINFO("Create mhive database")
    org::esb::lang::Process prinst(executable, arguments, "mhiveinstaller");
    prinst.start();
  }
#ifdef USE_SAFMQ
  arguments.clear();
  arguments.push_back("-q");
  arguments.push_back("--base="+bpath);
  //arguments.push_back("--debugmode");
  LOGINFO("Starting mhive queue")
  org::esb::lang::Process prq(executable, arguments, "mhivequeue");
//  PListener listener;
  //prq.addProcessListener(&listener);
  prq.run();
#endif
  LOGINFO("Starting mhive webadmin")
  arguments.clear();
  arguments.push_back("-w");
  arguments.push_back("--base="+bpath);
  org::esb::lang::Process prw(executable, arguments,"mhiveweb");
  //prw.addProcessListener(&listener);
  prw.run();
  org::esb::lang::Process * pra=NULL;
  org::esb::lang::Process * prc=NULL;
  if(!server_running){
    LOGINFO("Starting mhive core service")
    arguments.clear();
    arguments.push_back("-r");
    arguments.push_back("--base="+bpath);
    //arguments.push_back("--debugmode");
    pra=new org::esb::lang::Process(executable, arguments,"mhivecore");
    //PListener listener;
    //pra.addProcessListener(&listener);
    pra->run();
    org::esb::lang::Thread::sleep2(2000);
    LOGINFO("Starting mhive client")
    LOGINFO("Client host="<<host<<" port="<<port);
    arguments.clear();
    arguments.push_back("-i");
//    arguments.push_back("-h 127.0.0.1");
    //arguments.push_back("-p "+org::esb::util::StringUtil::toString(port));
    //arguments.push_back("--base="+bpath);
    //arguments.push_back("--debugmode");
    prc=new org::esb::lang::Process(executable, arguments,"mhiveclient");
    //PListener listener;
    //pra.addProcessListener(&listener);
    prc->run();

  }else{
    LOGINFO("Starting mhive client")
    arguments.clear();
    arguments.push_back("-i");
//    arguments.push_back("-h "+host);
//    arguments.push_back("-p "+org::esb::util::StringUtil::toString(port));
    arguments.push_back("--base="+bpath);
    //arguments.push_back("--debugmode");
    prc=new org::esb::lang::Process(executable, arguments,"mhiveclient");
    //PListener listener;
    //pra.addProcessListener(&listener);
    prc->run();
  }



  open_dialog("Media Encoding Cluster Server is running please open the webpage on http://localhost:8080 now","msgbox");
  arguments.clear();
  arguments.push_back("http://localhost:8080");
//  org::esb::lang::Thread::sleep2(1000);
  open_webadmin();
  org::esb::lang::CtrlCHitWaiter::wait();
  open_dialog("Media Encoding Cluster\nStop signal received!\nhalting now","msgbox");
  try {
    pra->stop();
  } catch (org::esb::lang::ProcessException & ex) {
    try {
      pra->kill();
    } catch (org::esb::lang::ProcessException & ex) {
      LOGERROR("Exception:" << ex.what());
    }
  }
  delete pra;
  try {
    prc->stop();
  } catch (org::esb::lang::ProcessException & ex) {
    try {
      prc->kill();
    } catch (org::esb::lang::ProcessException & ex) {
      LOGERROR("Exception:" << ex.what());
    }
  }
  delete prc;

  try {
    prw.stop();
  } catch (org::esb::lang::ProcessException & ex) {
    try {
      prw.kill();
    } catch (org::esb::lang::ProcessException & ex) {
      LOGERROR("Exception:" << ex.what());
    }
  }
#ifdef USE_SAFMQ
  try {
    prq.stop();
  } catch (org::esb::lang::ProcessException & ex) {
    try {
      prq.kill();
    } catch (org::esb::lang::ProcessException & ex) {
      LOGERROR("Exception:" << ex.what());
    }
  }
#endif
  open_dialog("Media Encoding Cluster stopped!","msgbox");
}