void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) { if (p_types.has(p_type)) return; if (!ClassDB::is_parent_class(p_type, base_type) || p_type == base_type) return; String inherits = ClassDB::get_parent_class(p_type); TreeItem *parent = p_root; if (inherits.length()) { if (!p_types.has(inherits)) { add_type(inherits, p_types, p_root, to_select); } if (p_types.has(inherits)) parent = p_types[inherits]; } TreeItem *item = search_options->create_item(parent); item->set_text(0, p_type); if (!ClassDB::can_instance(p_type)) { item->set_custom_color(0, Color(0.5, 0.5, 0.5)); item->set_selectable(0, false); } else { if ((!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) || search_box->get_text() == p_type) { *to_select = item; } } if (bool(EditorSettings::get_singleton()->get("docks/scene_tree/start_create_dialog_fully_expanded"))) { item->set_collapsed(false); } else { // don't collapse search results bool collapse = (search_box->get_text() == ""); // don't collapse the root node collapse &= (item != p_root); // don't collapse abstract nodes on the first tree level collapse &= ((parent != p_root) || (ClassDB::can_instance(p_type))); item->set_collapsed(collapse); } const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description; item->set_tooltip(0, description); if (has_icon(p_type, "EditorIcons")) { item->set_icon(0, get_icon(p_type, "EditorIcons")); } p_types[p_type] = item; }
bool ConnectivityBase::isValid_(AtomContainer& ac) { static HashMap<Handle, PreciseTime> mod_times; PreciseTime last_mod = ac.getModificationTime(); Handle mol_handle = ac.getHandle(); if (mod_times.has(mol_handle)) { if (mod_times[mol_handle] == last_mod) { #ifdef BALL_QSAR_CONNECTIVITYBASE_DEBUG cerr << ">> ConnectivityBase::isValid: molcule valid!" << endl; #endif return true; } else { mod_times[mol_handle] = last_mod; #ifdef BALL_QSAR_CONNECTIVITYBASE_DEBUG cerr << ">> ConnectivityBase::isValid: atom container not valid, modified!" << endl; #endif return false; } } else { mod_times.insert(std::make_pair(mol_handle, last_mod)); #ifdef BALL_QSAR_CONNECTIVITYBASE_DEBUG cerr << ">> ConnectivityBase::isValid: atom container not valid, first call!" << endl; #endif return false; } }
void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root,TreeItem **to_select) { if (p_types.has(p_type)) return; if (!ObjectTypeDB::is_type(p_type,base_type) || p_type==base_type) return; String inherits=ObjectTypeDB::type_inherits_from(p_type); TreeItem *parent=p_root; if (inherits.length()) { if (!p_types.has(inherits)) { add_type(inherits,p_types,p_root,to_select); } if (p_types.has(inherits) ) parent=p_types[inherits]; } TreeItem *item = search_options->create_item(parent); item->set_text(0,p_type); if (!ObjectTypeDB::can_instance(p_type)) { item->set_custom_color(0, Color(0.5,0.5,0.5) ); item->set_selectable(0,false); } else { if (!*to_select && (search_box->get_text()=="" || p_type.findn(search_box->get_text())!=-1)) { *to_select=item; } } if (has_icon(p_type,"EditorIcons")) { item->set_icon(0, get_icon(p_type,"EditorIcons")); } p_types[p_type]=item; }
static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) { if (variant_map.has(p_variant)) return variant_map[p_variant]; int idx = variant_map.size(); variant_map[p_variant]=idx; return idx; }
void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { HashMap<String, PLData> usage; Node *es = EditorNode::get_singleton()->get_edited_scene(); if (!es) return; int nc = 0; List<PLData *> datas; for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { if (!es->has_node(E->get())) continue; Node *n = es->get_node(E->get()); if (!n) continue; List<PropertyInfo> plist; n->get_property_list(&plist, true); for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) { if (F->get().name == "script") continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) if (!usage.has(F->get().name)) { PLData pld; pld.uses = 0; pld.info = F->get(); usage[F->get().name] = pld; datas.push_back(usage.getptr(F->get().name)); } usage[F->get().name].uses++; } nc++; } for (List<PLData *>::Element *E = datas.front(); E; E = E->next()) { if (nc == E->get()->uses) { p_list->push_back(E->get()->info); } } p_list->push_back(PropertyInfo(Variant::OBJECT, "scripts", PROPERTY_HINT_RESOURCE_TYPE, "Script")); }
void EditorHelp::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) { if (p_types.has(p_type)) return; // if (!ObjectTypeDB::is_type(p_type,base) || p_type==base) // return; String inherits=doc->class_list[p_type].inherits; TreeItem *parent=p_root; if (inherits.length()) { if (!p_types.has(inherits)) { add_type(inherits,p_types,p_root); } if (p_types.has(inherits) ) parent=p_types[inherits]; } TreeItem *item = class_list->create_item(parent); item->set_metadata(0,p_type); item->set_tooltip(0,doc->class_list[p_type].brief_description); item->set_text(0,p_type); if (has_icon(p_type,"EditorIcons")) { item->set_icon(0, get_icon(p_type,"EditorIcons")); } p_types[p_type]=item; }
/* --------------------------------------------------------- INVOKE MESSAGE CHAIN --------------------------------------------------------- */ void _Complete_history(size_t uid) { std::unique_lock<std::mutex> uk(mtx_); //-------- // NEED TO REDEFINE START AND END TIME //-------- // NO SUCH HISTORY; THE PROCESS HAD DONE ONLY IN THIS MEDIATOR LEVEL. if (progress_list_.has(uid) == false) return; // COMPLETE THE HISTORY std::shared_ptr<slave::InvokeHistory> history = progress_list_.get(uid); history->complete(); // ERASE THE HISTORY ON PROGRESS LIST progress_list_.erase(uid); // REPORT THE HISTORY TO MASTER std::thread(&MediatorSystem::sendData, this, history->toInvoke()).detach(); };
JNIEXPORT void JNICALL Java_com_android_godot_Godot_registerMethod(JNIEnv * env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args){ String singname = env->GetStringUTFChars( sname, NULL ); ERR_FAIL_COND(!jni_singletons.has(singname)); JNISingleton *s = jni_singletons.get(singname); String mname = env->GetStringUTFChars( name, NULL ); String retval = env->GetStringUTFChars( ret, NULL ); Vector<Variant::Type> types; String cs="("; int stringCount = env->GetArrayLength(args); print_line("Singl: "+singname+" Method: "+mname+" RetVal: "+retval); for (int i=0; i<stringCount; i++) { jstring string = (jstring) env->GetObjectArrayElement(args, i); const char *rawString = env->GetStringUTFChars(string, 0); types.push_back(get_jni_type(String(rawString))); cs+=get_jni_sig(String(rawString)); } cs+=")"; cs+=get_jni_sig(retval); jclass cls = env->GetObjectClass(s->get_instance()); print_line("METHOD: "+mname+" sig: "+cs); jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data()); if (!mid) { print_line("FAILED GETTING METHOID "+mname); } s->add_method(mname,mid,types,get_jni_type(retval)); }
void CreateDialog::update_tree() { tree->clear(); List<String> type_list; ObjectTypeDB::get_type_list(&type_list); HashMap<String,TreeItem*> types; TreeItem *root = tree->create_item(); root->set_text(0,base); List<String>::Element *I=type_list.front(); for(;I;I=I->next()) { String type=I->get(); if (!ObjectTypeDB::can_instance(type)) continue; // cant create what can't be instanced if (filter->get_text()=="") add_type(type,types,root); else { bool found=false; String type=I->get(); while(type!="" && ObjectTypeDB::is_type(type,base) && type!=base) { if (type.findn(filter->get_text())!=-1) { found=true; break; } type=ObjectTypeDB::type_inherits_from(type); } if (found) add_type(I->get(),types,root); } if (EditorNode::get_editor_data().get_custom_types().has(type)) { //there are custom types based on this... cool. const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type]; for(int i=0;i<ct.size();i++) { bool show = filter->get_text()=="" || ct[i].name.findn(filter->get_text())!=-1; if (!show) continue; if (!types.has(type)) add_type(type,types,root); TreeItem *ti; if (types.has(type) ) ti=types[type]; else ti=tree->get_root(); TreeItem *item = tree->create_item(ti); item->set_metadata(0,type); item->set_text(0,ct[i].name); if (ct[i].icon.is_valid()) { item->set_icon(0,ct[i].icon); } } } } }
void CreateDialog::_update_search() { search_options->clear(); /* TreeItem *root = search_options->create_item(); _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); */ List<StringName> type_list; ObjectTypeDB::get_type_list(&type_list); HashMap<String,TreeItem*> types; TreeItem *root = search_options->create_item(); root->set_text(0,base_type); List<StringName>::Element *I=type_list.front(); TreeItem *to_select=NULL; for(;I;I=I->next()) { String type=I->get(); if (!ObjectTypeDB::can_instance(type)) continue; // cant create what can't be instanced if (search_box->get_text()=="") add_type(type,types,root,&to_select); else { bool found=false; String type=I->get(); while(type!="" && ObjectTypeDB::is_type(type,base_type) && type!=base_type) { if (type.findn(search_box->get_text())!=-1) { found=true; break; } type=ObjectTypeDB::type_inherits_from(type); } if (found) add_type(I->get(),types,root,&to_select); } if (EditorNode::get_editor_data().get_custom_types().has(type)) { //there are custom types based on this... cool. //print_line("there are custom types"); const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type]; for(int i=0;i<ct.size();i++) { bool show = search_box->get_text()=="" || ct[i].name.findn(search_box->get_text())!=-1; if (!show) continue; if (!types.has(type)) add_type(type,types,root,&to_select); TreeItem *ti; if (types.has(type) ) ti=types[type]; else ti=search_options->get_root(); TreeItem *item = search_options->create_item(ti); item->set_metadata(0,type); item->set_text(0,ct[i].name); if (ct[i].icon.is_valid()) { item->set_icon(0,ct[i].icon); } if (!to_select && (search_box->get_text()=="" || ct[i].name.findn(search_box->get_text())!=-1)) { to_select=item; } } } } if (to_select) to_select->select(0); get_ok()->set_disabled(root->get_children()==NULL); }
void CreateDialog::_update_search() { search_options->clear(); favorite->set_disabled(true); help_bit->set_text(""); /* TreeItem *root = search_options->create_item(); _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); */ HashMap<String, TreeItem *> types; TreeItem *root = search_options->create_item(); EditorData &ed = EditorNode::get_singleton()->get_editor_data(); root->set_text(0, base_type); if (has_icon(base_type, "EditorIcons")) { root->set_icon(0, get_icon(base_type, "EditorIcons")); } TreeItem *to_select = search_box->get_text() == base_type ? root : NULL; for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) { String type = I->get(); bool cpp_type = ClassDB::class_exists(type); if (base_type == "Node" && type.begins_with("Editor")) continue; // do not show editor nodes if (cpp_type && !ClassDB::can_instance(type)) continue; // can't create what can't be instanced bool skip = false; if (cpp_type) { for (Set<StringName>::Element *E = type_blacklist.front(); E && !skip; E = E->next()) { if (ClassDB::is_parent_class(type, E->get())) skip = true; } if (skip) continue; } if (search_box->get_text() == "") { add_type(type, types, root, &to_select); } else { bool found = false; String type = I->get(); while (type != "" && (cpp_type ? ClassDB::is_parent_class(type, base_type) : ed.script_class_is_parent(type, base_type)) && type != base_type) { if (search_box->get_text().is_subsequence_ofi(type)) { found = true; break; } type = ClassDB::get_parent_class(type); } if (found) add_type(I->get(), types, root, &to_select); } if (EditorNode::get_editor_data().get_custom_types().has(type) && ClassDB::is_parent_class(type, base_type)) { //there are custom types based on this... cool. const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type]; for (int i = 0; i < ct.size(); i++) { bool show = search_box->get_text().is_subsequence_ofi(ct[i].name); if (!show) continue; if (!types.has(type)) add_type(type, types, root, &to_select); TreeItem *ti; if (types.has(type)) ti = types[type]; else ti = search_options->get_root(); TreeItem *item = search_options->create_item(ti); item->set_metadata(0, type); item->set_text(0, ct[i].name); if (ct[i].icon.is_valid()) { item->set_icon(0, ct[i].icon); } if (!to_select || ct[i].name == search_box->get_text()) { to_select = item; } } } } if (search_box->get_text() == "") { to_select = root; } if (to_select) { to_select->select(0); search_options->scroll_to_item(to_select); favorite->set_disabled(false); favorite->set_pressed(favorite_list.find(to_select->get_text(0)) != -1); } get_ok()->set_disabled(root->get_children() == NULL); }
void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) { if (p_types.has(p_type)) return; bool cpp_type = ClassDB::class_exists(p_type); EditorData &ed = EditorNode::get_singleton()->get_editor_data(); if (p_type == base_type) return; if (cpp_type) { if (!ClassDB::is_parent_class(p_type, base_type)) return; } else { if (!ScriptServer::is_global_class(p_type) || !ed.script_class_is_parent(p_type, base_type)) return; String script_path = ScriptServer::get_global_class_path(p_type); if (script_path.find("res://addons/", 0) != -1) { if (!EditorNode::get_singleton()->is_addon_plugin_enabled(script_path.get_slicec('/', 3))) return; } } String inherits = cpp_type ? ClassDB::get_parent_class(p_type) : ed.script_class_get_base(p_type); TreeItem *parent = p_root; if (inherits.length()) { if (!p_types.has(inherits)) { add_type(inherits, p_types, p_root, to_select); } if (p_types.has(inherits)) parent = p_types[inherits]; else if (ScriptServer::is_global_class(inherits)) return; } bool can_instance = (cpp_type && ClassDB::can_instance(p_type)) || ScriptServer::is_global_class(p_type); TreeItem *item = search_options->create_item(parent); if (cpp_type) { item->set_text(0, p_type); } else { item->set_metadata(0, p_type); item->set_text(0, p_type + " (" + ScriptServer::get_global_class_path(p_type).get_file() + ")"); } if (!can_instance) { item->set_custom_color(0, get_color("disabled_font_color", "Editor")); item->set_selectable(0, false); } else { bool is_search_subsequence = search_box->get_text().is_subsequence_ofi(p_type); String to_select_type = *to_select ? (*to_select)->get_text(0) : ""; to_select_type = to_select_type.split(" ")[0]; bool current_item_is_preffered; if (cpp_type) { current_item_is_preffered = ClassDB::is_parent_class(p_type, preferred_search_result_type) && !ClassDB::is_parent_class(to_select_type, preferred_search_result_type); } else { current_item_is_preffered = ed.script_class_is_parent(p_type, preferred_search_result_type) && !ed.script_class_is_parent(to_select_type, preferred_search_result_type); } if (*to_select && p_type.length() < (*to_select)->get_text(0).length()) { current_item_is_preffered = true; } if (((!*to_select || current_item_is_preffered) && is_search_subsequence) || search_box->get_text() == p_type) { *to_select = item; } } if (bool(EditorSettings::get_singleton()->get("docks/scene_tree/start_create_dialog_fully_expanded"))) { item->set_collapsed(false); } else { // don't collapse search results bool collapse = (search_box->get_text() == ""); // don't collapse the root node collapse &= (item != p_root); // don't collapse abstract nodes on the first tree level collapse &= ((parent != p_root) || (can_instance)); item->set_collapsed(collapse); } const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description; item->set_tooltip(0, description); if (cpp_type && has_icon(p_type, "EditorIcons")) { item->set_icon(0, get_icon(p_type, "EditorIcons")); } else if (!cpp_type && has_icon(ScriptServer::get_global_class_base(p_type), "EditorIcons")) { item->set_icon(0, get_icon(ScriptServer::get_global_class_base(p_type), "EditorIcons")); } p_types[p_type] = item; }
a1.setRadius(1.0); a2.setRadius(1.0); a2.setPosition(Vector3(10.0, 0.0, 0.0)); f.insert(a1); f.insert(a2); HashMap<const Atom*, float> atom_areas; float area = calculateSESAtomAreas(f, atom_areas, 1.5); PRECISION(0.001) TEST_REAL_EQUAL(area, 25.13274) // verify the contents of the hash map TEST_EQUAL(atom_areas.size(), 2) TEST_EQUAL(atom_areas.has(&a1), true) TEST_EQUAL(atom_areas.has(&a2), true) // verify the atom surface fractions TEST_REAL_EQUAL(atom_areas[&a1], 12.56637) TEST_REAL_EQUAL(atom_areas[&a2], 12.56637) // second case: overlapping atoms -> adds toroidal surface patches a2.setPosition(Vector3(1.0, 0.0, 0.0)); area = calculateSESAtomAreas(f, atom_areas, 1.5); TEST_REAL_EQUAL(area, 18.722) // verify the contents of the hash map TEST_EQUAL(atom_areas.size(), 2)
bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd,HashMap<String,int>& refs,TreeItem* p_parent){ if (!efsd) return false; bool has_childs=false; for(int i=0;i<efsd->get_subdir_count();i++) { TreeItem *dir_item=NULL; if (p_parent) { dir_item = files->create_item(p_parent); dir_item->set_text(0,efsd->get_subdir(i)->get_name()); dir_item->set_icon(0,get_icon("folder","FileDialog")); } bool children = _fill_owners(efsd->get_subdir(i),refs,dir_item); if (p_parent) { if (!children) { memdelete(dir_item); } else { has_childs=true; } } } for(int i=0;i<efsd->get_file_count();i++) { if (!p_parent) { Vector<String> deps = efsd->get_file_deps(i); //print_line(":::"+efsd->get_file_path(i)); for(int j=0;j<deps.size();j++) { if (!refs.has(deps[j])) { refs[deps[j]]=1; } } } else { String path = efsd->get_file_path(i); if (!refs.has(path)) { TreeItem *ti=files->create_item(p_parent); ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); ti->set_text(0,efsd->get_file(i)); ti->set_editable(0,true); String type=efsd->get_file_type(i); Ref<Texture> icon; if (has_icon(type,TTR("EditorIcons"))) { icon=get_icon(type,"EditorIcons"); } else { icon=get_icon("Object","EditorIcons"); } ti->set_icon(0,icon); int ds = efsd->get_file_deps(i).size(); ti->set_text(1,itos(ds)); if (ds) { ti->add_button(1,get_icon("Visible","EditorIcons")); } ti->set_metadata(0,path); has_childs=true; } } } return has_childs; }