本文整理汇总了C++中model::Model类的典型用法代码示例。如果您正苦于以下问题:C++ Model类的具体用法?C++ Model怎么用?C++ Model使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MainTabController
LocationTabController::LocationTabController(const model::Model & model,
const QString& modelTempDir)
: MainTabController(new LocationTabView(model,modelTempDir))
{
LocationView * locationView = new LocationView(model, modelTempDir);
mainContentWidget()->addSubTab("Weather File && Design Days",locationView,WEATHER_FILE);
LifeCycleCostsView * lifeCycleCostsView = new LifeCycleCostsView(model);
mainContentWidget()->addSubTab("Life Cycle Costs",lifeCycleCostsView,LIFE_CYCLE_COSTS);
QLabel * label;
label = new QLabel();
label->setPixmap(QPixmap(":/images/utility_calibration_warning.png"));
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_utilityBillsController = std::shared_ptr<UtilityBillsController>(new UtilityBillsController(model));
m_utilityBillsStackedWidget = new QStackedWidget();
m_warningWidgetIndex = m_utilityBillsStackedWidget->addWidget(label);
m_visibleWidgetIndex = m_utilityBillsStackedWidget->addWidget(m_utilityBillsController->subTabView());
mainContentWidget()->addSubTab("Utility Bills",m_utilityBillsStackedWidget,UTILITY_BILLS);
// Determine if the utility bill sub-tab is shown
boost::optional<model::YearDescription> yearDescription = model.yearDescription();
if (yearDescription){
boost::optional<int> calendarYear = yearDescription.get().calendarYear();
if (calendarYear){
boost::optional<model::WeatherFile> weatherFile = model.weatherFile();
if (weatherFile){
boost::optional<model::RunPeriod> runPeriod = model.getOptionalUniqueModelObject<model::RunPeriod>();
if (runPeriod.is_initialized()){
m_utilityBillsStackedWidget->setCurrentIndex(m_visibleWidgetIndex);
}
else {
m_utilityBillsStackedWidget->setCurrentIndex(m_warningWidgetIndex);
}
}
}
}
// Hack code to remove when tab active
label = new QLabel();
label->setPixmap(QPixmap(":/images/coming_soon_utility_rates.png"));
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
mainContentWidget()->addSubTab("Utility Rates",label,UTILITY_RATES);
// Hack code to remove when tab active
//label = new QLabel();
//label->setPixmap(QPixmap(":/images/coming_soon_ground_temperature.png"));
//label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//mainContentWidget()->addSubTab("Ground Temperature",label,GROUND_TEMPERATURE);
// Hack code to remove when tab active
//label = new QLabel();
//label->setPixmap(QPixmap(":/images/coming_soon_water_mains_temperature.png"));
//label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
//mainContentWidget()->addSubTab("Water Mains Temperature",label,WATER_MAINS_TEMPERATURE);
}
示例2: activate
void EmberEntityModelAction::activate(EntityMapping::ChangeContext& context)
{
Model::Model* model = Model::ModelRepresentationManager::getSingleton().getModelForEntity(mEntity);
if (!model || model->getDefinition()->getName() != mModelName) {
mEntity.setGraphicalRepresentation(0);
model = Model::Model::createModel(mScene.getSceneManager(), mModelName, mEntity.getId());
model->setVisible(mEntity.isVisible());
//if the model definition isn't valid, use a placeholder
if (!model->getDefinition()->isValid()) {
S_LOG_FAILURE( "Could not find " << mModelName << ", using placeholder.");
//add a placeholder model
Model::ModelDefinitionPtr modelDef = model->getDefinition();
modelDef->createSubModelDefinition("3d_objects/primitives/models/box.mesh")->createPartDefinition("main")->setShow(true);
modelDef->setValid(true);
modelDef->reloadAllInstances();
}
Model::ModelRepresentation* representation = new Model::ModelRepresentation(mEntity, *model, mScene, mMapping);
mEntity.setGraphicalRepresentation(representation);
representation->initFromModel();
}
}
示例3:
TEST(FilePersistence, LoadMultipleUnits)
{
QString testDir = ":/FilePersistence/test/persisted";
Model::Model model;
FileStore store;
store.setBaseFolder(testDir);
model.load(&store, "units");
TestNodes::BinaryNode* root = dynamic_cast<TestNodes::BinaryNode*> (model.root());
CHECK_STR_EQUAL("BinaryNode", root->typeName() );
CHECK_STR_EQUAL("Root", root->name()->get() );
CHECK_CONDITION(root->left() != nullptr);
CHECK_CONDITION(root->right() != nullptr);
CHECK_STR_EQUAL("BinaryNodePersistenceUnit", root->left()->typeName() );
CHECK_STR_EQUAL("Left child", root->left()->name()->get() );
CHECK_CONDITION(root->left()->left() != nullptr);
CHECK_CONDITION(root->left()->right() == nullptr);
CHECK_STR_EQUAL("BinaryNode", root->left()->left()->typeName() );
CHECK_STR_EQUAL("in a new unit", root->left()->left()->name()->get() );
CHECK_CONDITION(root->left()->left()->left() == nullptr);
CHECK_CONDITION(root->left()->left()->right() == nullptr);
CHECK_STR_EQUAL("BinaryNode", root->right()->typeName() );
CHECK_STR_EQUAL("Right child", root->right()->name()->get() );
CHECK_CONDITION(root->right()->left() == nullptr);
CHECK_CONDITION(root->right()->right() == nullptr);
}
示例4: model_rank_text
Object model_rank_text(Object self, Object text) {
Model::Model *model = from_ruby<Model::Model *>(self);
string example_text = from_ruby<string>(text);
Array indexes;
vector<Classifier::Score> *ranks = model->rank_text(example_text);
for(unsigned int i = 0; i < ranks->size(); i++)
indexes.push(ranks->at(i).category);
delete ranks;
return indexes;
}
示例5:
TEST(OOModel, SimpleProjectTest)
{
Model::Model model;
Project* root = dynamic_cast<Project*> (model.createRoot("Project"));
CHECK_CONDITION(root != nullptr);
CHECK_CONDITION(root->name().isEmpty());
model.beginModification(root, "setName");
root->setName("prj");
model.endModification();
CHECK_STR_EQUAL("prj", root->name());
}
示例6: model_rank
Object model_rank(Object self, Object ex) {
Model::Model *model = from_ruby<Model::Model *>(self);
DataSet::Example *example = from_ruby<DataSet::Example *>(ex);
Array indexes;
vector<Classifier::Score> *ranks = model->rank(example);
for(unsigned int i = 0; i < ranks->size(); i++)
indexes.push(ranks->at(i).category);
delete ranks;
return indexes;
}
示例7: model_rank_text_names
Object model_rank_text_names(Object self, Object text) {
Model::Model *model = from_ruby<Model::Model *>(self);
string example_text = from_ruby<string>(text);
Array names;
vector<Classifier::Score> *ranks = model->rank_text(example_text);
DataSet::NominalFeature *categories = model->data_set->category_feature();
for(unsigned int i = 0; i < ranks->size(); i++)
names.push(categories->names[ranks->at(i).category]);
delete ranks;
return names;
}
示例8: getReferenceLabels
static util::StringVector getReferenceLabels(network::Bundle& bundle,
const model::Model& model)
{
if(bundle.contains("referenceLabels"))
{
util::StringVector labels;
auto& referenceLabels = bundle["referenceLabels"].get<matrix::LabelVector>();
for(auto& referenceLabel : referenceLabels)
{
labels.push_back(std::string());
for(auto& grapheme : referenceLabel)
{
labels.back() += model.getOutputLabel(grapheme);
}
}
return labels;
}
auto& referenceActivations =
bundle["referenceActivations"].get<matrix::MatrixVector>().front();
return convertActivationsToLabels(std::move(referenceActivations), model);
}
示例9: quarry_rank_text_names_from_binary_model
Object quarry_rank_text_names_from_binary_model(Object path, Object text) {
string model_path = from_ruby<string>(path);
string example_text = from_ruby<string>(text);
Array names;
Storage::Binary reader(model_path);
Model::Model *model = reader.read_model();
vector<Classifier::Score> *ranks = model->rank_text(example_text);
DataSet::NominalFeature *categories = model->data_set->category_feature();
for(unsigned int i = 0; i < ranks->size(); i++)
names.push(categories->names[ranks->at(i).category]);
delete ranks;
delete model;
return names;
}
示例10:
TEST(FilePersistence, LoadingList)
{
QString testDir = ":/FilePersistence/test/persisted";
Model::Model model;
FileStore store;
store.setBaseFolder(testDir);
model.load(&store, "partial");
TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.root());
CHECK_CONDITION(root != nullptr);
Model::List* list = root->list();
CHECK_CONDITION(list != nullptr);
CHECK_STR_EQUAL("List", list->typeName() );
CHECK_CONDITION(list->isFullyLoaded() == false);
CHECK_INT_EQUAL(1, list->id());
list->loadFully(store);
CHECK_CONDITION(list->isFullyLoaded());
CHECK_INT_EQUAL(4, list->size());
Model::Text* one = list->at<Model::Text>(0);
Model::Text* two = list->at<Model::Text>(1);
Model::Text* three = list->at<Model::Text>(2);
Model::Text* four = list->at<Model::Text>(3);
CHECK_CONDITION(one != nullptr);
CHECK_STR_EQUAL("one", one->get());
CHECK_INT_EQUAL(2, one->id());
CHECK_CONDITION(two != nullptr);
CHECK_STR_EQUAL("two", two->get());
CHECK_INT_EQUAL(3, two->id())
CHECK_CONDITION(three != nullptr);
CHECK_STR_EQUAL("three", three->get());
CHECK_INT_EQUAL(4, three->id())
CHECK_CONDITION(four != nullptr);
CHECK_STR_EQUAL("four", four->get());
CHECK_INT_EQUAL(5, four->id());
}
示例11: TestBoxNode
TEST(VisualizationBase, ExtendableTest)
{
Model::Model* model = new Model::Model();
Model::List* list = static_cast<Model::List*> (model->createRoot("List"));
model->beginModification(list, "set");
TestNodes::BinaryNode* first = new TestNodes::BinaryNode();
list->append(first);
TestNodes::BinaryNode* second = new TestNodes::BinaryNode();
list->append(second);
Model::Text* third = new Model::Text();
list->append(third);
first->name()->set("First node");
TestNodes::BinaryNode* left = new TestNodes::BinaryNode();
first->setLeft(left);
TestNodes::BinaryNode* right = new TestNodes::BinaryNode();
first->setRight(right);
left->name()->set("left node");
right->name()->set("right node");
second->name()->set("Empty node");
third->set("Some independent text");
list->append(new TestBoxNode("someText"));
list->append(new TestBoxNode("stretch", true));
model->endModification();
auto top = new RootItem(list);
auto scene = VisualizationManager::instance().mainScene();
scene->addTopLevelItem( top );
QApplication::processEvents();
VList* l = dynamic_cast<VList*> (top->item());
l->itemAt<VExtendable>(1)->setExpanded(false);
scene->scheduleUpdate();
scene->listenToModel(model);
CHECK_CONDITION(scene);
}
示例12: convertActivationsToGraphemeLabels
static util::StringVector convertActivationsToGraphemeLabels(matrix::Matrix&& activations,
const model::Model& model)
{
assert(activations.size().size() >= 3);
if(activations.size().size() > 3)
{
activations = reshape(activations,
{activations.size().front(),
activations.size()[1],
activations.size().product() / (activations.size().front() * activations.size()[1])});
}
size_t timesteps = activations.size()[2];
size_t miniBatchSize = activations.size()[1];
size_t graphemes = activations.size()[0];
util::StringVector labels;
for(size_t miniBatch = 0; miniBatch < miniBatchSize; ++miniBatch)
{
std::string currentLabel;
size_t currentGrapheme = graphemes;
for(size_t timestep = 0; timestep < timesteps; ++timestep)
{
size_t maxGrapheme = 0;
double maxValue = std::numeric_limits<double>::min();
for(size_t grapheme = 0; grapheme < graphemes; ++grapheme)
{
if(activations(grapheme, miniBatch, timestep) >= maxValue)
{
maxValue = activations(grapheme, miniBatch, timestep);
maxGrapheme = grapheme;
}
}
if(maxGrapheme != currentGrapheme)
{
currentGrapheme = maxGrapheme;
auto newGrapheme = model.getOutputLabel(maxGrapheme);
currentLabel.insert(currentLabel.end(), newGrapheme.begin(), newGrapheme.end());
}
}
labels.push_back(currentLabel);
}
return labels;
}
示例13: Scene
TEST(InteractionBase, TextSelect)
{
Scene* scene = new Scene();
Model::Model* model = new Model::Model();
Model::List* list = static_cast<Model::List*> (model->createRoot("List"));
model->beginModification(list, "set");
TestNodes::BinaryNode* first = new TestNodes::BinaryNode();
list->append(first);
TestNodes::BinaryNode* second = new TestNodes::BinaryNode();
list->append(second);
Model::Text* third = new Model::Text();
list->append(third);
first->name()->set("First node");
TestNodes::BinaryNode* left = new TestNodes::BinaryNode();
first->setLeft(left);
TestNodes::BinaryNode* right = new TestNodes::BinaryNode();
first->setRight(right);
left->name()->set("left node");
right->name()->set("right node");
second->name()->set("Empty node");
third->set("Some independent text");
model->endModification();
VList* l = dynamic_cast<VList*> (scene->renderer()->render(nullptr, list));
scene->addTopLevelItem(l);
scene->scheduleUpdate();
QApplication::processEvents();
l->at<VExtendable>(0)->setExpanded();
scene->scheduleUpdate();
scene->listenToModel(model);
// Create view
MainView* view = new MainView(scene);
CHECK_CONDITION(view != nullptr);
}
示例14:
TEST(FilePersistence, SaveList)
{
QString testDir = QDir::tempPath() + "/Envision/FilePersistence/tests";
Model::Model model;
FileStore store;
store.setBaseFolder(testDir);
TestNodes::PartialList* root = dynamic_cast<TestNodes::PartialList*> (model.createRoot("PartialList"));
model.beginModification(root, "create ");
Model::Text* one = new Model::Text();
one->set("one");
root->list()->append(one);
Model::Text* two = new Model::Text();
two->set("two");
root->list()->append(two);
Model::Text* three = new Model::Text();
three->set("three");
root->list()->append(three);
Model::Text* four = new Model::Text();
four->set("four");
root->list()->append(four);
model.endModification();
model.setName("partial");
model.save(&store);
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/partial/partial", testDir + "/partial/partial");
}
示例15:
TEST(FilePersistence, SaveMultipleUnits)
{
QString testDir = QDir::tempPath() + QDir::toNativeSeparators("/Envision/FilePersistence/tests");
Model::Model model;
FileStore store;
store.setBaseFolder(testDir);
TestNodes::BinaryNode* root = dynamic_cast<TestNodes::BinaryNode*> (model.createRoot("BinaryNode"));
model.beginModification(root, "set title");
root->name()->set("Root");
TestNodes::BinaryNode* left = root->setLeft<TestNodes::BinaryNodePersistenceUnit>();
TestNodes::BinaryNode* right = root->setRight<TestNodes::BinaryNode>();
left->name()->set("Left child");
TestNodes::BinaryNode* leftleft = left->setLeft<TestNodes::BinaryNode>();
leftleft->name()->set("in a new unit");
right->name()->set("Right child");
model.endModification();
model.setName("units");
model.save(&store);
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/units/units", testDir + "/units/units");
CHECK_TEXT_FILES_EQUAL(":/FilePersistence/test/persisted/units/2", testDir + "/units/2");
}