Example #1
0
/**
 * @brief Entry point for docker_image_labels table.
 */
QueryData genImageLabels(QueryContext& context) {
  return getLabels(context,
                   "image", // Docker object type
                   "id", // Look for "id" column in context
                   "Id", // Image primary key is "Id"
                   "/images/json", // All images URL
                   "", // Image array is at top level
                   false, // Does not support "filters" query string
                   false); // Does not support "all" query string
}
Example #2
0
/**
 * @brief Entry point for docker_volume_labels table.
 */
QueryData genVolumeLabels(QueryContext& context) {
  return getLabels(context,
                   "volume", // Docker object type
                   "name", // Look for "name" column in context
                   "Name", // Volume primary key is "Name"
                   "/volumes", // All volumes URL
                   "Volumes", // Volume array is under "Volumes" child node
                   true, // Supports "filters" in query string
                   false); // Does not supports "all" in query string
}
Example #3
0
/**
 * @brief Entry point for docker_network_labels table.
 */
QueryData genNetworkLabels(QueryContext& context) {
  return getLabels(context,
                   "network", // Docker object type
                   "id", // Look for "id" column in context
                   "Id", // Network primary key is "Id"
                   "/networks", // All networks URL
                   "", // Network array is at top level
                   true, // Supports "filters" in query string
                   false); // Does not supports "all" in query string
}
Example #4
0
/**
 * @brief Entry point for docker_container_labels table.
 */
QueryData genContainerLabels(QueryContext& context) {
  return getLabels(context,
                   "container", // Docker object type
                   "id", // Look for "id" column in context
                   "Id", // Container primary key is "Id"
                   "/containers/json", // All containers URL
                   "", // Container array is at top level
                   true, // Supports "filters" in query string
                   true); // Supports "all" in query string
}
Example #5
0
int testpluginPlugin::msg(int msgId, void* wParam, void* lParam)
{
    bool handled = false;
    switch (msgId)
    {
    case MSG_INIT:
        init();
        handled = true;
        break;
    case MSG_GET_LABELS:
        getLabels((InputList*) wParam);
        handled = true;
        break;
    case MSG_GET_ID:
        getID((uint*) wParam);
        handled = true;
        break;
    case MSG_GET_NAME:
        getName((QString*) wParam);
        handled = true;
        break;
    case MSG_GET_RESULTS:
        getResults((InputList*) wParam, (QList<CatItem>*) lParam);
        handled = true;
        break;
    case MSG_GET_CATALOG:
        getCatalog((QList<CatItem>*) wParam);
        handled = true;
        break;
    case MSG_EXTEND_CATALOG:
        extendCatalog((SearchInfo*) wParam, (QList<CatItem>*)lParam);
        handled = true;
        break;
    case MSG_LAUNCH_ITEM:
        handled = launchItem((InputList*) wParam, (QList<CatItem>*) lParam);
        break;
    case MSG_HAS_DIALOG:
        handled = true;
        break;
    case MSG_DO_DIALOG:
        doDialog((QWidget*) wParam, (QWidget**) lParam);
        break;
    case MSG_END_DIALOG:
        endDialog((bool) wParam);
        break;
    case MSG_PATH:
        setPath((QString *) wParam);
    default:
        break;
    }

    return handled;
}
Example #6
0
    vec1<optional<Permutation> > getTransversal() const
    {
        vec1<optional<int> > translabels(getTranslabels());
        vec1<Permutation> labels(getLabels());

        vec1<optional<Permutation> > p(translabels.size(), optional<Permutation>());
        for(int i : range1(translabels.size()))
        {
            if(translabels[i])
            {
                p[i] = labels[*(translabels[i])];
            }
        }
        return p;
    }
Example #7
0
int VerbyPlugin::msg(int msgId, void* wParam, void* lParam)
{
    int handled = 0;
    switch (msgId)
    {        
    case MSG_INIT:
        init();
        handled = true;
        break;
    case MSG_GET_ID:
        getID((uint*) wParam);
        handled = true;
        break;
    case MSG_GET_NAME:
        getName((QString*) wParam);
        handled = true;
        break;
    case MSG_GET_LABELS:
        getLabels((QList<InputData>*) wParam);
        handled = true;
        break;
    case MSG_GET_RESULTS:
        getResults((QList<InputData>*) wParam, (QList<CatItem>*) lParam);
        handled = true;
        break;
    case MSG_LAUNCH_ITEM:
        handled = launchItem((QList<InputData>*) wParam, (CatItem*) lParam);
        break;
    case MSG_HAS_DIALOG:
        handled = true;
        break;
    case MSG_DO_DIALOG:
        doDialog((QWidget*) wParam, (QWidget**) lParam);
        break;
    case MSG_END_DIALOG:
        endDialog(wParam != 0);
        break;
    case MSG_PATH:
        setPath((QString *) wParam);
        break;

    default:
        break;
    }

    return handled;
}
Example #8
0
void		RoomPanel::updatePlayers(std::vector<std::string> &vector, int from)
{
  (void)from;
  RenderWindow *window = RenderWindow::getInstance();
  unsigned int i = 0;

  while (i < vector.size() - 2)
    {
      getPlayers().at(i)->setUsername(vector.at(i));
      _backgrounds.at(i + 1).setTexture(*_spaceShipsTextures.at(i + 1));


      getLabels().at(i + 2).setString(vector.at(i));
      getLabels().at(i + 2).setOrigin(_labels.at(i + 2).getText().getGlobalBounds().width / 2, _labels.at(i + 2).getText().getGlobalBounds().height / 2);
      _nbPlayers++;
      i++;
    }
  i--;
  _players.at(i)->setCurrentClient(true);
  _currentPlayer = i + 1;

  switch (i)
    {
    case 0:
      getLabels().at(i + 2).setColor(Color::BLUE);
      break;
    case 1:
      getLabels().at(i + 2).setColor(Color::RED);
      break;
    case 2:
      getLabels().at(i + 2).setColor(Color::GREEN);
      break;
    case 3:
      getLabels().at(i + 2).setColor(Color::YELLOW);
      break;
    default:
      getLabels().at(i + 2).setColor(Color::WHITE);
      break;
    }

  _idRoom = vector.at(vector.size() - 2);
  _labels.at(6).setString(_idRoom);
  _labels.at(6).setOrigin(_labels.at(6).getText().getGlobalBounds().width / 2, _labels.at(6).getText().getGlobalBounds().height / 2);
  _labels.at(6).setPosition(Vector2(0.5 * window->getSize()._x, 0.95 * window->getSize()._y));
}
////
// Initialization Routine
////
bool CGameLauncher::setupMenu()
{
    m_mustquit      = false;
    mDonePatchSelection = false;
    m_chosenGame    = -1;
    m_ep1slot       = -1;
    mLauncherDialog.initEmptyBackground();
    mSelection      = -1;

    bool gamesDetected = false;

    // TODO: Put that scanning into a separate so we can show a loading menu
    // Scan for games...
    m_DirList.clear();
    m_Entries.clear();

    gLogging.ftextOut("Game Autodetection Started<br>" );

    // Process any custom labels
    getLabels();

    // Scan VFS DIR_ROOT for exe's
    gamesDetected |= scanExecutables(DIR_ROOT);
    mGameScanner.setPermilage(100);

    // Recursivly scan into DIR_GAMES subdir's for exe's
    gamesDetected |= scanSubDirectories(DIR_GAMES, DEPTH_MAX_GAMES, 200, 900);

    mpSelList = new CGUITextSelectionList();

    // Save any custom labels
    putLabels();

    // Create an empty Bitmap control
    mLauncherDialog.addControl( new CGUIBitmap(),
                                GsRect<float>(0.51f, 0.07f, 0.48f, 0.48f) );

    mCurrentBmp = std::dynamic_pointer_cast< CGUIBitmap >
                  ( mLauncherDialog.getControlList().back() );

    mpPrevievBmpVec.resize(m_Entries.size());

	std::vector<GameEntry>::iterator it = m_Entries.begin();
    unsigned int i=0;
    for( ; it != m_Entries.end() ; it++	)
    {
    	mpSelList->addText(it->name);

        // And try to add a preview bitmap
        std::string fullfilename = "preview.bmp";
        fullfilename = getResourceFilename(fullfilename, it->path, false);
        fullfilename = GetFullFileName(fullfilename);

        if(IsFileAvailable(fullfilename))
        {
            SDL_Surface *pPrimBmp = SDL_LoadBMP(GetFullFileName(fullfilename).c_str());
            std::shared_ptr<SDL_Surface> bmpSfcPtr( pPrimBmp );
            std::shared_ptr<GsBitmap> pBmp(new GsBitmap(bmpSfcPtr));
            mpPrevievBmpVec[i] = pBmp;
        }
        i++;
    }

    mpSelList->setConfirmButtonEvent(new GMStart());
    mpSelList->setBackButtonEvent(new GMQuit());

    mLauncherDialog.addControl(new CGUIText("Pick a Game"), GsRect<float>(0.0f, 0.0f, 1.0f, 0.05f));
    mLauncherDialog.addControl(new GsButton( "x", new GMQuit() ), GsRect<float>(0.0f, 0.0f, 0.07f, 0.07f) );
    mLauncherDialog.addControl(mpSelList, GsRect<float>(0.01f, 0.07f, 0.49f, 0.79f));


    mLauncherDialog.addControl(new GsButton( "Start >", new GMStart() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );

#ifdef DBFUSION

    GsButton *fusionShellBtn = new GsButton( "DosFusion Shell >", new GMDBFusionStart() );
    GsButton *fusionBtn = new GsButton( "DosFusion! >", new GMDosGameFusionStart() );

    if(disallowDBFusion)
    {
        fusionShellBtn->enable(false);
        fusionBtn->enable(false);
    }

    mLauncherDialog.addControl( fusionShellBtn, GsRect<float>(0.01f, 0.865f, 0.3f, 0.07f) );
    mLauncherDialog.addControl( fusionBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
#endif



#ifdef DOWNLOADER
    GsButton *downloadBtn = new GsButton( "New Stuff", new GMDownloadDlgOpen() );
    mLauncherDialog.addControl( downloadBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
#endif

    mpEpisodeText = new CGUIText("Game");
    mpVersionText = new CGUIText("Version");
    mLauncherDialog.addControl(mpEpisodeText, GsRect<float>(0.5f, 0.75f, 0.5f, 0.05f));
    mLauncherDialog.addControl(mpVersionText, GsRect<float>(0.5f, 0.80f, 0.5f, 0.05f));

    // This way it goes right to the selection list.
    mLauncherDialog.setSelection(2);

    mGameScanner.setPermilage(1000);

    gLogging.ftextOut("Game Autodetection Finished<br>" );
    // Banner. TODO: Create a class for that...
    CGUIBanner *banner = new CGUIBanner("Commander Genius " CGVERSION "\n"
                    "By Gerstrong,\n"
                    "Hagel,\n"
                    "Tulip,\n"
                    "NY00123,\n"
                    "Pelya,\n"
					"and the CG Contributors\n");
    mLauncherDialog.addControl( banner, GsRect<float>(0.0f, 0.95f, 1.0f, 0.05f) );

    if(!gamesDetected)
        return false;

    const std::string gameDir = gArgs.getValue("dir");
    if(!gameDir.empty())
    {
        int chosenGame = 0;
        bool found=false;

        // Check if the given parameter makes one game start.
        for( GameEntry &entry : m_Entries)
        {
            if(entry.path == gameDir)
            {
                // found!
                m_chosenGame = chosenGame;
                gLogging.textOut("Launching game from directory: \"" + gameDir + "\"\n");
                gArgs.removeTag("dir");

                setupModsDialog();
                // Nothing else to do, break the loop
                found = true;
                break;
            }
            chosenGame++;
        }

        if(!found)
        {
            const std::string err = "The game from directory: \"" + gameDir + "\" cannot the launched." +
                    "Maybe it's missing or not compatible. Please check if you can run that through the game launcher.\n";

            gLogging.textOut(err);

            showMessageBox("Given path :\"" + gameDir + "\" unknown.\nPlease check the CGLog File!");
        }
    }

    return true;
}
 void ColorHistogramLabelMatch::match(
   const sensor_msgs::Image::ConstPtr& image_msg,
   const sensor_msgs::Image::ConstPtr& label_msg,
   const sensor_msgs::Image::ConstPtr& mask_msg)
 {
   boost::mutex::scoped_lock lock(mutex_);
   if (histogram_.empty()) {
     NODELET_DEBUG("no reference histogram is available");
     return;
   }
   
   cv::Mat image
     = cv_bridge::toCvShare(image_msg, image_msg->encoding)->image;
   cv::Mat label
     = cv_bridge::toCvShare(label_msg, label_msg->encoding)->image;
   cv::Mat whole_mask
     = cv_bridge::toCvShare(mask_msg, mask_msg->encoding)->image;
   
   cv::Mat coefficient_image = cv::Mat::zeros(
     image_msg->height, image_msg->width, CV_32FC1);
   std::vector<int> labels;
   getLabels(label, labels);
   
   cv::Mat coefficients_heat_image = cv::Mat::zeros(
     image_msg->height, image_msg->width, CV_8UC3); // BGR8
   int hist_size = histogram_.cols;
   float range[] = { min_value_, max_value_ };
   const float* hist_range = { range };
   double min_coef = DBL_MAX;
   double max_coef = - DBL_MAX;
   for (size_t i = 0; i < labels.size(); i++) {
     int label_index = labels[i];
     cv::Mat label_mask = cv::Mat::zeros(label.rows, label.cols, CV_8UC1);
     getMaskImage(label, label_index, label_mask);
     double coef = 0.0;
     // get label_mask & whole_mask and check is it all black or not
     cv::Mat masked_label;
     label_mask.copyTo(masked_label, whole_mask);
     if (isMasked(label_mask, masked_label)) {
       coef = masked_coefficient_;
     }
     else {
       cv::MatND hist;
       bool uniform = true; bool accumulate = false;
       cv::calcHist(&image, 1, 0, label_mask, hist, 1,
                    &hist_size, &hist_range, uniform, accumulate);
       cv::normalize(hist, hist, 1, hist.rows, cv::NORM_L2, -1,
                     cv::Mat());
       cv::Mat hist_mat = cv::Mat::zeros(1, hist_size, CV_32FC1);
       for (size_t j = 0; j < hist_size; j++) {
         hist_mat.at<float>(0, j) = hist.at<float>(0, j);
       }
       //cv::Mat hist_mat = hist;
     
       coef = coefficients(hist_mat, histogram_);
       if (min_coef > coef) {
         min_coef = coef;
       }
       if (max_coef < coef) {
         max_coef = coef;
       }
     }
     std_msgs::ColorRGBA coef_color = jsk_topic_tools::heatColor(coef);
     for (size_t j = 0; j < coefficients_heat_image.rows; j++) {
       for (size_t i = 0; i < coefficients_heat_image.cols; i++) {
         if (label_mask.at<uchar>(j, i) == 255) {
           coefficients_heat_image.at<cv::Vec3b>(j, i)
             = cv::Vec3b(int(coef_color.b * 255),
                         int(coef_color.g * 255),
                         int(coef_color.r * 255));
           coefficient_image.at<float>(j, i) = coef;
         }
       }
     }
   }
   NODELET_INFO("coef: %f - %f", min_coef, max_coef);
   pub_debug_.publish(
     cv_bridge::CvImage(image_msg->header,
                        sensor_msgs::image_encodings::BGR8,
                        coefficients_heat_image).toImageMsg());
   pub_coefficient_image_.publish(
     cv_bridge::CvImage(image_msg->header,
                        sensor_msgs::image_encodings::TYPE_32FC1,
                        coefficient_image).toImageMsg());
   // apply threshold operation
   cv::Mat threshold_image = cv::Mat::zeros(
     coefficient_image.rows, coefficient_image.cols, CV_32FC1);
   if (threshold_method_ == 0) { // smaller than
     cv::threshold(coefficient_image, threshold_image, coef_threshold_, 1,
                  cv::THRESH_BINARY_INV);
   }
   else if (threshold_method_ == 1) { // greater than
     cv::threshold(coefficient_image, threshold_image, coef_threshold_, 1,
                   cv::THRESH_BINARY);
   }
   else if (threshold_method_ == 2 || threshold_method_ == 3) {
     // convert image into 8UC to apply otsu' method
     cv::Mat otsu_image = cv::Mat::zeros(
       coefficient_image.rows, coefficient_image.cols, CV_8UC1);
     cv::Mat otsu_result_image = cv::Mat::zeros(
       coefficient_image.rows, coefficient_image.cols, CV_8UC1);
     coefficient_image.convertTo(otsu_image, 8, 255.0);
     cv::threshold(otsu_image, otsu_result_image, coef_threshold_, 255,
                   cv::THRESH_OTSU);
     // convert it into float image again
     if (threshold_method_ == 2) {
       otsu_result_image.convertTo(threshold_image, 32, 1 / 255.0);
     }
     else if (threshold_method_ == 3) {
       otsu_result_image.convertTo(threshold_image, 32, - 1 / 255.0, 1.0);
     }
   }
   cv::Mat threshold_uchar_image = cv::Mat(threshold_image.rows,
                                           threshold_image.cols,
                                           CV_8UC1);
   threshold_image.convertTo(threshold_uchar_image, 8, 255.0);
   // convert image from float to uchar
   pub_result_.publish(
     cv_bridge::CvImage(image_msg->header,
                        sensor_msgs::image_encodings::MONO8,
                        threshold_uchar_image).toImageMsg());
 }