当前位置: 首页>>代码示例>>C++>>正文


C++ opt函数代码示例

本文整理汇总了C++中opt函数的典型用法代码示例。如果您正苦于以下问题:C++ opt函数的具体用法?C++ opt怎么用?C++ opt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了opt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Q_D

/*!\reimp
*/
void QLabel::paintEvent(QPaintEvent *)
{
    Q_D(QLabel);
    QStyle *style = QWidget::style();
    QPainter painter(this);
    drawFrame(&painter);
    QRect cr = contentsRect();
    cr.adjust(d->margin, d->margin, -d->margin, -d->margin);
    int align = QStyle::visualAlignment(layoutDirection(), QFlag(d->align));

#ifndef QT_NO_MOVIE
    if (d->movie) {
        if (d->scaledcontents)
            style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap().scaled(cr.size()));
        else
            style->drawItemPixmap(&painter, cr, align, d->movie->currentPixmap());
    }
    else
#endif
    if (d->isTextLabel) {
        QRectF lr = d->layoutRect();
        if (d->control) {
#ifndef QT_NO_SHORTCUT
            const bool underline = (bool)style->styleHint(QStyle::SH_UnderlineShortcut, 0, this, 0);
            if (d->shortcutId != 0
                && underline != d->shortcutCursor.charFormat().fontUnderline()) {
                QTextCharFormat fmt;
                fmt.setFontUnderline(underline);
                d->shortcutCursor.mergeCharFormat(fmt);
            }
#endif
            d->ensureTextLayouted();

            QAbstractTextDocumentLayout::PaintContext context;
            QStyleOption opt(0);
            opt.init(this);

            if (!isEnabled() && style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)) {
                context.palette = palette();
                context.palette.setColor(QPalette::Text, context.palette.light().color());
                painter.save();
                painter.translate(lr.x() + 1, lr.y() + 1);
                painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1));
                QAbstractTextDocumentLayout *layout = d->control->document()->documentLayout();
                layout->draw(&painter, context);
                painter.restore();
            }

            // Adjust the palette
            context.palette = palette();
            if (foregroundRole() != QPalette::Text && isEnabled())
                context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));

            painter.save();
            painter.translate(lr.topLeft());
            painter.setClipRect(lr.translated(-lr.x(), -lr.y()));
            d->control->setPalette(context.palette);
            d->control->drawContents(&painter, QRectF(), this);
            painter.restore();
        } else {
            int flags = align;
            if (d->hasShortcut) {
                flags |= Qt::TextShowMnemonic;
                QStyleOption opt;
                opt.initFrom(this);
                if (!style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this))
                    flags |= Qt::TextHideMnemonic;
            }
            style->drawItemText(&painter, lr.toRect(), flags, palette(), isEnabled(), d->text, foregroundRole());
        }
    } else
#ifndef QT_NO_PICTURE
    if (d->picture) {
        QRect br = d->picture->boundingRect();
        int rw = br.width();
        int rh = br.height();
        if (d->scaledcontents) {
            painter.save();
            painter.translate(cr.x(), cr.y());
            painter.scale((double)cr.width()/rw, (double)cr.height()/rh);
            painter.drawPicture(-br.x(), -br.y(), *d->picture);
            painter.restore();
        } else {
            int xo = 0;
            int yo = 0;
            if (align & Qt::AlignVCenter)
                yo = (cr.height()-rh)/2;
            else if (align & Qt::AlignBottom)
                yo = cr.height()-rh;
            if (align & Qt::AlignRight)
                xo = cr.width()-rw;
            else if (align & Qt::AlignHCenter)
                xo = (cr.width()-rw)/2;
            painter.drawPicture(cr.x()+xo-br.x(), cr.y()+yo-br.y(), *d->picture);
        }
    } else
#endif
    if (d->pixmap && !d->pixmap->isNull()) {
//.........这里部分代码省略.........
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:101,代码来源:qlabel.cpp

示例2: paint

    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
        if (!index.isValid()) {
            return;
        }
        bool mouseOver = option.state & QStyle::State_MouseOver;
        bool gtk = mouseOver && qApp->style()->inherits("QGtkStyle");
        bool selected = option.state & QStyle::State_Selected;
        bool drawBgnd = true;

        if (!underMouse) {
            if (mouseOver && !selected) {
                drawBgnd = false;
            }
            mouseOver = false;
        }

        const QString text = index.model()->data(index, Qt::DisplayRole).toString();
        const QIcon icon = index.model()->data(index, Qt::DecorationRole).value<QIcon>();
        const QPixmap pixmap = icon.pixmap(iconSize, iconSize);

        QFontMetrics fm = painter->fontMetrics();
        int wp = pixmap.width();
        int hp = pixmap.height();

        QTextLayout iconTextLayout(text, option.font);
        QTextOption textOption(Qt::AlignHCenter);
        iconTextLayout.setTextOption(textOption);
        int maxWidth = qMax(3 * wp, 8 * fm.height());
        layoutText(&iconTextLayout, maxWidth);

        QPen pen = painter->pen();
        QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                                  ? QPalette::Normal : QPalette::Disabled;
        if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
            cg = QPalette::Inactive;
        }

        QStyleOptionViewItem opt(option);
        opt.showDecorationSelected = true;
        QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();

        if (drawBgnd) {
            if (mouseOver && gtk) {
                painter->save();
                opt.state |= QStyle::State_Selected;
                painter->setOpacity(selected ? 0.75 : 0.25);
            }
            style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
            if (mouseOver && gtk) {
                painter->restore();
            }
        }

        if (selected) {
            painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
        } else {
            painter->setPen(option.palette.color(cg, QPalette::Text));
        }

        painter->drawPixmap(option.rect.x() + (option.rect.width() / 2) - (wp / 2), option.rect.y() + 5, pixmap);
        if (!text.isEmpty()) {
            iconTextLayout.draw(painter, QPoint(option.rect.x() + (option.rect.width() / 2) - (maxWidth / 2), option.rect.y() + hp + 7));
        }
        painter->setPen(pen);
        drawFocus(painter, option, option.rect);
    }
开发者ID:CDrummond,项目名称:carbon,代码行数:66,代码来源:pagewidget.cpp

示例3: TEST

TEST(ErrorBlockTests, error_blocks_maxwell)
{
  ros::NodeHandle nh("~");

  robot_calibration::Optimizer opt(robot_description);

  std::vector<robot_calibration_msgs::CalibrationData> data;
  robot_calibration_msgs::CalibrationData msg;

  // Match expected output from chain manager
  msg.joint_states.name.resize(10);
  msg.joint_states.name[0] = "arm_lift_joint";
  msg.joint_states.name[1] = "arm_shoulder_pan_joint";
  msg.joint_states.name[2] = "arm_shoulder_lift_joint";
  msg.joint_states.name[3] = "arm_upperarm_roll_joint";
  msg.joint_states.name[4] = "arm_elbow_flex_joint";
  msg.joint_states.name[5] = "arm_wrist_flex_joint";
  msg.joint_states.name[6] = "arm_wrist_roll_joint";
  msg.joint_states.name[7] = "head_pan_joint";
  msg.joint_states.name[8] = "head_tilt_joint";
  msg.joint_states.name[9] = "arm_lift_joint";
  msg.joint_states.position.resize(10);
  msg.joint_states.position[0] = -0.05;  // Add some error
  msg.joint_states.position[1] = -0.814830;
  msg.joint_states.position[2] = -0.00022290000000002586;
  msg.joint_states.position[3] = 0.0;
  msg.joint_states.position[4] = -0.7087341;
  msg.joint_states.position[5] = 0.0;
  msg.joint_states.position[6] = 0.0;
  msg.joint_states.position[7] = -0.8280187999999999;
  msg.joint_states.position[8] = 0.6358500000000002;
  msg.joint_states.position[9] = 0.0;

  // Expectect output from led finder
  msg.observations.resize(2);
  msg.observations[0].sensor_name = "camera";
  msg.observations[1].sensor_name = "arm";

  msg.observations[0].features.resize(1);
  msg.observations[0].features[0].header.frame_id = "head_camera_rgb_optical_frame";
  msg.observations[0].features[0].point.x = -0.0143163670728;
  msg.observations[0].features[0].point.y = 0.111304592065;
  msg.observations[0].features[0].point.z = 0.522079317365;

  msg.observations[0].ext_camera_info.camera_info.P[0] = 100.0;  // fx
  msg.observations[0].ext_camera_info.camera_info.P[5] = 100.0;  // fy
  msg.observations[0].ext_camera_info.camera_info.P[2] = 320.0;  // cx
  msg.observations[0].ext_camera_info.camera_info.P[6] = 240.0;  // cy
  msg.observations[0].ext_camera_info.parameters.resize(2);
  msg.observations[0].ext_camera_info.parameters[0].name = "z_offset";
  msg.observations[0].ext_camera_info.parameters[0].value = 0.0;
  msg.observations[0].ext_camera_info.parameters[1].name = "z_scaling";
  msg.observations[0].ext_camera_info.parameters[1].value = 1.0;

  msg.observations[1].features.resize(1);
  msg.observations[1].features[0].header.frame_id = "gripper_led_frame";
  msg.observations[1].features[0].point.x = 0.0;
  msg.observations[1].features[0].point.y = 0.0;
  msg.observations[1].features[0].point.z = 0.0;

  // Add first data point
  data.push_back(msg);

  // Add a second data point that is just a little different
  msg.joint_states.position[1] = -0.019781999999999966;
  msg.joint_states.position[7] = 0.0;
  msg.observations[0].features[0].point.x = 0.0365330705881;
  msg.observations[0].features[0].point.y = 0.102609552493;
  msg.observations[0].features[0].point.z = 0.536061220027;
  data.push_back(msg);

  // And a third data point
  msg.joint_states.position[1] = 0.883596;
  msg.joint_states.position[7] = 0.9442135999999999;
  msg.observations[0].features[0].point.x = 0.0942445346646;
  msg.observations[0].features[0].point.y = 0.11409172323;
  msg.observations[0].features[0].point.z = 0.517497963716;
  data.push_back(msg);

  // Setup params
  robot_calibration::OptimizationParams params;
  params.LoadFromROS(nh);

  // Optimize
  opt.optimize(params, data, false);
  EXPECT_GT(opt.summary()->initial_cost, 0.001);
  EXPECT_LT(opt.summary()->final_cost, 1e-18);
  EXPECT_GT(opt.summary()->iterations.size(), static_cast<size_t>(1));  // expect more than 1 iteration
  // The -0.05 we added above should be calibrated off
  EXPECT_LT(fabs(0.05 - opt.getOffsets()->get("arm_lift_joint")), 0.001);
  // 1 joint
  EXPECT_EQ(1, opt.getNumParameters());
  // 3 CalibrationData, each with chain3d with a single observed point (3 residuals)
  EXPECT_EQ(9, opt.getNumResiduals());
}
开发者ID:mikeferguson,项目名称:robot_calibration,代码行数:95,代码来源:error_block_tests2.cpp

示例4: initShortcutDescriptionTableEntry

void FQTermShortcutHelper::initShortcutDescriptionTable()
{
    initShortcutDescriptionTableEntry(CONNECT, "connect", tr(""), tr("Connect Host"), "connect");
    initShortcutDescriptionTableEntry(CASCADEWINDOWS, "cascadewindows", tr(""), tr("Cascade Windows"));
    initShortcutDescriptionTableEntry(TILEWINDOWS, "tilewindows", tr(""), tr("Tils Windows"));
    initShortcutDescriptionTableEntry(DISCONNECT, "disconnect", tr(""), tr("Disconnect Host"), "disconnect");
    initShortcutDescriptionTableEntry(ADDRESSBOOK, "addressbook", tr("F2"), tr("Address Book"), "address_book");
    initShortcutDescriptionTableEntry(QUICKLOGIN, "quicklogin", tr("F3"), tr("Quick Login"), "quick_login");
#if defined(__APPLE__)
    initShortcutDescriptionTableEntry(COPY, "copy", tr("Ctrl+C"), tr("Copy"), "copy");
    initShortcutDescriptionTableEntry(PASTE, "paste", tr("Ctrl+V"), tr("Paste"), "paste");
#else
    initShortcutDescriptionTableEntry(COPY, "copy", tr("Ctrl+Ins"), tr("Copy"), "copy");
    initShortcutDescriptionTableEntry(PASTE, "paste", tr("Shift+Insert"), tr("Paste"), "paste");
#endif
    initShortcutDescriptionTableEntry(COPYWITHCOLOR, "copywithcolor", tr(""), tr("Copy With Color"), "copy_with_color");
    getAction(COPYWITHCOLOR)->setCheckable(true);
    initShortcutDescriptionTableEntry(RECTANGLESELECTION, "rectangleselection", tr(""), tr("Rectangle Selection"), "rectangle_selection");
    getAction(RECTANGLESELECTION)->setCheckable(true);
    initShortcutDescriptionTableEntry(AUTOCOPYSELECTION, "autocopyselection", tr(""), tr("Auto Copy Selection"));
    getAction(AUTOCOPYSELECTION)->setCheckable(true);
    initShortcutDescriptionTableEntry(PASTEWORDWRAP, "pastewordwrap", tr(""), tr("Paste With Word Wrap"));
    getAction(PASTEWORDWRAP)->setCheckable(true);
    initShortcutDescriptionTableEntry(ENGLISHFONT, "englishfont", tr(""), tr("Set English Font"));
    initShortcutDescriptionTableEntry(OTHERFONT, "nonenglishfont", tr(""), tr("Set Other Font"));
    initShortcutDescriptionTableEntry(COLORSETTING, "colorsetting", tr(""), tr("Color Setting"), "ansi_color");
    initShortcutDescriptionTableEntry(REFRESHSCREEN, "refreshscreen", tr(""), tr("Refresh Screen"), "refresh");
    initShortcutDescriptionTableEntry(ANSICOLOR, "ansicolor", tr(""), tr("Toggle Ansi Color"), "toggle_ansi_color");
    getAction(ANSICOLOR)->setCheckable(true);
    initShortcutDescriptionTableEntry(UIFONT, "uifont", tr(""), tr("Set UI Font"));
    initShortcutDescriptionTableEntry(FULLSCREEN, "fullscreen", tr("F6"), tr("Toggle Full Screen"));
    getAction(FULLSCREEN)->setCheckable(true);
    initShortcutDescriptionTableEntry(BOSSCOLOR, "bosscolor", tr("F12"), tr("Toggle Boss Color"));
    getAction(BOSSCOLOR)->setCheckable(true);
    initShortcutDescriptionTableEntry(SWITCHBAR, "switchbar", tr(""), tr("Toggle Switch Bar"));
    getAction(SWITCHBAR)->setCheckable(true);
    initShortcutDescriptionTableEntry(CURRENTSETTING, "currentsetting", tr(""), tr("Current Session Setting"), "preferences");
    initShortcutDescriptionTableEntry(SEARCHIT, "googleit", tr("Ctrl+Alt+G"), tr("Google selected words"));
    initShortcutDescriptionTableEntry(WEIBOSHARE, "shareit", tr("Alt+`"), tr("Share selected text and highlighted URL to weibo"));
    initShortcutDescriptionTableEntry(EXTERNALEDITOR, "externaleditor", tr("Ctrl+Alt+E"), tr("Invoke external editor"));
    initShortcutDescriptionTableEntry(FASTPOST, "fastpost", tr("Ctrl+Alt+F"), tr("Fast post from clipboard"));
    initShortcutDescriptionTableEntry(DEFAULTSETTING, "defaultsetting", tr(""), tr("Default Setting"));
    initShortcutDescriptionTableEntry(PREFERENCE, "preference", tr(""), tr("Preference"), "preferences");
    initShortcutDescriptionTableEntry(EDITSCHEMA, "schema", tr(""), tr("Edit Schema"));
    initShortcutDescriptionTableEntry(SHORTCUTSETTING, "shortcut", tr(""), tr("Shorcut Setting"));
    initShortcutDescriptionTableEntry(COPYARTICLE, "copyarticle", tr("F9"), tr("Copy Article"), "get_article_fulltext");
    initShortcutDescriptionTableEntry(ANTIIDLE, "antiidle", tr(""), tr("Toggle Anti Idle"), "anti_idle");
    getAction(ANTIIDLE)->setCheckable(true);
    initShortcutDescriptionTableEntry(AUTOREPLY, "autoreply", tr(""), tr("Toggle Auto Reply"), "auto_reply");
    getAction(AUTOREPLY)->setCheckable(true);
    initShortcutDescriptionTableEntry(VIEWMESSAGE, "viewmessage", tr("F10"), tr("View Messages"), "view_messages");
    initShortcutDescriptionTableEntry(IPLOOKUP, "iplookup", tr(""), tr("IP Lookup"));
    initShortcutDescriptionTableEntry(BEEP, "beep", tr(""), tr("Toggle Beep"), "beep");
    getAction(BEEP)->setCheckable(true);
    initShortcutDescriptionTableEntry(MOUSESUPPORT, "mousesupport", tr(""), tr("Toggle Mouse Support"), "mouse");
    getAction(MOUSESUPPORT)->setCheckable(true);
    initShortcutDescriptionTableEntry(IMAGEVIEWER, "imageviewer", tr(""), tr("Image Viewer"), "image_viewer");
    initShortcutDescriptionTableEntry(RUNSCRIPT, "runscript", tr("F7"), tr("Run Script"));
    initShortcutDescriptionTableEntry(STOPSCRIPT, "stop", tr("F8"), tr("Stop Script"));
#ifdef HAVE_PYTHON
    initShortcutDescriptionTableEntry(RUNPYTHONSCRIPT, "runpythonscript", tr("Ctrl+F1"), tr("Run Python Script"));
#endif //HAVE_PYTHON
    initShortcutDescriptionTableEntry(ABOUT, "about", tr("Shift+F1"), tr("About"));
    initShortcutDescriptionTableEntry(HOMEPAGE, "homepage", tr(""), tr("Homepage"));
    initShortcutDescriptionTableEntry(EXIT, "exit", tr(""), tr("Exit FQTerm"));
    initShortcutDescriptionTableEntry(COLORCTL_NO, "colorctlno", tr(""), tr("Set Color Ctrl to None"));
    getAction(COLORCTL_NO)->setCheckable(true);
    initShortcutDescriptionTableEntry(COLORCTL_SMTH, "colorctlsmth", tr(""), tr("Set Color Ctrl to **["));
    getAction(COLORCTL_SMTH)->setCheckable(true);
    initShortcutDescriptionTableEntry(COLORCTL_PTT, "colorctlptt", tr(""), tr("Set Color Ctrl to ^u["));
    getAction(COLORCTL_PTT)->setCheckable(true);
    initShortcutDescriptionTableEntry(COLORCTL_OLD_CUSTOM, "colorctloldcustom", tr(""), tr("Set Color Ctrl to old custom"));
    getAction(COLORCTL_OLD_CUSTOM)->setCheckable(true);
    initShortcutDescriptionTableEntry(COLORCTL_CUSTOM, "colorctlcustom", tr(""), tr("Set Color Ctrl to custom"));
    getAction(COLORCTL_CUSTOM)->setCheckable(false);
    initShortcutDescriptionTableEntry(AUTORECONNECT, "autoreconnect", tr(""), tr("Toggle Auto Reconnect"), "auto_reconnect");
    getAction(AUTORECONNECT)->setCheckable(true);
    initShortcutDescriptionTableEntry(SCROLLBAR_LEFT, "scrollbarleft", tr(""), tr("Set Scrollbar to Left"));
    getAction(SCROLLBAR_LEFT)->setCheckable(true);
    initShortcutDescriptionTableEntry(SCROLLBAR_RIGHT, "scrollbarright", tr(""), tr("Set Scrollbar to Right"));
    getAction(SCROLLBAR_RIGHT)->setCheckable(true);
    initShortcutDescriptionTableEntry(SCROLLBAR_HIDDEN, "scrollbarhidden", tr(""), tr("Set Scrollbar Hidden"));
    getAction(SCROLLBAR_HIDDEN)->setCheckable(true);
    initShortcutDescriptionTableEntry(SEARCH_GOOGLE, "searchgoogle", tr(""), tr("Use Google"));
    getAction(SEARCH_GOOGLE)->setCheckable(true);
    initShortcutDescriptionTableEntry(SEARCH_BAIDU, "searchbaidu", tr(""), tr("Use Baidu"));
    getAction(SEARCH_BAIDU)->setCheckable(true);
    initShortcutDescriptionTableEntry(SEARCH_BING, "searchbing", tr(""), tr("Use Bing"));
    getAction(SEARCH_BING)->setCheckable(true);
    initShortcutDescriptionTableEntry(SEARCH_YAHOO, "searchyahoo", tr(""), tr("Use Yahoo!"));
    getAction(SEARCH_YAHOO)->setCheckable(true);
    initShortcutDescriptionTableEntry(SEARCH_CUSTOM, "searchcustom", tr(""), tr("Use Customized SE"));
    getAction(SEARCH_CUSTOM)->setCheckable(true);
    initShortcutDescriptionTableEntry(LANGUAGE_ENGLISH, "languageenglish", tr(""), tr("Choose UI Language: English"));
    getAction(LANGUAGE_ENGLISH)->setCheckable(true);
    initShortcutDescriptionTableEntry(SAVESETTING, "savesetting", tr(""), tr("Save Current Session Setting"), "save_setting");

#if defined(__APPLE__)
    QString opt(tr("Ctrl"));
#else
//.........这里部分代码省略.........
开发者ID:boltomli,项目名称:fqterm,代码行数:101,代码来源:fqterm_shortcuthelper.cpp

示例5: parseOptions

void ShowCounts::execute()
{
    if ( d->state == 0 ) {
        parseOptions();
        end();

        database();
        d->state = 1;

        EString s( Configuration::text( Configuration::DbSchema ) );

        d->query = new Query(
            "select "
            "(select count(*) from users)::int as users,"
            "(select count(*) from mailboxes where deleted='f')::int"
            " as mailboxes,"
            "(" + tuples( "messages" ) + ")::int as messages,"
            "(" + tuples( "bodyparts" ) + ")::int as bodyparts,"
            "(" + tuples( "addresses" ) + ")::int as addresses,"
            "(" + tuples( "deleted_messages" ) + ")::int as dm",
            this
        );

        d->query->bind( 1, s );
        d->query->execute();
    }

    if ( d->state == 1 ) {
        if ( !d->query->done() )
            return;

        Row * r = d->query->nextRow();
        if ( d->query->failed() || !r )
            error( "Couldn't fetch estimates." );

        printf( "Users: %d\n", r->getInt( "users" ) );
        printf( "Mailboxes: %d\n", r->getInt( "mailboxes" ) );

        if ( opt( 'f' ) == 0 ) {
            printf( "Messages: %d", r->getInt( "messages" ) );
            if ( r->getInt( "dm" ) != 0 )
                printf( " (%d deleted)", r->getInt( "dm" ) );
            printf( " (estimated)\n" );
            printf( "Bodyparts: %d (estimated)\n",
                    r->getInt( "bodyparts" ) );
            printf( "Addresses: %d (estimated)\n",
                    r->getInt( "addresses" ) );
            d->state = 666;
            finish();
            return;
        }

        d->query =
            new Query( "select count(*)::int as messages, "
                       "coalesce(sum(rfc822size)::bigint,0) as totalsize, "
                       "(select count(*) from mailbox_messages)::int "
                       "as mm, "
                       "(select count(*) from deleted_messages)::int "
                       "as dm from messages", this );
        d->query->execute();
        d->state = 2;
    }

    if ( d->state == 2 ) {
        if ( !d->query->done() )
            return;

        Row * r = d->query->nextRow();
        if ( d->query->failed() || !r )
            error( "Couldn't fetch messages/deleted_messages counts." );

        int um = r->getInt( "messages" );
        int mm = r->getInt( "mm" );
        int dm = r->getInt( "dm" );

        printf( "Messages: %d unique", um );
        printf( " (%d in mailboxes", mm );
        if ( dm != 0 )
            printf( ", %d deleted", dm );
        printf( ", total size: %s",
                EString::humanNumber( r->getBigint( "totalsize" ) ).cstr() );
        printf( ")\n" );

        d->query =
            new Query( "select count(*)::int as bodyparts,"
                       "coalesce(sum(length(text))::bigint,0) as textsize,"
                       "coalesce(sum(length(data))::bigint,0) as datasize "
                       "from bodyparts", this );
        d->query->execute();
        d->state = 3;
    }

    if ( d->state == 3 ) {
        if ( !d->query->done() )
            return;

        Row * r = d->query->nextRow();
        if ( d->query->failed() || !r )
            error( "Couldn't fetch bodyparts counts." );

//.........这里部分代码省略.........
开发者ID:aox,项目名称:aox,代码行数:101,代码来源:stats.cpp

示例6: main

int main(const int iArgc, const char** iArgv) {
  std::string rootDir;
  ConciseArgs opt(iArgc, (char**)iArgv);
  opt.add(rootDir, "r", "root_dir", "input root directory");
  opt.parse();

  // set up vo
  std::shared_ptr<drc::BotWrapper> botWrapper(new drc::BotWrapper());
  std::shared_ptr<drc::LcmWrapper>
    lcmWrapper(new drc::LcmWrapper(botWrapper->getLcm()));
  auto boostLcm = lcmWrapper->getBoost();
  auto config =
    new voconfig::KmclConfiguration(botWrapper->getBotParam(), "CAMERA");
  boost::shared_ptr<fovis::StereoCalibration>
    calib(config->load_stereo_calibration());
  FoVision vo(boostLcm, calib);

  // find file timestamps
  std::ifstream ifs(rootDir + "/cam_poses.txt");
  std::vector<int64_t> times;
  std::string line;
  while (std::getline(ifs,line)) {
    std::istringstream iss(line);
    int64_t utime;
    iss >> utime;
    times.push_back(utime);
  }

  // iterate
  std::string poseFileName = rootDir + "/fovis_poses.txt";
  std::ofstream ofs(poseFileName);
  ofs << std::setprecision(15);
  for (auto utime : times) {
    std::string fileName;
    std::ostringstream oss;

    // read image
    oss << rootDir << "/color_" << utime << ".png";
    cv::Mat img = cv::imread(oss.str());
    cv::cvtColor(img,img,CV_RGB2GRAY);

    // read disparity
    oss.str("");
    oss.clear();
    oss << rootDir << "/disp_" << utime << ".float";
    std::ifstream ifs(oss.str(), std::ios::binary);
    int width, height;
    ifs.read((char*)&width, sizeof(width));
    ifs.read((char*)&height, sizeof(height));
    std::vector<float> vals(width*height);
    ifs.read((char*)vals.data(), width*height*sizeof(float));
    ifs.close();
    cv::Mat disp(height,width,CV_32FC1,vals.data());

    // do fovis
    vo.doOdometry(img.data, (float*)disp.data, utime);
    Eigen::Isometry3d delta;
    auto worldToCamera = Eigen::Isometry3d::Identity();
    Eigen::MatrixXd cov;
    fovis::MotionEstimateStatusCode status;
    vo.getMotion(delta, cov, status);
    worldToCamera = worldToCamera*delta;
    vo.fovis_stats();

    // write pose
    auto cameraPose = worldToCamera.inverse();
    auto& m = cameraPose;
    ofs << utime << " " <<
      m(0,0) << " " << m(0,1) << " " << m(0,2) << " " << m(0,3) << " " <<
      m(1,0) << " " << m(1,1) << " " << m(1,2) << " " << m(1,3) << " " << 
      m(2,0) << " " << m(2,1) << " " << m(2,2) << " " << m(2,3) << std::endl;
  }
  ofs.close();

  return 1;
}
开发者ID:Gastd,项目名称:oh-distro,代码行数:76,代码来源:feed-fovis.cpp

示例7: opt

    //-------------------------------------------------------------------------------------------------//
    void OSXCarbonWindow::create( const String& name, unsigned int width, unsigned int height,
                    bool fullScreen, const NameValuePairList *miscParams )
    {
        bool hasDepthBuffer = false;
        String title = name;
        size_t fsaa_samples = 0;
        int left = 0;
        int top = 0;
        bool vsync = false;
        bool hidden = false;
        int depth = 32;

        if( miscParams )
        {
            NameValuePairList::const_iterator opt(NULL);
            NameValuePairList::const_iterator end = miscParams->end();

            // Full screen anti aliasing
            if((opt = miscParams->find("FSAA")) != end) 
                fsaa_samples = StringConverter::parseUnsignedInt( opt->second );

            if((opt = miscParams->find("left")) != end) 
                left = StringConverter::parseUnsignedInt( opt->second );

            if((opt = miscParams->find("top")) != end) 
                top = StringConverter::parseUnsignedInt( opt->second );

            if((opt = miscParams->find("title")) != end) 
                title = opt->second;

            if((opt = miscParams->find("vsync")) != end) 
                vsync = StringConverter::parseBool(opt->second);

            if((opt = miscParams->find("hidden")) != end) 
                hidden = StringConverter::parseBool(opt->second);

            if((opt = miscParams->find("gamma")) != end) 
				mHwGamma = StringConverter::parseBool(opt->second);

            if((opt = miscParams->find("depthBuffer")) != end) 
                hasDepthBuffer = StringConverter::parseBool( opt->second );
            
            if((opt = miscParams->find("colourDepth")) != end) 
                depth = StringConverter::parseUnsignedInt( opt->second );

            if((opt = miscParams->find("Full Screen")) != end) 
                fullScreen = StringConverter::parseBool( opt->second );
        }

        if(fullScreen)
        {
            setFullscreen(fullScreen, width, height);
        }
        else
        {
            createAGLContext(fsaa_samples, depth);

            NameValuePairList::const_iterator opt(NULL);
            if(miscParams)
                opt = miscParams->find("externalWindowHandle");

            if(!miscParams || opt == miscParams->end())
                createNewWindow(width, height, title.c_str());
            else
                createWindowFromExternal((HIViewRef)StringConverter::parseUnsignedLong(opt->second));

            // Set the drawable, and current context
            // If you do this last, there is a moment before the rendering window pops-up
            // This could go once inside each case above, before the window is displayed,
            // if desired.
    #if defined(MAC_OS_X_VERSION_10_4) && MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
            aglSetDrawable(mAGLContext, GetWindowPort(mWindow));
    #else
            aglSetWindowRef(mAGLContext, mWindow);
    #endif
            aglSetCurrentContext(mAGLContext);

            // Give a copy of our context to the render system
            if(!mCarbonContext)
            {
                mCarbonContext = OGRE_NEW OSXCarbonContext(mAGLContext, mAGLPixelFormat);
                mContext = mCarbonContext;
            }
        }

        // Apply vsync settings. call setVSyncInterval first to avoid 
		// setting vsync more than once.
        setVSyncEnabled(vsync);
        setHidden(hidden);

        mName = name;
        mWidth = width;
        mHeight = height;
        mColourDepth = depth;
        mFSAA = fsaa_samples;
        mIsFullScreen = fullScreen;
        mActive = true;
        mClosed = false;
        mCreated = true;
//.........这里部分代码省略.........
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:101,代码来源:OgreOSXCarbonWindow.cpp

示例8: createKey

QPixmap QtopiaPicIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
                               QIcon::State state)
{
    QString key = createKey(d->filename, size, mode, state,
                            QApplication::palette().color(QPalette::Highlight));
    QPixmap pm;

    // See if we have it in our local cache first.
    if (QPixmapCache::find(key, pm))
        return pm;

    // Try explicitly added pixmaps
    if (d->pixmaps) {
        if (d->pixmaps->contains(key))
            return d->pixmaps->value(key);
    }

    // Perhaps it has already been stored in the global cache.
    bool globalCandidate = false;
    if (size.height() == QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize)
        || size.height() == QApplication::style()->pixelMetric(QStyle::PM_TabBarIconSize)
        || size.height() == QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize)
        || size.height() == QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize)) {
        if (QGlobalPixmapCache::find(key, pm)) {
            qLog(Resource) << "Icon found in global cache" << d->filename;
            // Put in local cache because we will probably use again soon.
            QPixmapCache::insert(key, pm);
            return pm;
        }
        globalCandidate = true;
        qLog(Resource) << "Icon not found in global cache" << d->filename;
    }

    if (!d->loaded) {
        if (!d->picture)
            d->picture = new QPicture;
        if (!d->picture->load(d->filename))
            qWarning() << "Cannot load icon" << d->filename;
        else
            qLog(Resource) << "loaded pic icon" << d->filename;
        d->loaded = true;
    }

    QImage img(size, QImage::Format_ARGB32_Premultiplied);
    img.fill(0x00000000);
    QPainter p(&img);
    QRectF br = d->picture->boundingRect();
    if (br.width() == 0 || br.height() == 0)
        return QPixmap();
    if (br.width() > 0 && br.height() > 0)
        p.scale(qreal(size.width())/br.width(), qreal(size.height())/br.height());
    p.drawPicture(0, 0, *d->picture);
    p.end();
    pm = QPixmap::fromImage(img);
    QStyleOption opt(0);
    opt.palette = QApplication::palette();
    QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt);
    if (!generated.isNull())
        pm = generated;

    // We'll only put the standard icon sizes in the global cache because
    // there's a high likelyhood that they'll be used by others.
    if (globalCandidate)
        QGlobalPixmapCache::insert(key, pm);

    // Still worthwhile putting in the local cache since it is very likely
    // to be rendered again
    QPixmapCache::insert(key, pm);

    return pm;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:71,代码来源:piciconengine.cpp

示例9: frameRect

void QFrame::drawFrame(QPainter *p)
{
    QPoint      p1, p2;
    QRect       r     = frameRect();
    int         type  = fstyle & MShape;
    int         cstyle = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen(black);   // ####
    p->drawRect(r);   //### a bit too simple
#else
    const QColorGroup & g = colorGroup();

#ifndef QT_NO_STYLE
    QStyleOption opt(lineWidth(), midLineWidth());

    QStyle::SFlags flags = QStyle::Style_Default;
    if (isEnabled())
        flags |= QStyle::Style_Enabled;
    if (cstyle == Sunken)
        flags |= QStyle::Style_Sunken;
    else if (cstyle == Raised)
        flags |= QStyle::Style_Raised;
    if (hasFocus())
        flags |= QStyle::Style_HasFocus;
    if (hasMouse())
        flags |= QStyle::Style_MouseOver;
#endif // QT_NO_STYLE

    switch (type) {

    case Box:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            qDrawShadeRect(p, r, g, cstyle == Sunken, lwidth,
                           midLineWidth());
        break;

    case LineEditPanel:
        style().drawPrimitive(QStyle::PE_PanelLineEdit, p, r, g, flags, opt);
        break;

    case GroupBoxPanel:
        style().drawPrimitive(QStyle::PE_PanelGroupBox, p, r, g, flags, opt);
        break;

    case TabWidgetPanel:
        style().drawPrimitive(QStyle::PE_PanelTabWidget, p, r, g, flags, opt);
        break;

    case MenuBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelMenuBar, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case ToolBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelDockWindow, p, rect(), g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case StyledPanel:
#ifndef QT_NO_STYLE
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            style().drawPrimitive(QStyle::PE_Panel, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case PopupPanel:
#ifndef QT_NO_STYLE
        {
            int vextra = style().pixelMetric(QStyle::PM_PopupMenuFrameVerticalExtra, this),
                         hextra = style().pixelMetric(QStyle::PM_PopupMenuFrameHorizontalExtra, this);
            if (vextra > 0 || hextra > 0) {
                QRect fr = frameRect();
                int   fw = frameWidth();
                if (vextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.bottom() - fw - vextra, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                }
                if (hextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.right() - fw - hextra, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                }
            }

            if (cstyle == Plain)
                qDrawPlainRect(p, r, g.foreground(), lwidth);
            else
//.........这里部分代码省略.........
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:101,代码来源:kexiframeutils_p.cpp

示例10: AddRsnEventComputations

Bool_t AddRsnEventComputations(Bool_t isMC, const char *options = "", const char *taskName = "RSNtask")
{
   // ==================================================================================================================
   // == PRELIMINARY OPERATIONS ========================================================================================
   // ==================================================================================================================
   
   // retrieve task from manager, using its name
   AliAnalysisManager *mgr  = AliAnalysisManager::GetAnalysisManager();
   AliRsnAnalysisTask *task = (AliRsnAnalysisTask*)mgr->GetTask(taskName);
   if (!task) {
      Error("RsnConfigMonitor", "Task not found");
      return kFALSE;
   }
   
   TString opt(options);
   opt.ToUpper();
   opt.ReplaceAll(" ", "");
   
   Bool_t central    = opt.Contains("CENT");
   Bool_t peripheral = opt.Contains("PERI");
   
   // ==================================================================================================================
   // == EVENT CUTS ====================================================================================================
   // ==================================================================================================================

   // event cuts are added directly to a cutSet in the task
   // we create all and then add thos which are needed
   
   // primary vertex:
   // - 2nd argument --> |Vz| range
   // - 3rd argument --> minimum required number of contributors
   // - 4th argument --> tells if TPC stand-alone vertexes must be accepted
   // we switch on the check for pileup
   AliRsnCutPrimaryVertex *cutVertex = new AliRsnCutPrimaryVertex("cutVertex", 10.0, 0, kFALSE);
   cutVertex->SetCheckPileUp(kTRUE);
      
   // centrality:
   // - 2nd      argument --> one of the centrality evaluation methods
   // - 3rd, 4th argument --> centrality ranges in percentile (0-10 for central, 60-70 for peripheral)
   AliRsnCutValue *cutCentrality = 0x0;
   if (central) 
      cutCentrality = new AliRsnCutValue("cutCentral", AliRsnValue::kEventCentralityV0,  0.0, 10.0);
   else if (peripheral)
      cutCentrality = new AliRsnCutValue("cutPeripheral", AliRsnValue::kEventCentralityV0, 60.0, 70.0);
   
   // primary vertex is always used
   task->GetEventCuts()->AddCut(cutVertex);
   
   // set cut scheme as AND of primary vertex and centrality, if initialized
   if (cutCentrality) {
      task->GetEventCuts()->AddCut(cutCentrality);
      task->GetEventCuts()->SetCutScheme(Form("%s & %s", cutVertex->GetName(), cutCentrality->GetName()));
   } else {
      task->GetEventCuts()->SetCutScheme(cutVertex->GetName());
   }
   ::Info("AddEventStuff", "Scheme for event cuts: %s", task->GetEventCuts()->GetCutScheme().Data());
   
   // ==================================================================================================================
   // == EVENT FUNCTIONS ===============================================================================================
   // ==================================================================================================================

   // we want to add an AliRsnFunction to compute multiplicity distribution
   // it is needed in order to know how many events we have in each multiplicity bin
   
   // axes
   AliRsnValue *axisEvMultSPD = new AliRsnValue("MultSPD", AliRsnValue::kEventMultSPD, 0.0, 150.0, 1.0);
   AliRsnValue *axisEvMultMC  = new AliRsnValue("MultMC" , AliRsnValue::kEventMultMC , 0.0, 150.0, 1.0);

   // create function and add axis
   AliRsnFunction *fcnEv = new AliRsnFunction;
   if (!fcnEv->AddAxis(axisEvMultSPD)) return kFALSE;
   if (isMC && !fcnEv->AddAxis(axisEvMultMC)) return kFALSE;

   // add functions to pairs
   task->GetInfo()->AddEventFunction(fcnEv);
   
   return kTRUE;
}
开发者ID:fbellini,项目名称:AliRsn,代码行数:78,代码来源:AddRsnEventComputations.C

示例11: main

int main(int argc, char* argv[]) {
  TlGetopt opt(argc, argv, "hv");

  if (opt["h"] == "defined") {
    showHelp(opt[0]);
    return EXIT_SUCCESS;
  }

  const bool bVerbose = (opt["v"] == "defined");

  if (opt.getCount() <= 1) {
    showHelp(opt[0]);
    return EXIT_FAILURE;
  }
  const std::string inputMatrixPath1 = opt[1];
  const std::string inputMatrixPath2 = opt[2];
  const std::string outputMatrixPath = opt[3];

  if (bVerbose == true) {
    std::cerr << "load matrix: " << inputMatrixPath1 << std::endl;
  }

  TlDenseGeneralMatrix_Lapack A;
  if (TlMatrixUtils::isLoadable(inputMatrixPath1, TlMatrixObject::CSFD)) {
    A.load(inputMatrixPath1);
  } else if (TlMatrixUtils::isLoadable(inputMatrixPath1,
                                       TlMatrixObject::RLHD)) {
    TlDenseSymmetricMatrix_Lapack tmp;
    tmp.load(inputMatrixPath1);
    A = tmp;
  } else {
    std::cerr << "can not open file: " << inputMatrixPath1 << std::endl;
    return EXIT_FAILURE;
  }

  if (bVerbose == true) {
    std::cerr << "load matrix: " << inputMatrixPath2 << std::endl;
  }
  TlDenseGeneralMatrix_Lapack B;
  if (TlMatrixUtils::isLoadable(inputMatrixPath2, TlMatrixObject::CSFD)) {
    B.load(inputMatrixPath2);
  } else if (TlMatrixUtils::isLoadable(inputMatrixPath2,
                                       TlMatrixObject::RLHD)) {
    TlDenseSymmetricMatrix_Lapack tmp;
    tmp.load(inputMatrixPath2);
    B = tmp;
  } else {
    std::cerr << "can not open file: " << inputMatrixPath2 << std::endl;
    return EXIT_FAILURE;
  }

  if (bVerbose == true) {
    std::cerr << "running..." << std::endl;
  }

  A.dotInPlace(B);

  if (bVerbose == true) {
    std::cerr << "save matrix: " << outputMatrixPath << std::endl;
  }
  if (outputMatrixPath != "") {
    A.save(outputMatrixPath);
  }

  return EXIT_SUCCESS;
}
开发者ID:ProteinDF,项目名称:ProteinDF,代码行数:66,代码来源:main_mat_dot.cpp

示例12: opt

void
ViewerNode::setZoomComboBoxText(const std::string& text)
{
    ChoiceOption opt(text, "", "");
    _imp->zoomChoiceKnob.lock()->setActiveEntry(opt, ViewSetSpec(0), eValueChangedReasonPluginEdited);
}
开发者ID:ebrayton,项目名称:Natron,代码行数:6,代码来源:ViewerNode.cpp

示例13: main


//.........这里部分代码省略.........
		//upper_bounds[4] = 30;//1.0;//*Pi/180;

		//// k1 sk
		//lower_bounds[5] = 1e-6;//0.0;//*Pi/180;
		//upper_bounds[5] = 15;//1.0;//*Pi/180;

		//// k2 sk
		//lower_bounds[6] = 0.1;
		//upper_bounds[6] = 100;

		// set parameter limits
		sys.setParameterLimits(lower_bounds,upper_bounds);

		// initialise vector of initial parameter guesses
		Vector guess(numParams);
	
		guess[0] = 6.82; //flexion theta star (degrees)
		guess[1] = 6.82; // extension theta star (degrees)
		guess[2] = 1.22; // k1 (N*m/degree)
		guess[3] = 7.29; // k2 (N*m/degree)
		guess[4] = 0.3; // bushing offset

		//guess[4] = 0.0; // head mass
		//		guess[4] = 45; // theta star sk (degrees)
		//guess[5] = guess[1]; // k1 sk (N*m/degree)
		//guess[6] = guess[2]; // k2 sk (N*m/degree)
		
		// Try optimisation
		clock_t t1,t2,t3,t4;
		t1 = clock();
		try{
		
			// intialise optimizer
			Optimizer opt(sys, SimTK::InteriorPoint);
			opt.setDiagnosticsLevel(5);
			
			// Optimisation settings					
			opt.setConvergenceTolerance(1e-3);
			opt.setMaxIterations(1000);
			opt.useNumericalGradient(true);
			opt.setLimitedMemoryHistory(500);
			
			// return optimum solution
			f = opt.optimize(guess);
			
			cout<<"\nf = "<<f;
			cout<<"\nguess = "<<guess;
		}
		catch(const std::exception& e) {
		std::cout << "OptimizationExample.cpp Caught exception :"  << std::endl;
		std::cout << e.what() << std::endl;
		}
		t2 = clock();
		//// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //	

		//cout<<"\n\nOptimiszation time: "<<((float)t2-(float)t1)/ CLOCKS_PER_SEC << " seconds";
		//
		//// Run simulation and save point kinematic reporter in data_sim storage object. Print simulation results to file.
		//Array<Array<double>> pk_data;

		Vector PARAMS(numParams);
		for (int i = 0; i<numParams; i++){
			PARAMS[i] = guess[i];
		}
		//string fd = "";
		simtools->RunSimulation_FlexExt(osimModel,PARAMS,tiFlex,tiExt,tfFlex,tfExt,ICs_Flex,ICs_Ext,false,fd,*force_storage_flex,*force_storage_ext,*m1h,*m2h,*m3h,*m4h,*m5h,*m6h,data_trc_flex,data_trc_ext);
开发者ID:tlin067,项目名称:Opensim_development,代码行数:67,代码来源:main.cpp

示例14: main

main(int argc, char *argv[]) {
    int i, j, nf;

    progname = argv[0];
    ac = argc + 50;
    av = alloc(ac*sizeof(char *));
    if (signal(SIGINT, SIG_IGN) != SIG_IGN)
        signal(SIGINT, interrupt);
    if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
        signal(SIGTERM, interrupt);
#ifdef SIGHUP
    if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
        signal(SIGHUP, interrupt);
#endif
    if (getenv("TMP"))
        tempdir = getenv("TMP");
    else if (getenv("TEMP"))
        tempdir = getenv("TEMP");
    else if (getenv("TMPDIR"))
        tempdir = getenv("TMPDIR");
    assert(tempdir);
    i = strlen(tempdir);
    for (; i > 0 && tempdir[i-1] == '/' || tempdir[i-1] == '\\'; i--)
        tempdir[i-1] = '\0';
    if (argc <= 1) {
        help();
        exit(0);
    }
    plist = append("-D__LCC__", 0);
    initinputs();
    if (getenv("LCCDIR"))
        option(stringf("-lccdir=%s", getenv("LCCDIR")));
    for (nf = 0, i = j = 1; i < argc; i++) {
        if (strcmp(argv[i], "-o") == 0) {
            if (++i < argc) {
                if (suffix(argv[i], suffixes, 2) >= 0) {
                    error("-o would overwrite %s", argv[i]);
                    exit(8);
                }
                outfile = argv[i];
                continue;
            } else {
                error("unrecognized option `%s'", argv[i-1]);
                exit(8);
            }
        } else if (strcmp(argv[i], "-target") == 0) {
            if (argv[i+1] && *argv[i+1] != '-')
                i++;
            continue;
        } else if (*argv[i] == '-' && argv[i][1] != 'l') {
            opt(argv[i]);
            continue;
        } else if (*argv[i] != '-' && suffix(argv[i], suffixes, 3) >= 0)
            nf++;
        argv[j++] = argv[i];
    }
    if ((cflag || Sflag) && outfile && nf != 1) {
        fprintf(stderr, "%s: -o %s ignored\n", progname, outfile);
        outfile = 0;
    }
    argv[j] = 0;
    for (i = 0; include[i]; i++)
        plist = append(include[i], plist);
    if (ilist) {
        List b = ilist;
        do {
            b = b->link;
            plist = append(b->str, plist);
        } while (b != ilist);
    }
    ilist = 0;
    for (i = 1; argv[i]; i++)
        if (strcmp(argv[i], "-l") == 0 && argv[i+1] && *argv[i+1] != '-') {	/* -l file */
            llist[1] = append(argv[i++], llist[1]);
            llist[1] = append(argv[i],   llist[1]);
        } else if (*argv[i] == '-')
            opt(argv[i]);
        else {
            char *name = exists(argv[i]);
            if (name) {
                if (strcmp(name, argv[i]) != 0
                        || nf > 1 && suffix(name, suffixes, 3) >= 0)
                    fprintf(stderr, "%s:\n", name);
                filename(name, 0);
            } else
                error("can't find `%s'", argv[i]);
        }
    if (errcnt == 0 && !Eflag && !Sflag && !cflag && llist[1]) {
        compose(ld, llist[0], llist[1],
                append(outfile ? outfile : concat("a", first(suffixes[4])), 0));
        if (callsys(av))
            errcnt++;
    }
    rm(rmlist);
    return errcnt ? EXIT_FAILURE : EXIT_SUCCESS;
}
开发者ID:romalik,项目名称:rl_cpu,代码行数:96,代码来源:lcc.c

示例15: main

int main(int argc, char* argv[]) {
  TlGetopt opt(argc, argv, "ahp:vw:");
  const bool isAtomIndexMode = (opt["a"] == "defined");
  const bool isVerbose = (opt["v"] == "defined");
  const bool isShowHelp = (opt["h"] == "defined");
  std::string pdfparamPath = "pdfparam.mpac";
  if (opt["p"].empty() != true) {
    pdfparamPath = opt["p"];
  }
  std::string saveMpacPath = "";
  if (opt["w"].empty() != true) {
    saveMpacPath = opt["w"];
  }

  if (isShowHelp) {
    showHelp();
    std::exit(0);
  }

  TlMsgPack mpac;
  if (isVerbose) {
    std::cerr << TlUtils::format("reading %s ...", pdfparamPath.c_str());
  }
  mpac.load(pdfparamPath);
  TlSerializeData data = mpac.getSerializeData();
  TlOrbitalInfo orbInfo(data["coordinates"], data["basis_set"]);

  const int numOfAOs = orbInfo.getNumOfOrbitals();
  if (isVerbose == true) {
    std::cerr << "total atoms: " << orbInfo.getNumOfAtoms() << std::endl;
    std::cerr << "total orbitals: " << numOfAOs << std::endl;
  }

  const int numOfArgs =
      opt.getCount() - 1;  // opt[0] means the name of this program.

  if (isAtomIndexMode == true) {
    if (numOfArgs == 0) {
      showHelp();
      std::exit(1);
    }

    for (int i = 0; i < numOfArgs; ++i) {
      const int atomIndex = std::atoi(opt[i + 1].c_str());

      std::cout << TlUtils::format(">>>> atom index: %d", atomIndex)
                << std::endl;
      for (int aoIndex = 0; aoIndex < numOfAOs; ++aoIndex) {
        if (atomIndex == orbInfo.getAtomIndex(aoIndex)) {
          printOrbInfo(orbInfo, aoIndex);
        }
      }
    }
  } else {
    std::vector<int> orbitals;
    if (numOfArgs == 0) {
      orbitals.resize(numOfAOs);
      for (int i = 0; i < numOfAOs; ++i) {
        orbitals[i] = i;
      }
    } else {
      for (int i = 0; i < numOfArgs; ++i) {
        const int orb = std::atoi(opt[i + 1].c_str());
        orbitals.push_back(orb);
      }
    }
    const int numOfQueries = orbitals.size();

    if (saveMpacPath.empty()) {
      for (int i = 0; i < numOfQueries; ++i) {
        const int orb = orbitals[i];
        if (orb < numOfAOs) {
          printOrbInfo(orbInfo, orb);
        }
      }
    } else {
      TlSerializeData output;
      for (int i = 0; i < numOfQueries; ++i) {
        const int orb = orbitals[i];
        if (orb < numOfAOs) {
          TlSerializeData entry;

          entry["atom_index"] = orbInfo.getAtomIndex(orb);
          entry["atomic_number"] =
              TlAtom::getElementNumber(orbInfo.getAtomName(orb));
          entry["symbol"] = orbInfo.getAtomName(orb);
          const TlPosition pos = orbInfo.getPosition(orb);
          TlSerializeData xyz;
          xyz.pushBack(pos.x() / AU_BOHR);
          xyz.pushBack(pos.y() / AU_BOHR);
          xyz.pushBack(pos.z() / AU_BOHR);
          entry["xyz"] = xyz;

          entry["shell_type_id"] = orbInfo.getShellType(orb);
          entry["shell_type"] =
              TlUtils::format("%c", shellTypes[orbInfo.getShellType(orb)]);
          entry["basis_type_id"] = orbInfo.getBasisType(orb);
          entry["basis_type"] =
              std::string(angularMomentumTypes[orbInfo.getBasisType(orb)]);

//.........这里部分代码省略.........
开发者ID:ProteinDF,项目名称:ProteinDF,代码行数:101,代码来源:main_info_orb.cpp


注:本文中的opt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。