Example #1
0
/**
 * Inserts @p type into the type-combobox.
 * The combobox is cleared and all types together with the optional new one
 * sorted and then added again.
 * @param type   a new type to add and selected
 */
void UMLTemplateDialog::insertTypesSorted(const QString& type)
{
    QStringList types;
    // "class" is the nominal type of template parameter
    types << "class";
    // add the active data types to combo box
    UMLDoc *pDoc = UMLApp::app()->document();
    UMLClassifierList namesList( pDoc->concepts() );
    foreach (UMLClassifier* obj, namesList) {
        types << obj->name();
    }
    // add the given parameter
    if ( !types.contains(type) ) {
        types << type;
    }
    types.sort();

    m_pTypeCB->clear();
    m_pTypeCB->insertItems(-1, types);

    // select the given parameter
    int currentIndex = m_pTypeCB->findText(type);
    if (currentIndex > -1) {
        m_pTypeCB->setCurrentIndex(currentIndex);
    }
}
Example #2
0
void exectsenums (){
   ROOT::EnableThreadSafety();
   vector<thread> threads;
   std::vector<const char*> enumNames {"enum1",
                   "enum2",
                   "enum3",
                   "enum4",
                   "enum5",
                   "enumns::enum1",
                   "enumns::enum2",
                   "enumns::enum3",
                   "enumns::enum4",
                   "enumns::enum5"};
   tsStringlist names;
   for (auto&& enName : enumNames){
      auto f = [&](){
         auto en = TEnum::GetEnum(enName);
         names.addString(TEnum::GetEnum(enName)->GetQualifiedName());
      };
      threads.emplace_back(f);
//      f(); //just run serial
   }

   for (auto&& t : threads)
      t.join();

   std::list<std::string> namesList (names.getStrings());
   namesList.sort();
   for (auto&& name:namesList) printf("Enum called %s was found\n",name.c_str());

}
void UMLOperationDialog::slotParameterProperties() {
    int result = 0;
    UMLAttribute* pAtt = 0, * pOldAtt = 0;
    pOldAtt = m_pOperation->findParm( m_pParmsLB->currentText() );

    if( !pOldAtt ) {
        kDebug() << "THE impossible has occurred for:" << m_pParmsLB->currentText() << endl;
        return;
    }//should never occur
    ParmPropDlg dlg(this, m_doc, pOldAtt);
    result = dlg.exec();
    QString name = dlg.getName();
    pAtt = m_pOperation->findParm( name );
    if( result ) {
        if( name.length() == 0 ) {
            KMessageBox::error(this, i18n("You have entered an invalid parameter name."),
                               i18n("Parameter Name Invalid"), false);
            return;
        }
        if ( !pAtt || pOldAtt->getTypeName() != dlg.getTypeName() ||
                pOldAtt->getDoc() != dlg.getDoc() ||
                pOldAtt->getInitialValue() != dlg.getInitialValue() ) {
            pOldAtt->setName( name );
            QString typeName = dlg.getTypeName();
            if (pOldAtt->getTypeName() != typeName) {
                UMLClassifierList namesList( m_doc->getConcepts() );
                UMLClassifier* obj = NULL;
                for (obj=namesList.first(); obj!=0; obj=namesList.next()) {
                    if (typeName == obj->getFullyQualifiedName()) {
                        pOldAtt->setType( obj );
                        break;
                    }
                }
                if (obj == NULL) {
                    // Nothing found: set type name directly. Bad.
                    kDebug() << "UMLOperationDialog::slotParameterProperties: "
                    << typeName << " not found." << endl;
                    pOldAtt->setTypeName( typeName );  // Bad.
                }
            }
            m_pParmsLB->changeItem( dlg.getName(), m_pParmsLB -> currentItem() );
            pOldAtt->setDoc( dlg.getDoc() );
            pOldAtt->setInitialValue( dlg.getInitialValue() );
            m_doc->setModified( true );
        } else if( pAtt != pOldAtt ) {
            KMessageBox::error(this, i18n("The parameter name you have chosen is already being used in this operation."),
                               i18n("Parameter Name Not Unique"), false);
        }
    }
}
Example #4
0
QString NuclideList::matchNucs( qreal energy, qreal toler, GammaList *gammaList, int &howMany )
{
    QList<int> ids = gammaList->matchIdnucls( energy, toler );
    howMany = ids.count();
    QString ret;
    // Doblst num = dataMatchEnergies( energy );

    ret = namesList( ids ).join(", ");
    /*
    for (int i=0; i < ids.count(); i++ )
        ret += QString("%1").arg( ids[i] ) + ", ";
    if ( ret.length() >= 2 ) ret.chop(2); // remove the extra ", "
    */
    return ret;
}
Example #5
0
/**
 * Checks if changes are valid and applies them if they are,
 * else returns false
 */
bool UMLTemplateDialog::apply()
{
    QString typeName = m_pTypeCB->currentText();
    UMLDoc *pDoc = UMLApp::app()->document();
    UMLClassifierList namesList( pDoc->concepts() );
    foreach (UMLClassifier* obj, namesList) {
        if (typeName == obj->name()) {
            m_pTemplate->setType(obj);
        }
    }
    if (namesList.isEmpty()) { // not found.
        // FIXME: This implementation is not good yet.
        m_pTemplate->setTypeName( typeName );
    }
    QString name = m_pNameLE->text();
    if( name.length() == 0 ) {
        KMessageBox::error(this, i18n("You have entered an invalid template name."),
                           i18n("Template Name Invalid"), false);
        m_pNameLE->setText( m_pTemplate->name() );
        return false;
    }

    UMLClassifier * pClass = dynamic_cast<UMLClassifier *>( m_pTemplate->parent() );
    if (pClass) {
        UMLObject *o = pClass->findChildObject(name);
        if (o && o != m_pTemplate) {
            KMessageBox::error(this, i18n("The template parameter name you have chosen is already being used in this operation."),
                               i18n("Template Name Not Unique"), false);
            m_pNameLE->setText( m_pTemplate->name() );
            return false;
        }
    }
    m_pTemplate->setName(name);

    m_pTemplate->setStereotype( m_pStereoTypeLE->text() );

    return true;
}
void UMLOperationDialog::setupDialog() {

    int margin = fontMetrics().height();
    QVBoxLayout * topLayout = new QVBoxLayout( plainPage() );

    m_pGenGB = new QGroupBox(i18n("General Properties"), plainPage() );
    QGridLayout * genLayout = new QGridLayout(m_pGenGB, 3, 4 );
    genLayout -> setColStretch(1, 1);
    genLayout -> setColStretch(3, 1);
    genLayout -> addColSpacing(1, 200);
    genLayout -> addColSpacing(3, 200);
    genLayout -> setMargin(margin);
    genLayout -> setSpacing(10);

    Dialog_Utils::makeLabeledEditField( m_pGenGB, genLayout, 0,
                                    m_pNameL, i18n("&Name:"),
                                    m_pNameLE, m_pOperation->getName() );

    m_pRtypeL = new QLabel(i18n("&Type:"), m_pGenGB );
    genLayout -> addWidget(m_pRtypeL, 0, 2);

    m_pRtypeCB = new KComboBox(true, m_pGenGB );
    genLayout -> addWidget(m_pRtypeCB, 0, 3);
    m_pRtypeL->setBuddy(m_pRtypeCB);

    m_pStereoTypeL = new QLabel( i18n("Stereotype name:"), m_pGenGB );
    genLayout -> addWidget(m_pStereoTypeL, 1, 0);
    m_pStereoTypeCB = new KComboBox(true, m_pGenGB );
    genLayout -> addWidget(m_pStereoTypeCB, 1, 1);

    m_pAbstractCB = new QCheckBox( i18n("&Abstract operation"), m_pGenGB );
    m_pAbstractCB -> setChecked( m_pOperation->getAbstract() );
    genLayout -> addWidget( m_pAbstractCB, 2, 0 );
    m_pStaticCB = new QCheckBox( i18n("Classifier &scope (\"static\")"), m_pGenGB );
    m_pStaticCB -> setChecked( m_pOperation->getStatic() );
    genLayout -> addWidget( m_pStaticCB, 2, 1 );
    m_pQueryCB = new QCheckBox( i18n("&Query (\"const\")"), m_pGenGB );
    m_pQueryCB -> setChecked( m_pOperation->getConst() );
    genLayout -> addWidget( m_pQueryCB, 2, 2 );

    topLayout -> addWidget( m_pGenGB );

    m_pScopeBG = new QButtonGroup(i18n("Visibility"), plainPage() );

    QHBoxLayout * scopeLayout = new QHBoxLayout(m_pScopeBG);
    scopeLayout -> setMargin(margin);

    m_pPublicRB = new QRadioButton(i18n("P&ublic"), m_pScopeBG);
    scopeLayout -> addWidget(m_pPublicRB);

    m_pPrivateRB = new QRadioButton(i18n("P&rivate"), m_pScopeBG);
    scopeLayout -> addWidget(m_pPrivateRB);

    m_pProtectedRB = new QRadioButton(i18n("Prot&ected"), m_pScopeBG);
    scopeLayout -> addWidget(m_pProtectedRB);

    m_pImplementationRB = new QRadioButton(i18n("I&mplementation"), m_pScopeBG);
    scopeLayout -> addWidget(m_pImplementationRB);

    topLayout -> addWidget(m_pScopeBG);

    m_pParmsGB = new QGroupBox(i18n("Parameters"), plainPage() );
    QVBoxLayout* parmsLayout = new QVBoxLayout(m_pParmsGB);
    parmsLayout->setMargin(margin);
    parmsLayout->setSpacing(10);

    //horizontal box contains the list box and the move up/down buttons
    QHBoxLayout* parmsHBoxLayout = new QHBoxLayout(parmsLayout);
    m_pParmsLB = new QListBox(m_pParmsGB);
    parmsHBoxLayout->addWidget(m_pParmsLB);

    //the move up/down buttons (another vertical box)
    QVBoxLayout* buttonLayout = new QVBoxLayout( parmsHBoxLayout );
    m_pUpButton = new KArrowButton( m_pParmsGB );
    m_pUpButton->setEnabled( false );
    buttonLayout->addWidget( m_pUpButton );

    m_pDownButton = new KArrowButton( m_pParmsGB, Qt::DownArrow );
    m_pDownButton->setEnabled( false );
    buttonLayout->addWidget( m_pDownButton );

    KButtonBox* buttonBox = new KButtonBox(m_pParmsGB);
    buttonBox->addButton( i18n("Ne&w Parameter..."), this, SLOT(slotNewParameter()) );
    m_pDeleteButton = buttonBox->addButton( i18n("&Delete"), this, SLOT(slotDeleteParameter()) );
    m_pPropertiesButton = buttonBox->addButton( i18n("&Properties"), this,
                          SLOT(slotParameterProperties()) );
    parmsLayout->addWidget(buttonBox);

    topLayout -> addWidget(m_pParmsGB);

    m_pDeleteButton->setEnabled(false);
    m_pPropertiesButton->setEnabled(false);
    m_pUpButton->setEnabled(false);
    m_pDownButton->setEnabled(false);

    // Add "void". We use this for denoting "no return type" independent
    // of the programming language.
    // For example, the Ada generator would interpret the return type
    // "void" as an instruction to generate a procedure instead of a
    // function.
    insertType( "void" );

    m_pRtypeCB->setDuplicatesEnabled(false);//only allow one of each type in box
    m_pRtypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );

    // add template parameters
    UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(m_pOperation->parent());
    if (classifier) {
        UMLClassifierListItemList tmplParams( classifier->getFilteredList(Uml::ot_Template) );
        for (UMLClassifierListItem *li = tmplParams.first(); li; li = tmplParams.next())
            insertType( li->getName() );
    }
    //now add the Classes and Interfaces (both are Concepts)
    UMLClassifierList namesList( m_doc->getConcepts() );
    UMLClassifier* pConcept = 0;
    for(pConcept=namesList.first(); pConcept!=0 ;pConcept=namesList.next()) {
        insertType( pConcept->getFullyQualifiedName() );
    }

    //work out which one to select
    int returnBoxCount = 0;
    bool foundReturnType = false;
    while (returnBoxCount < m_pRtypeCB->count() && foundReturnType == false) {
        QString returnBoxString = m_pRtypeCB->text(returnBoxCount);
        if ( returnBoxString == m_pOperation->getTypeName() ) {
            foundReturnType = true;
            m_pRtypeCB->setCurrentItem(returnBoxCount);
            break;
        }
        returnBoxCount++;
    }

    if (!foundReturnType) {
        insertType( m_pOperation->getTypeName(), 0 );
        m_pRtypeCB->setCurrentItem(0);
    }

    //fill in parm list box
    UMLAttributeList list = m_pOperation->getParmList();
    UMLAttribute * pAtt = 0;
    for (pAtt = list.first(); pAtt; pAtt = list.next())
        m_pParmsLB->insertItem( pAtt->getName() );

    //set scope
    Uml::Visibility scope = m_pOperation -> getVisibility();
    if( scope == Uml::Visibility::Public )
      m_pPublicRB -> setChecked( true );
    else if( scope == Uml::Visibility::Private )
      m_pPrivateRB -> setChecked( true );
    else if( scope == Uml::Visibility::Protected )
      m_pProtectedRB -> setChecked( true );
    else if( scope == Uml::Visibility::Implementation )
      m_pImplementationRB -> setChecked( true );

    // manage stereotypes
    m_pStereoTypeCB -> setDuplicatesEnabled(false);//only allow one of each type in box
    m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
    insertStereotype (QString("")); // an empty stereotype is the default
    int defaultStereotype=0;
    bool foundDefaultStereotype = false;
    for (UMLStereotypeListIt it(m_doc->getStereotypes()); it.current(); ++it) {
        if (!foundDefaultStereotype) {
            if ( m_pOperation->getStereotype() == it.current()->getName()) {
                foundDefaultStereotype = true;
            }
            defaultStereotype++;
        }
        insertStereotype (it.current()->getName());
    }
    // lookup for a default stereotype, if the operation doesn't have one
    if (foundDefaultStereotype)
        m_pStereoTypeCB->setCurrentItem(defaultStereotype);
    else
        m_pStereoTypeCB->setCurrentItem(-1);

    //setup parm list box signals
    connect( m_pUpButton, SIGNAL( clicked() ), this, SLOT( slotParameterUp() ) );
    connect( m_pDownButton, SIGNAL( clicked() ), this, SLOT( slotParameterDown() ) );

    connect(m_pParmsLB, SIGNAL(clicked(QListBoxItem*)),
            this, SLOT(slotParamsBoxClicked(QListBoxItem*)));

    connect(m_pParmsLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)),
            this, SLOT(slotParmRightButtonPressed(QListBoxItem *, const QPoint &)));

    connect(m_pParmsLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
            this, SLOT(slotParmRightButtonClicked(QListBoxItem *, const QPoint &)));


    connect(m_pParmsLB, SIGNAL(doubleClicked(QListBoxItem *)),
            this, SLOT(slotParmDoubleClick(QListBoxItem *)));

    m_pNameLE->setFocus();
    connect( m_pNameLE, SIGNAL( textChanged ( const QString & ) ), SLOT( slotNameChanged( const QString & ) ) );
    slotNameChanged(m_pNameLE->text() );

}
Example #7
0
        void TRACK_votImpl::loadDataset(const string &rootPath)
        {
            string nameListPath = rootPath + "/list.txt";
            ifstream namesList(nameListPath.c_str());
            vector <int> datasetsLengths;
            string datasetName;

            if (namesList.is_open())
            {
                int currDatasetID = 0;

                //All datasets/folders loop
                while (getline(namesList, datasetName))
                {
                    currDatasetID++;
                    vector <Ptr<TRACK_votObj> > objects;

                    //All frames/images loop
                    Ptr<TRACK_votObj> currDataset(new TRACK_votObj);

                    //Open dataset's ground truth file
                    string gtListPath = rootPath + "/" + datasetName + "/groundtruth.txt";
                    ifstream gtList(gtListPath.c_str());
                    if (!gtList.is_open())
                        printf("Error to open groundtruth.txt!!!");

                    //Make a list of datasets lengths
                    int currFrameID = 0;
                    if (currDatasetID == 0)
                        printf("VOT Dataset Initialization...\n");
                    bool trFLG = true;
                    do
                    {
                        currFrameID++;
                        string fullPath = rootPath + "/" + datasetName + "/" + numberToString(currFrameID) + ".jpg";
                        if (!fileExists(fullPath))
                            break;

                        //Make VOT Object
                        Ptr<TRACK_votObj> currObj(new TRACK_votObj);
                        currObj->imagePath = fullPath;
                        currObj->id = currFrameID;

                        //Get Ground Truth data
                        double	x1 = 0, y1 = 0,
                            x2 = 0, y2 = 0,
                            x3 = 0, y3 = 0,
                            x4 = 0, y4 = 0;
                        string tmp;
                        getline(gtList, tmp);
                        sscanf(tmp.c_str(), "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
                        currObj->gtbb.push_back(Point2d(x1, y1));
                        currObj->gtbb.push_back(Point2d(x2, y2));
                        currObj->gtbb.push_back(Point2d(x3, y3));
                        currObj->gtbb.push_back(Point2d(x4, y4));

                        //Add object to storage
                        objects.push_back(currObj);

                    } while (trFLG);

                    datasetsLengths.push_back(currFrameID - 1);
                    data.push_back(objects);
                }
            }
            else
            {
                printf("Couldn't find a *list.txt* in VOT Dataset folder!!!");
            }

            namesList.close();
            return;
        }