TEST(Mesh,CompareRealSpace) { alps::gf::real_space_index_mesh::container_type points1(boost::extents[20][3]); alps::gf::real_space_index_mesh::container_type points2(boost::extents[20][3]); alps::gf::real_space_index_mesh::container_type points3(boost::extents[20][3]); alps::gf::real_space_index_mesh::container_type points4(boost::extents[3][20]); for (int i=0; i<points1.num_elements(); ++i) { *(points1.origin()+i)=i; *(points2.origin()+i)=i; *(points3.origin()+i)=i+1; *(points4.origin()+i)=i; } alps::gf::real_space_index_mesh mesh1(points1); alps::gf::real_space_index_mesh mesh2(points2); alps::gf::real_space_index_mesh mesh3(points3); alps::gf::real_space_index_mesh mesh4(points4); EXPECT_TRUE(mesh1==mesh2); EXPECT_TRUE(mesh1!=mesh3); EXPECT_TRUE(mesh1!=mesh4); EXPECT_FALSE(mesh1==mesh3); EXPECT_FALSE(mesh1!=mesh2); EXPECT_FALSE(mesh1==mesh4); }
void ApplicationModel::updateBounds(void) { for(int i=0; i<this->get_n_children(); i++) { Glib::RefPtr<Goocanvas::Item> item = parentWindow->m_Canvas->get_item(this->get_child(i)); if(item) { Goocanvas::Bounds bd = item->get_bounds(); bounds.set_x1( (bounds.get_x1() < bd.get_x1()) ? bounds.get_x1(): bd.get_x1() ); bounds.set_x2( (bounds.get_x2() > bd.get_x2()) ? bounds.get_x2(): bd.get_x2() ); bounds.set_y1( (bounds.get_y1() < bd.get_y1()) ? bounds.get_y1(): bd.get_y1() ); bounds.set_y2( (bounds.get_y2() > bd.get_y2()) ? bounds.get_y2(): bd.get_y2() ); } } width = MAX(MIN_WIDTH + text_w, bounds.get_x2()-bounds.get_x1() + 2*ITEMS_MARGIE); height = MAX(MIN_HEIGHT, bounds.get_y2()-bounds.get_y1() + 2*ITEMS_MARGIE + text_h); Goocanvas::Points points(6); points.set_coordinate(0, 0, 0); points.set_coordinate(1, text_w+TEXT_MARGINE*2, 0); points.set_coordinate(2, text_w+TEXT_MARGINE*2, text_h+TEXT_MARGINE); points.set_coordinate(3, width, text_h+TEXT_MARGINE); points.set_coordinate(4, width, height); points.set_coordinate(5, 0, height); poly->property_points().set_value(points); Goocanvas::Points points3(3); points3.set_coordinate(0, width, text_h+TEXT_MARGINE); points3.set_coordinate(1, width, height); points3.set_coordinate(2, 0, height); shadow->property_points().set_value(points3); }
ApplicationModel::ApplicationModel(ApplicationWindow* parentWnd, Application* app) : GroupModel() { parentWindow = parentWnd; application = app; app->setModel(this); // adding application name text = Goocanvas::TextModel::create(app->getName()); #ifdef GLIBMM_PROPERTIES_ENABLED text->property_font() = FONT_DESC; text->property_alignment().set_value(Pango::ALIGN_CENTER); #endif PangoLayout *layout = gtk_widget_create_pango_layout((GtkWidget*)parentWindow->gobj(), app->getName()); PangoFontDescription *fontdesc = pango_font_description_from_string(FONT_DESC); pango_layout_set_font_description (layout, fontdesc); pango_layout_get_pixel_size (layout, &text_w, &text_h); text->property_x().set_value(TEXT_MARGINE); text->property_y().set_value(text_h/2.0); poly = Goocanvas::PolylineModel::create(0,0,0,0); poly->property_close_path().set_value(true); poly->property_line_width().set_value(1.2); //poly->property_fill_color().set_value(APPLICATION_COLOR); poly->property_fill_color_rgba().set_value(APPLICATION_COLOR); poly->property_stroke_color().set_value("DodgerBlue3"); //GooCanvasLineDash *dash = goo_canvas_line_dash_new (2, 3.0, 3.0); //g_object_set(poly->gobj(), "line-dash", dash, NULL); shadow = Goocanvas::PolylineModel::create(0,0,0,0); shadow->property_close_path().set_value(false); shadow->property_line_width().set_value(3.0); shadow->property_stroke_color().set_value("gray"); getApplicationBounds(bounds); width = MAX(MIN_WIDTH + text_w, bounds.get_x2()-bounds.get_x1() + 2*ITEMS_MARGIE); height = MAX(MIN_HEIGHT, bounds.get_y2()-bounds.get_y1() + 2*ITEMS_MARGIE + text_h); Goocanvas::Points points(6); points.set_coordinate(0, 0, 0); points.set_coordinate(1, text_w+TEXT_MARGINE*2, 0); points.set_coordinate(2, text_w+TEXT_MARGINE*2, text_h+TEXT_MARGINE); points.set_coordinate(3, width, text_h+TEXT_MARGINE); points.set_coordinate(4, width, height); points.set_coordinate(5, 0, height); poly->property_points().set_value(points); Goocanvas::Points points3(3); points3.set_coordinate(0, width, text_h+TEXT_MARGINE); points3.set_coordinate(1, width, height); points3.set_coordinate(2, 0, height); shadow->property_points().set_value(points3); shadow->translate(1,1); this->add_child(shadow); this->add_child(poly); this->add_child(text); ModulePContainer modules = parentWindow->manager.getKnowledgeBase()->getModules(application); CnnContainer connections = parentWindow->manager.getKnowledgeBase()->getConnections(application); ApplicaitonPContainer applications = parentWindow->manager.getKnowledgeBase()->getApplications(application); int index = 0; ModulePIterator itr; for(itr=modules.begin(); itr!=modules.end(); itr++) { Module* module = (*itr); Glib::RefPtr<ModuleModel> mod = ModuleModel::create(parentWindow, module, true); this->add_child(mod); double x, y; x = (module->getModelBase().points.size()>0) ? module->getModelBase().points[0].x : index%900+10; y = (module->getModelBase().points.size()>0) ? module->getModelBase().points[0].y : ((index+=300)/900)*100+10; x -= bounds.get_x1(); x += ITEMS_MARGIE; y -= bounds.get_y1(); y += ITEMS_MARGIE + text_h + TEXT_MARGINE; mod->translate(x, y); double end_x, end_y; Goocanvas::Points points = poly->property_points().get_value(); points.get_coordinate(4, end_x, end_y); if((x + mod->getWidth() + ITEMS_MARGIE) >= end_x) width = x + mod->getWidth() + ITEMS_MARGIE; if((y + mod->getHeight() + ITEMS_MARGIE) >= end_y) height = y + mod->getHeight() + ITEMS_MARGIE; //points.set_coordinate(0, 0, 0); //points.set_coordinate(1, text_w+TEXT_MARGINE*2, 0); //points.set_coordinate(2, text_w+TEXT_MARGINE*2, text_h+TEXT_MARGINE); points.set_coordinate(3, width, text_h+TEXT_MARGINE); points.set_coordinate(4, width, height); points.set_coordinate(5, 0, height); poly->property_points().set_value(points); Goocanvas::Points points3(3); points3.set_coordinate(0, width, text_h+TEXT_MARGINE); points3.set_coordinate(1, width, height); points3.set_coordinate(2, 0, height); shadow->property_points().set_value(points3); } }
void ApplicationModel::updateChildItems(void) { ModulePContainer modules = parentWindow->manager.getKnowledgeBase()->getModules(application); CnnContainer connections = parentWindow->manager.getKnowledgeBase()->getConnections(application); ApplicaitonPContainer applications = parentWindow->manager.getKnowledgeBase()->getApplications(application); int index = 0; //index = (index/900)*100+50; CnnIterator citr; for(citr=connections.begin(); citr<connections.end(); citr++) { Connection baseCon = *citr; GraphicModel model = baseCon.getModelBase(); InputData* input = NULL; OutputData* output = NULL; Glib::RefPtr<PortModel> source(NULL); Glib::RefPtr<PortModel> dest(NULL); findInputOutputData((*citr), modules, input, output); if(output) source = findModelFromOutput(output); else { Glib::RefPtr<ExternalPortModel> extPort; bool bExist = false; for(int i=0; i<get_n_children(); i++) { extPort = Glib::RefPtr<ExternalPortModel>::cast_dynamic(get_child(i)); if(extPort && compareString(extPort->getPort(), baseCon.from())) { source = extPort; bExist = true; break; } } if(!bExist) { source = ExternalPortModel::create(parentWindow, OUTPUTD, (*citr).from(), true); add_child(source); double x ,y; if(model.points.size() > 1) { x = model.points[1].x - Glib::RefPtr<ExternalPortModel>::cast_dynamic(source)->getWidth() - bounds.get_x1()+ITEMS_MARGIE; y = model.points[1].y - Glib::RefPtr<ExternalPortModel>::cast_dynamic(source)->getHeight()/2.0 - bounds.get_y1()+ITEMS_MARGIE+text_h+TEXT_MARGINE; source->set_property("x", x); source->set_property("y", y); } else { x = 10; y = index; source->set_property("x", 10); source->set_property("y", index); } double end_x, end_y; double start_x; Goocanvas::Points points = poly->property_points().get_value(); points.get_coordinate(4, end_x, end_y); points.get_coordinate(5, start_x, end_y); double port_w = Glib::RefPtr<ExternalPortModel>::cast_dynamic(source)->getWidth(); double port_h = Glib::RefPtr<ExternalPortModel>::cast_dynamic(source)->getHeight(); if((x + port_w + ITEMS_MARGIE) >= end_x) width = x + port_w + ITEMS_MARGIE; if((y + port_h + ITEMS_MARGIE) >= end_y) height = y + port_h + ITEMS_MARGIE; double minx = start_x; if(x < start_x) { minx = x - ITEMS_MARGIE; text->translate(-abs(start_x-x)-ITEMS_MARGIE, 0); } points.set_coordinate(0, minx, 0); points.set_coordinate(1, text_w+TEXT_MARGINE*2+minx, 0); points.set_coordinate(2, text_w+TEXT_MARGINE*2+minx, text_h+TEXT_MARGINE); points.set_coordinate(3, width, text_h+TEXT_MARGINE); points.set_coordinate(4, width, height); points.set_coordinate(5, minx, height); poly->property_points().set_value(points); Goocanvas::Points points3(3); points3.set_coordinate(0, width, text_h+TEXT_MARGINE); points3.set_coordinate(1, width, height); points3.set_coordinate(2, minx, height); shadow->property_points().set_value(points3); } index+=40; } if(input) dest = findModelFromInput(input); else { Glib::RefPtr<ExternalPortModel> extPort; bool bExist = false; for(int i=0; i<get_n_children(); i++) { extPort = Glib::RefPtr<ExternalPortModel>::cast_dynamic(get_child(i)); if(extPort && compareString(extPort->getPort(), baseCon.to())) { dest = extPort; bExist = true; break; } } if(!bExist) { double x,y; dest = ExternalPortModel::create(parentWindow, INPUTD, (*citr).to(), true); add_child(dest); size_t size = model.points.size(); if(size > 2) { x = model.points[size-1].x-bounds.get_x1()+ITEMS_MARGIE; y = model.points[size-1].y - Glib::RefPtr<ExternalPortModel>::cast_dynamic(dest)->getHeight()/2.0 - bounds.get_y1()+ITEMS_MARGIE+text_h+TEXT_MARGINE; dest->set_property("x", x); dest->set_property("y", y); } else { x = 400; y = index; dest->set_property("x", x); dest->set_property("y", y); } double end_x, end_y; Goocanvas::Points points = poly->property_points().get_value(); points.get_coordinate(4, end_x, end_y); double port_w = Glib::RefPtr<ExternalPortModel>::cast_dynamic(dest)->getWidth(); double port_h = Glib::RefPtr<ExternalPortModel>::cast_dynamic(dest)->getHeight(); if((x + port_w + ITEMS_MARGIE) >= end_x) width = x + port_w + ITEMS_MARGIE; if((y + port_h + ITEMS_MARGIE) >= end_y) height = y + port_h + ITEMS_MARGIE; points.set_coordinate(3, width, text_h+TEXT_MARGINE); points.set_coordinate(4, width, height); points.get_coordinate(5, end_x, end_y); points.set_coordinate(5, end_x, height); poly->property_points().set_value(points); Goocanvas::Points points3(3); points3.set_coordinate(0, width, text_h+TEXT_MARGINE); points3.set_coordinate(1, width, height); points3.set_coordinate(2, end_x, height); shadow->property_points().set_value(points3); } } if(source && dest) { Glib::RefPtr<ArrowModel> arrow = ArrowModel::create(parentWindow, source, dest, &baseCon, this); add_child(arrow); int size = model.points.size(); for(int i=2; i<size-1; i++) arrow->addMidPoint(model.points[i].x-bounds.get_x1()+ITEMS_MARGIE, model.points[i].y-bounds.get_y1()+ITEMS_MARGIE+text_h+TEXT_MARGINE, i-2); arrow->setSelected(false); if(size) arrow->setLabelPosition(model.points[0].x-bounds.get_x1()+ITEMS_MARGIE, model.points[0].y-bounds.get_y1()+ITEMS_MARGIE+text_h+TEXT_MARGINE); } } }