//font void SettingDlg::OnFontChange(wxCommandEvent &event) { wxString str = m_font_cmb->GetValue(); if (str != "") { m_font_file = str + ".ttf"; std::string exePath = wxStandardPaths::Get().GetExecutablePath().ToStdString(); exePath = exePath.substr(0,exePath.find_last_of(std::string()+GETSLASH())); std::string loc = exePath + GETSLASH() + wxString("Fonts") + GETSLASH() + str.ToStdString() + ".ttf"; VRenderFrame* vr_frame = (VRenderFrame*)m_frame; if (vr_frame) { vr_frame->GetTextRenderer()->LoadNewFace(loc); vr_frame->GetTextRenderer()->SetSize(m_text_size); for (int i=0 ; i<(int)vr_frame->GetViewList()->size() ; i++) { VRenderView* vrv = (*vr_frame->GetViewList())[i]; if (vrv) vrv->RefreshGL(); } } } }
void OIBReader::SetBatch(bool batch) { if (batch) { //read the directory info wstring search_path = m_path_name.substr(0, m_path_name.find_last_of(GETSLASH())) + GETSLASH(); FIND_FILES(search_path,L".oib",m_batch_list,m_cur_batch); m_batch = true; } else m_batch = false; }
void DatabaseDlg::SaveDefault() { if (!m_dbtree) return; wxString expath = wxStandardPaths::Get().GetExecutablePath(); expath = expath.BeforeLast(GETSLASH(),NULL); #ifdef _WIN32 wxString dft = expath + "\\catalog_list.set"; wxString dft2 = wxStandardPaths::Get().GetUserConfigDir() + "\\catalog_list.set"; if (!wxFileExists(dft) && wxFileExists(dft2)) dft = dft2; #else wxString dft = expath + "/../Resources/" + "catalog_list.set"; #endif wxFileOutputStream os(dft); if (os.IsOk()) { wxTextOutputStream tout(os); std::vector<DBCatalog> *cat = m_dbtree->GetCatalogDataIndex(); if (cat && !cat->empty()) { for (int i = 0; i < cat->size(); i++) tout << (*cat)[i].path << "\n"; } } }
void OIFReader::ReadSequenceOif() { for (int i=0; i<(int)m_oif_info.size(); i++) { wstring path_name = m_oif_info[i].filename; m_oif_info[i].subdirname = path_name + L".files" + GETSLASH(); if (path_name == m_path_name) m_cur_time = i; m_subdir_name = path_name + L".files" + GETSLASH(); std::vector<std::wstring> list; FIND_FILES(m_subdir_name,L".tif",list,m_oif_t); //read file sequence for(size_t f = 0; f < list.size(); f++) ReadTifSequence(list.at(f), i); } }
void OIFReader::ReadSingleOif() { m_subdir_name = m_path_name + L".files" + GETSLASH(); std::vector<std::wstring> list; int tmp; FIND_FILES(m_subdir_name,L".tif",list,tmp); //read file sequence for(size_t f = 0; f < list.size(); f++) ReadTifSequence(list.at(f)); }
void OIFReader::SetFile(std::string &file) { if (!file.empty()) { if (!m_path_name.empty()) m_path_name.clear(); m_path_name.assign(file.length(), L' '); copy(file.begin(), file.end(), m_path_name.begin()); m_data_name = m_path_name.substr(m_path_name.find_last_of(GETSLASH())+1); } m_id_string = m_path_name; }
void LSMReader::Preprocess() { FILE* pfile = 0; if (!WFOPEN(&pfile, m_path_name.c_str(), L"rb")) return; m_lsm_info.clear(); m_l4gb = false; int i, j; unsigned int ioffset = 0; fread(&ioffset, sizeof(unsigned int), 1, pfile); if (ioffset!=0x002A4949) { fclose(pfile); return; } int cnt_image = 0; bool full_image = false; //first offset if (fread(&ioffset, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } unsigned int prev_offset = 0; unsigned int offset_high = 0; //images while (fseek(pfile, ioffset, SEEK_SET)==0) { unsigned short entry_num; //entry number if (fread(&entry_num, sizeof(unsigned short), 1, pfile)<1) { fclose(pfile); return; } vector<unsigned int> offsets; vector<unsigned int> offset_highs; vector<unsigned int> sizes; for (i=0; i<entry_num; i++) { unsigned short tag; if (fread(&tag, sizeof(unsigned short), 1, pfile)<1) { fclose(pfile); return; } unsigned short type; if (fread(&type, sizeof(unsigned short), 1, pfile)<1) { fclose(pfile); return; } unsigned int length; if (fread(&length, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } unsigned int value; if (fread(&value, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } //remember current position long cur_pos = ftell(pfile); switch (tag) { case 0x00FE://254, new subfile type if (value==0) { full_image = true; cnt_image++; } else full_image = false; break; case 0x0100://256, image width if (full_image && cnt_image == 1) m_x_size = value; break; case 0x0101://257, image length if (full_image && cnt_image == 1) m_y_size = value; break; case 0x0102://258, bits per sample break; case 0x0103://259, compression if (full_image && cnt_image == 1) m_compression = value<<16>>16; break; case 0x0106://262, photometric interpretation break; case 0x0111://273, strip offsets if (full_image) { if (length==1) { offsets.push_back(value); if (value < prev_offset) { m_l4gb = true; offset_high++; } prev_offset = value; offset_highs.push_back(offset_high); } else { if (fseek(pfile, value, SEEK_SET)==0) { unsigned int vtemp; for (j=0; j<(int)length; j++) { if (fread(&vtemp, sizeof(unsigned int), 1, pfile)==1) { offsets.push_back(vtemp); if (vtemp < prev_offset) { m_l4gb = true; offset_high++; } prev_offset = vtemp; offset_highs.push_back(offset_high); } } } } } break; case 0x0115://277, samples per pixel if (full_image && cnt_image == 1) m_chan_num = value<<16>>16; break; case 0x0117://279, strip byte counts if (full_image) { if (length==1) { sizes.push_back(value); } else { if (fseek(pfile, value, SEEK_SET)==0) { unsigned int vtemp; for (j=0; j<(int)length; j++) { if (fread(&vtemp, sizeof(unsigned int), 1, pfile)==1) sizes.push_back(vtemp); } } } } break; case 0x011C://284, planar configuration break; case 0x013D://317, predictor if (full_image && cnt_image == 1) m_predictor = value<<16>>16; break; break; case 0x0140://320, colormap break; case 0x866C://34412, zeiss lsm info if (type == 1) { if (fseek(pfile, value, SEEK_SET)!=0) { fclose(pfile); return; } unsigned char* pdata = new unsigned char[length]; if (fread(pdata, sizeof(unsigned char), length, pfile)!=length) { fclose(pfile); return; } //read lsm info ReadLsmInfo(pfile, pdata, length); //delete delete []pdata; } break; } //reset position if (fseek(pfile, cur_pos, SEEK_SET)!=0) { fclose(pfile); return; } } //build lsm info, which contains all offset values and sizes if (full_image) { int time = (cnt_image-1) / m_slice_num; if (time+1 > (int)m_lsm_info.size()) { DatasetInfo dinfo; for (i=0; i<m_chan_num; i++) { ChannelInfo cinfo; dinfo.push_back(cinfo); } m_lsm_info.push_back(dinfo); } //int slice = (cnt_image-1) % m_slice_num; for (i=0; i<m_chan_num; i++) { SliceInfo sinfo; sinfo.offset = offsets[i]; sinfo.offset_high = offset_highs[i]; sinfo.size = sizes[i]; //add slice info to lsm info m_lsm_info[time][i].push_back(sinfo); } } //next image if (fread(&ioffset, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } if (!ioffset) break; } fclose(pfile); m_cur_time = 0; m_data_name = m_path_name.substr(m_path_name.find_last_of(GETSLASH())+1); }
void SettingDlg::SaveSettings() { wxFileConfig fconfig("FluoRender Settings"); fconfig.Write("ver_major", VERSION_MAJOR_TAG); fconfig.Write("ver_minor", VERSION_MINOR_TAG); fconfig.SetPath("/gm calculation"); fconfig.Write("mode", m_gmc_mode); fconfig.SetPath("/peeling layers"); fconfig.Write("value", m_peeling_layers); fconfig.SetPath("/micro blend"); fconfig.Write("mode", m_micro_blend); fconfig.SetPath("/save project"); fconfig.Write("mode", m_prj_save); fconfig.SetPath("/realtime compress"); fconfig.Write("mode", m_realtime_compress); fconfig.SetPath("/skip bricks"); fconfig.Write("mode", m_skip_bricks); fconfig.SetPath("/mouse int"); fconfig.Write("mode", m_mouse_int); fconfig.SetPath("/dir shadow"); fconfig.Write("mode", m_shadow_dir); fconfig.Write("x", m_shadow_dir_x); fconfig.Write("y", m_shadow_dir_y); fconfig.SetPath("/test mode"); fconfig.Write("speed", m_test_speed); fconfig.Write("param", m_test_param); fconfig.Write("wiref", m_test_wiref); fconfig.SetPath("/wavelength to color"); fconfig.Write("c1", m_wav_color1); fconfig.Write("c2", m_wav_color2); fconfig.Write("c3", m_wav_color3); fconfig.Write("c4", m_wav_color4); fconfig.SetPath("/time id"); fconfig.Write("value", m_time_id); fconfig.SetPath("/grad bg"); fconfig.Write("value", m_grad_bg); fconfig.SetPath("/override vox"); fconfig.Write("value", m_override_vox); fconfig.SetPath("/soft threshold"); fconfig.Write("value", m_soft_threshold); fconfig.SetPath("/save cmp"); fconfig.Write("value", VRenderFrame::GetCompression()); fconfig.SetPath("/run script"); fconfig.Write("value", m_run_script); fconfig.SetPath("/paint history"); fconfig.Write("value", m_paint_hist_depth); fconfig.SetPath("/text font"); fconfig.Write("file", m_font_file); fconfig.Write("value", m_text_size); //memory settings fconfig.SetPath("/memory settings"); fconfig.Write("mem swap", m_mem_swap); fconfig.Write("graphics mem", m_graphics_mem); fconfig.Write("large data size", m_large_data_size); fconfig.Write("force brick size", m_force_brick_size); fconfig.Write("up time", m_up_time); EnableStreaming(m_mem_swap); //update order fconfig.SetPath("/update order"); fconfig.Write("value", m_update_order); //point volume mode fconfig.SetPath("/point volume mode"); fconfig.Write("value", m_point_volume_mode); //ruler use transfer function fconfig.SetPath("/ruler use transf"); fconfig.Write("value", m_ruler_use_transf); //ruler time dependent fconfig.SetPath("/ruler time dependent"); fconfig.Write("value", m_ruler_time_dep); //flags for flipping pvxml fconfig.SetPath("/pvxml flip"); fconfig.Write("x", m_pvxml_flip_x); fconfig.Write("y", m_pvxml_flip_y); //pixel format fconfig.SetPath("/pixel format"); fconfig.Write("red_bit", m_red_bit); fconfig.Write("green_bit", m_green_bit); fconfig.Write("blue_bit", m_blue_bit); fconfig.Write("alpha_bit", m_alpha_bit); fconfig.Write("depth_bit", m_depth_bit); fconfig.Write("samples", m_samples); //context attrib fconfig.SetPath("/context attrib"); fconfig.Write("gl_major_ver", m_gl_major_ver); fconfig.Write("gl_minor_ver", m_gl_minor_ver); fconfig.Write("gl_profile_mask", m_gl_profile_mask); //cl device fconfig.SetPath("/cl device"); fconfig.Write("device_id", m_cl_device_id); wxString expath = wxStandardPaths::Get().GetExecutablePath(); expath = expath.BeforeLast(GETSLASH(),NULL); #ifdef _WIN32 wxString dft = expath + "\\" + SETTING_FILE_NAME; #else wxString dft = expath + "/../Resources/" + SETTING_FILE_NAME; #endif wxFileOutputStream os(dft); fconfig.Save(os); }
wxWindow* SettingDlg::CreateProjectPage(wxWindow *parent) { //validator: integer wxIntegerValidator<unsigned int> vald_int; wxStaticText* st; wxPanel *page = new wxPanel(parent); //project save wxBoxSizer *group1 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "Open/Save"), wxVERTICAL); m_prj_save_chk = new wxCheckBox(page, ID_PrjSaveChk, "Save project when capture viewport or export movie."); m_realtime_cmp_chk = new wxCheckBox(page, ID_RealtimeCmpChk, "Compress data in graphics memory when loading."); group1->Add(10, 5); group1->Add(m_prj_save_chk); group1->Add(10, 5); group1->Add(m_realtime_cmp_chk); group1->Add(10, 5); //font wxBoxSizer *group2 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "Render View Font and Size"), wxVERTICAL); wxBoxSizer *sizer2_1 = new wxBoxSizer(wxHORIZONTAL); st = new wxStaticText(page, 0, "Font:"); m_font_cmb = new wxComboBox(page, ID_FontCmb, "", wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY); //populate fonts std::string exePath = wxStandardPaths::Get().GetExecutablePath().ToStdString(); exePath = exePath.substr(0,exePath.find_last_of(std::string()+GETSLASH())); wxString loc = wxString(exePath) + GETSLASH() + wxString("Fonts") + GETSLASH() + wxString("*.ttf"); wxLogNull logNo; wxString file = wxFindFirstFile(loc); while (!file.empty()) { file = file.AfterLast(GETSLASH()); file = file.BeforeLast('.'); m_font_cmb->Append(file); file = wxFindNextFile(); } sizer2_1->Add(st); sizer2_1->Add(20, 10); sizer2_1->Add(m_font_cmb); sizer2_1->Add(20, 10); st = new wxStaticText(page, 0, "Size:"); m_font_size_cmb = new wxComboBox(page, ID_FontSizeCmb, "", wxDefaultPosition, wxSize(50, -1), 0, NULL, wxCB_READONLY); for (int font_size=10; font_size<31; font_size+=2) m_font_size_cmb->Append(wxString::Format("%d", font_size)); sizer2_1->Add(st); sizer2_1->Add(20, 10); sizer2_1->Add(m_font_size_cmb); group2->Add(10, 5); group2->Add(sizer2_1, 0, wxEXPAND); group2->Add(10, 5); st = new wxStaticText(page, 0, "Put TrueType font files into the \"Fonts\" folder.\n"\ "Restart FluoRender to load new font files."); group2->Add(st); group2->Add(10, 5); //script wxBoxSizer *group3 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "4D Script"), wxVERTICAL); m_run_script_chk = new wxCheckBox(page, ID_RunScriptChk, "Enable execution of a script on 4D data during playback."); st = new wxStaticText(page, 0, "Compose and save the text file \"script_4d.txt\" in the same folder as the\n"\ "4D data. See details in the user manual for the syntax of the script."); group3->Add(10, 5); group3->Add(m_run_script_chk); group3->Add(10, 5); group3->Add(st); group3->Add(10, 5); //paint history depth wxBoxSizer *group4 = new wxStaticBoxSizer( new wxStaticBox(page, wxID_ANY, "Paint History"), wxVERTICAL); wxBoxSizer *sizer4_1 = new wxBoxSizer(wxHORIZONTAL); m_paint_hist_depth_sldr = new wxSlider(page, ID_PaintHistDepthSldr, 0, 0, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL); m_paint_hist_depth_text = new wxTextCtrl(page, ID_PaintHistDepthText, "0", wxDefaultPosition, wxSize(40, 20), 0, vald_int); st = new wxStaticText(page, 0, "The number of undo steps for paint brush selection.\n" \ "Set the value to 0 to disable history.\n" \ "A value greater than 0 slows down speed and increases memory usage."); sizer4_1->Add(m_paint_hist_depth_sldr, 1, wxEXPAND); sizer4_1->Add(m_paint_hist_depth_text, 0, wxALIGN_CENTER); group4->Add(10, 5); group4->Add(sizer4_1, 0, wxEXPAND); group4->Add(10, 5); group4->Add(st); group4->Add(10, 5); wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL); sizerV->Add(10, 10); sizerV->Add(group1, 0, wxEXPAND); sizerV->Add(10, 10); sizerV->Add(group2, 0, wxEXPAND); sizerV->Add(10, 10); sizerV->Add(group3, 0, wxEXPAND); sizerV->Add(10, 10); sizerV->Add(group4, 0, wxEXPAND); page->SetSizer(sizerV); return page; }
//load default void BrushToolDlg::LoadDefault() { wxString expath = wxStandardPaths::Get().GetExecutablePath(); expath = expath.BeforeLast(GETSLASH(),NULL); #ifdef _WIN32 wxString dft = expath + "\\default_brush_settings.dft"; #else wxString dft = expath + "/../Resources/default_brush_settings.dft"; #endif wxFileInputStream is(dft); if (!is.IsOk()) return; wxFileConfig fconfig(is); wxString str; double val; int ival; bool bval; //brush properties fconfig.Read("brush_ini_thresh", &m_dft_ini_thresh); fconfig.Read("brush_gm_falloff", &m_dft_gm_falloff); fconfig.Read("brush_scl_falloff", &m_dft_scl_falloff); if (fconfig.Read("brush_scl_translate", &m_dft_scl_translate)) { str = wxString::Format("%.1f", m_dft_scl_translate*m_max_value); m_brush_scl_translate_sldr->SetRange(0, int(m_max_value*10.0)); m_brush_scl_translate_text->SetValue(str); } //auto thresh if (fconfig.Read("auto_thresh", &bval)) m_estimate_thresh_chk->SetValue(bval); //edge detect if (fconfig.Read("edge_detect", &bval)) m_edge_detect_chk->SetValue(bval); //hidden removal if (fconfig.Read("hidden_removal", &bval)) m_hidden_removal_chk->SetValue(bval); //select group if (fconfig.Read("select_group", &bval)) m_select_group_chk->SetValue(bval); //2d influence if (fconfig.Read("brush_2dinfl", &val)) { str = wxString::Format("%.2f", val); m_brush_2dinfl_text->SetValue(str); } //size 1 if (fconfig.Read("brush_size1", &val) && val>0.0) { str = wxString::Format("%d", (int)val); m_brush_size1_text->SetValue(str); } //size 2 link if (fconfig.Read("use_brush_size2", &bval)) { m_brush_size2_chk->SetValue(bval); if (bval) { m_brush_size2_sldr->Enable(); m_brush_size2_text->Enable(); } else { m_brush_size2_sldr->Disable(); m_brush_size2_text->Disable(); } } //size 2 if (fconfig.Read("brush_size2", &val) && val>0.0) { str = wxString::Format("%d", (int)val); m_brush_size2_text->SetValue(str); } //iterations if (fconfig.Read("brush_iters", &ival)) { switch (ival) { case 1: m_brush_iterw_rb->SetValue(true); m_brush_iters_rb->SetValue(false); m_brush_iterss_rb->SetValue(false); break; case 2: m_brush_iterw_rb->SetValue(false); m_brush_iters_rb->SetValue(true); m_brush_iterss_rb->SetValue(false); break; case 3: m_brush_iterw_rb->SetValue(false); m_brush_iters_rb->SetValue(false); m_brush_iterss_rb->SetValue(true); break; } } //component analyzer //selected only if (fconfig.Read("ca_select_only", &bval)) m_ca_select_only_chk->SetValue(bval); //min voxel if (fconfig.Read("ca_min", &ival)) { m_dft_ca_min = ival; str = wxString::Format("%d", ival); m_ca_min_text->SetValue(str); } //max voxel if (fconfig.Read("ca_max", &ival)) { m_dft_ca_max = ival; str = wxString::Format("%d", ival); m_ca_max_text->SetValue(str); } //ignore max if (fconfig.Read("ca_ignore_max", &bval)) { m_ca_ignore_max_chk->SetValue(bval); if (bval) m_ca_max_text->Disable(); else m_ca_max_text->Enable(); } //thresh if (fconfig.Read("ca_thresh", &m_dft_ca_thresh)) { str = wxString::Format("%.1f", m_dft_ca_thresh*m_max_value); m_ca_thresh_sldr->SetRange(0, int(m_max_value*10.0)); m_ca_thresh_text->SetValue(str); } //falloff fconfig.Read("ca_falloff", &m_dft_ca_falloff); //size map if (fconfig.Read("ca_size_map", &bval)) m_ca_size_map_chk->SetValue(bval); //nr thresh fconfig.Read("nr_thresh", &m_dft_nr_thresh); //nr size if (fconfig.Read("nr_size", &m_dft_nr_size)) { str = wxString::Format("%d", (int)val); m_nr_size_text->SetValue(str); } }
void NRRDReader::Preprocess() { m_4d_seq.clear(); //separate path and name int64_t pos = m_path_name.find_last_of(GETSLASH()); if (pos == -1) return; wstring path = m_path_name.substr(0, pos+1); wstring name = m_path_name.substr(pos+1); //generate search name for time sequence int64_t begin = name.find(m_time_id); size_t end = -1; size_t id_len = m_time_id.size(); wstring t_num; if (begin != -1) { size_t j; for (j=begin+id_len; j<name.size(); j++) { wchar_t c = name[j]; if (iswdigit(c)) t_num.push_back(c); else break; } if (t_num.size() > 0) end = j; else begin = -1; } //build 4d sequence if (begin == -1) { TimeDataInfo info; info.filenumber = 0; info.filename = m_path_name; m_4d_seq.push_back(info); m_cur_time = 0; } else { //search time sequence files std::vector<std::wstring> list; int tmp = 0; FIND_FILES(path,L".nrrd",list,tmp,name.substr(0,begin+id_len+1)); for(size_t i = 0; i < list.size(); i++) { size_t start_idx = list.at(i).find(m_time_id) + id_len; size_t end_idx = list.at(i).find(L".nrrd"); size_t size = end_idx - start_idx; std::wstring fileno = list.at(i).substr(start_idx, size); TimeDataInfo info; info.filenumber = WSTOI(fileno); info.filename = list.at(i); m_4d_seq.push_back(info); } } if (m_4d_seq.size() > 0) { std::sort(m_4d_seq.begin(), m_4d_seq.end(), NRRDReader::nrrd_sort); for (int t=0; t<(int)m_4d_seq.size(); t++) { if (m_4d_seq[t].filename == m_path_name) { m_cur_time = t; break; } } } else m_cur_time = 0; //3D nrrd file m_chan_num = 1; //get time number m_time_num = (int)m_4d_seq.size(); }
Nrrd* NRRDReader::Convert(int t, int c, bool get_max) { if (t<0 || t>=m_time_num) return 0; int i; m_data_name = m_4d_seq[t].filename.substr(m_4d_seq[t].filename.find_last_of(GETSLASH())+1); Nrrd *output = nrrdNew(); NrrdIoState *nio = nrrdIoStateNew(); nrrdIoStateSet(nio, nrrdIoStateSkipData, AIR_TRUE); string str; str.assign(m_4d_seq[t].filename.length(), 0); for (i=0; i<(int)m_4d_seq[t].filename.length(); i++) str[i] = (char)m_4d_seq[t].filename[i]; if (nrrdLoad(output, str.c_str(), nio)) return 0; nio = nrrdIoStateNix(nio); if (output->dim != 3) { delete []output->data; nrrdNix(output); return 0; } m_slice_num = int(output->axis[2].size); m_x_size = int(output->axis[0].size); m_y_size = int(output->axis[1].size); m_xspc = output->axis[0].spacing; m_yspc = output->axis[1].spacing; m_zspc = output->axis[2].spacing; if (m_xspc>0.0 && m_xspc<100.0 && m_yspc>0.0 && m_yspc<100.0 && m_zspc>0.0 && m_zspc<100.0) m_valid_spc = true; else { m_valid_spc = false; m_xspc = 1.0; m_yspc = 1.0; m_zspc = 1.0; } int data_size = m_slice_num * m_x_size * m_y_size; if (output->type == nrrdTypeUShort || output->type == nrrdTypeShort) data_size *= 2; output->data = new unsigned char[data_size]; if (nrrdLoad(output, str.c_str(), NULL)) { delete []output->data; nrrdNix(output); return 0; } // turn signed into unsigned if (output->type == nrrdTypeChar) { for (i=0; i<m_slice_num*m_x_size*m_y_size; i++) { char val = ((char*)output->data)[i]; unsigned char n = val + 128; ((unsigned char*)output->data)[i] = n; } output->type = nrrdTypeUChar; } m_max_value = 0.0; // turn signed into unsigned unsigned short min_value = 32768, n; if (output->type == nrrdTypeShort || output->type == nrrdTypeUShort) { for (i=0; i<m_slice_num*m_x_size*m_y_size; i++) { if (output->type == nrrdTypeShort) { short val = ((short*)output->data)[i]; n = val + 32768; ((unsigned short*)output->data)[i] = n; min_value = (n < min_value)?n:min_value; } else { n = ((unsigned short*)output->data)[i]; } if (get_max) m_max_value = (n > m_max_value)?n:m_max_value; } output->type = nrrdTypeUShort; } //find max value if (output->type == nrrdTypeUChar) { //8 bit m_max_value = 255.0; m_scalar_scale = 1.0; } else if (output->type == nrrdTypeUShort) { m_max_value -= min_value; //16 bit for (i=0; i<m_slice_num*m_x_size*m_y_size; i++) { ((unsigned short*)output->data)[i] = ((unsigned short*)output->data)[i] - min_value; } if (m_max_value > 0.0) m_scalar_scale = 65535.0 / m_max_value; else m_scalar_scale = 1.0; } else { delete []output->data; nrrdNix(output); return 0; } m_cur_time = t; return output; }
DatabaseDlg::DatabaseDlg(wxWindow* frame, wxWindow* parent) : wxPanel(parent, wxID_ANY, wxPoint(500, 150), wxSize(440, 700), 0, "DatabaseDlg"), m_frame(parent), m_view(0) { SetEvtHandlerEnabled(false); Freeze(); wxBoxSizer *group1 = new wxBoxSizer(wxHORIZONTAL); m_url_text = new DBSearcher(parent, this, ID_SearchTextCtrl, wxT("Search"), wxDefaultPosition, wxSize(300, 23), wxTE_PROCESS_ENTER); m_download_btn = new wxButton(this, ID_DownloadBtn, wxT("Search"), wxDefaultPosition, wxSize(70, 23)); group1->Add(5, 5); group1->Add(m_url_text, 1, wxEXPAND); group1->Add(5, 5); group1->Add(m_download_btn, 0, wxALIGN_CENTER); wxBoxSizer *group_g = new wxBoxSizer(wxHORIZONTAL); m_sch_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(300, 10)); group_g->Add(5, 10); group_g->Add(m_sch_gauge, 1, wxEXPAND); group_g->Add(5, 10); //list m_dbtree = new DBTreeCtrl(frame, this, wxID_ANY); m_searchResult = new DBTreeCtrl(frame, this, wxID_ANY); wxString expath = wxStandardPaths::Get().GetExecutablePath(); expath = expath.BeforeLast(GETSLASH(),NULL); #ifdef _WIN32 wxString dft = expath + "\\catalog_list.set"; if (!wxFileExists(dft)) dft = wxStandardPaths::Get().GetUserConfigDir() + "\\catalog_list.set"; #else wxString dft = expath + "/../Resources/" + "catalog_list.set"; #endif wxFileInputStream is(dft); if (is.IsOk()) { wxTextInputStream tis(is); wxString str; while (!is.Eof()) { wxString sline = tis.ReadLine(); m_dbtree->LoadDatabase(sline); } } wxBoxSizer *group2 = new wxBoxSizer(wxHORIZONTAL); m_db_text = new DBSearcher(parent, this, ID_DBTextCtrl, wxT("URL or Path"), wxDefaultPosition, wxSize(330, 23), wxTE_PROCESS_ENTER); m_browse_btn = new wxButton(this, ID_BrowseBtn, wxT("Browse..."), wxDefaultPosition, wxSize(90, 23)); group2->Add(5, 5); group2->Add(m_db_text, 1, wxEXPAND); group2->Add(5, 5); group2->Add(m_browse_btn, 0, wxALIGN_CENTER); group2->Add(5, 5); wxBoxSizer *group3 = new wxBoxSizer(wxHORIZONTAL); m_add_btn = new wxButton(this, ID_AddDBBtn, wxT("Add"), wxDefaultPosition, wxSize(90, 28)); group3->AddStretchSpacer(1); group3->Add(5, 5); group3->Add(m_add_btn, 0, wxALIGN_CENTER); group3->Add(5, 5); //all controls wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL); sizerV->Add(10, 10); sizerV->Add(group1, 0, wxEXPAND); sizerV->Add(10, 5); sizerV->Add(group_g, 0, wxEXPAND); sizerV->Add(10, 10); sizerV->Add(m_dbtree, 1, wxEXPAND); sizerV->Add(m_searchResult, 1, wxEXPAND); sizerV->Add(10, 20); sizerV->Add(group2, 0, wxEXPAND); sizerV->Add(10, 5); sizerV->Add(group3, 0, wxEXPAND); m_searchResult->Hide(); m_sch_gauge->Hide(); SetSizer(sizerV); Layout(); m_thread = NULL; m_th_del = NULL; Thaw(); SetEvtHandlerEnabled(true); }
void OIFReader::SetFile(wstring &file) { m_path_name = file; m_data_name = m_path_name.substr(m_path_name.find_last_of(GETSLASH())+1); m_id_string = m_path_name; }
void SettingDlg::GetSettings() { m_gmc_mode = 2; m_prj_save = false; m_realtime_compress = false; m_skip_bricks = false; m_test_speed = false; m_test_param = false; m_test_wiref = false; m_peeling_layers = 1; m_micro_blend = false; m_shadow_dir = false; m_shadow_dir_x = 0.0; m_shadow_dir_y = 0.0; m_mouse_int = true; m_wav_color1 = 5; m_wav_color2 = 5; m_wav_color3 = 5; m_wav_color4 = 5; m_time_id = "_T"; m_grad_bg = false; m_override_vox = true; m_soft_threshold = 0.0; m_run_script = false; m_text_size = 12; m_font_file = ""; m_mem_swap = false; m_graphics_mem = 1000.0; m_large_data_size = 1000.0; m_force_brick_size = 128; m_up_time = 100; m_update_order = 0; m_point_volume_mode = 0; m_ruler_use_transf = false; m_ruler_time_dep = true; m_pvxml_flip_x = false; m_pvxml_flip_y = false; m_red_bit = 8; m_green_bit = 8; m_blue_bit = 8; m_alpha_bit = 8; m_depth_bit = 24; m_samples = 0; m_gl_major_ver = 4; m_gl_minor_ver = 4; m_gl_profile_mask = 2; m_cl_device_id = 0; m_paint_hist_depth = 0; wxString expath = wxStandardPaths::Get().GetExecutablePath(); expath = expath.BeforeLast(GETSLASH(),NULL); #ifdef _WIN32 wxString dft = expath + "\\" + SETTING_FILE_NAME; #else wxString dft = expath + "/../Resources/" + SETTING_FILE_NAME; #endif wxFileInputStream is(dft); if (!is.IsOk()) return; wxFileConfig fconfig(is); //gradient magnitude if (fconfig.Exists("/gm calculation")) { fconfig.SetPath("/gm calculation"); m_gmc_mode = fconfig.Read("mode", 2l); } //depth peeling if (fconfig.Exists("/peeling layers")) { fconfig.SetPath("/peeling layers"); m_peeling_layers = fconfig.Read("value", 1l); } //micro blending if (fconfig.Exists("/micro blend")) { fconfig.SetPath("/micro blend"); fconfig.Read("mode", &m_micro_blend, false); } //save project if (fconfig.Exists("/save project")) { fconfig.SetPath("/save project"); fconfig.Read("mode", &m_prj_save, false); } //realtime compression if (fconfig.Exists("/realtime compress")) { fconfig.SetPath("/realtime compress"); fconfig.Read("mode", &m_realtime_compress, false); } //skip empty bricks if (fconfig.Exists("/skip bricks")) { fconfig.SetPath("/skip bricks"); fconfig.Read("mode", &m_skip_bricks, false); } //mouse interactions if (fconfig.Exists("/mouse int")) { fconfig.SetPath("/mouse int"); fconfig.Read("mode", &m_mouse_int, true); } //shadow if (fconfig.Exists("/dir shadow")) { fconfig.SetPath("/dir shadow"); fconfig.Read("mode", &m_shadow_dir, false); fconfig.Read("x", &m_shadow_dir_x, 0.0); fconfig.Read("y", &m_shadow_dir_y, 0.0); } //test mode if (fconfig.Exists("/test mode")) { fconfig.SetPath("/test mode"); fconfig.Read("speed", &m_test_speed, false); fconfig.Read("param", &m_test_param, false); fconfig.Read("wiref", &m_test_wiref, false); } //wavelength to color if (fconfig.Exists("/wavelength to color")) { fconfig.SetPath("/wavelength to color"); fconfig.Read("c1", &m_wav_color1, 5); fconfig.Read("c2", &m_wav_color2, 5); fconfig.Read("c3", &m_wav_color3, 5); fconfig.Read("c4", &m_wav_color4, 5); } //time sequence identifier if (fconfig.Exists("/time id")) { fconfig.SetPath("/time id"); fconfig.Read("value", &m_time_id); } //gradient background if (fconfig.Exists("/grad bg")) { fconfig.SetPath("/grad bg"); fconfig.Read("value", &m_grad_bg); } //save compressed if (fconfig.Exists("/save cmp")) { bool save_cmp; fconfig.SetPath("/save cmp"); fconfig.Read("value", &save_cmp); VRenderFrame::SetCompression(save_cmp); } //override vox if (fconfig.Exists("/override vox")) { fconfig.SetPath("/override vox"); fconfig.Read("value", &m_override_vox); } //soft threshold if (fconfig.Exists("/soft threshold")) { fconfig.SetPath("/soft threshold"); fconfig.Read("value", &m_soft_threshold); } //run script if (fconfig.Exists("/run script")) { fconfig.SetPath("/run script"); fconfig.Read("value", &m_run_script); } //paint history depth if (fconfig.Exists("/paint history")) { fconfig.SetPath("/paint history"); fconfig.Read("value", &m_paint_hist_depth); } //text font if (fconfig.Exists("/text font")) { fconfig.SetPath("/text font"); fconfig.Read("file", &m_font_file); fconfig.Read("value", &m_text_size); } //memory settings if (fconfig.Exists("/memory settings")) { fconfig.SetPath("/memory settings"); //enable mem swap fconfig.Read("mem swap", &m_mem_swap); //graphics memory limit fconfig.Read("graphics mem", &m_graphics_mem); //large data size fconfig.Read("large data size", &m_large_data_size); //force brick size fconfig.Read("force brick size", &m_force_brick_size); //response time fconfig.Read("up time", &m_up_time); } EnableStreaming(m_mem_swap); //update order if (fconfig.Exists("/update order")) { fconfig.SetPath("/update order"); fconfig.Read("value", &m_update_order); } //point volume mode if (fconfig.Exists("/point volume mode")) { fconfig.SetPath("/point volume mode"); fconfig.Read("value", &m_point_volume_mode); } //ruler use transfer function if (fconfig.Exists("/ruler use transf")) { fconfig.SetPath("/ruler use transf"); fconfig.Read("value", &m_ruler_use_transf); } //ruler time dependent if (fconfig.Exists("/ruler time dep")) { fconfig.SetPath("/ruler time dep"); fconfig.Read("value", &m_ruler_time_dep); } //flags for pvxml flipping if (fconfig.Exists("/pvxml flip")) { fconfig.SetPath("/pvxml flip"); fconfig.Read("x", &m_pvxml_flip_x); fconfig.Read("y", &m_pvxml_flip_y); } //pixel format if (fconfig.Exists("/pixel format")) { fconfig.SetPath("/pixel format"); fconfig.Read("red_bit", &m_red_bit); fconfig.Read("green_bit", &m_green_bit); fconfig.Read("blue_bit", &m_blue_bit); fconfig.Read("alpha_bit", &m_alpha_bit); fconfig.Read("depth_bit", &m_depth_bit); fconfig.Read("samples", &m_samples); } //context attrib if (fconfig.Exists("/context attrib")) { fconfig.SetPath("/context attrib"); fconfig.Read("gl_major_ver", &m_gl_major_ver); fconfig.Read("gl_minor_ver", &m_gl_minor_ver); fconfig.Read("gl_profile_mask", &m_gl_profile_mask); } //cl device if (fconfig.Exists("/cl device")) { fconfig.SetPath("/cl device"); fconfig.Read("device_id", &m_cl_device_id); } UpdateUI(); }
void OIFReader::Preprocess() { m_type = 0; m_oif_info.clear(); //separate path and name int64_t pos = m_path_name.find_last_of(GETSLASH()); if (pos == -1) return; wstring path = m_path_name.substr(0, pos+1); wstring name = m_path_name.substr(pos+1); //extract time sequence string int64_t begin = name.find(m_time_id); size_t end = -1; size_t id_len = m_time_id.size(); if (begin != -1) { wstring t_num; size_t j; for (j=begin+id_len; j<name.size(); j++) { wchar_t c = name[j]; if (iswdigit(c)) t_num.push_back(c); else break; } if (t_num.size() > 0) end = j; else begin = -1; } if (begin == -1) { ReadSingleOif(); } else { //search time sequence files std::vector<std::wstring> list; int tmp = 0; FIND_FILES(path,L".oif",list,tmp,name.substr(0,begin+id_len+1)); for(size_t i = 0; i < list.size(); i++) { size_t start_idx = list.at(i).find(m_time_id) + id_len; size_t end_idx = list.at(i).find(L".oif"); size_t size = end_idx - start_idx; std::wstring fileno = list.at(i).substr(start_idx, size); TimeDataInfo info; info.filenumber = WSTOI(fileno); info.filename = list.at(i); m_oif_info.push_back(info); } if (m_oif_info.size() > 0) { m_type = 1; std::sort(m_oif_info.begin(), m_oif_info.end(), OIFReader::oif_sort); ReadSequenceOif(); } else { m_oif_info.clear(); ReadSingleOif(); } } ReadOif(); m_time_num = int(m_oif_info.size()); if (m_type == 0) m_cur_time = 0; m_chan_num = m_time_num>0?int(m_oif_info[0].dataset.size()):0; m_slice_num = m_chan_num>0?int(m_oif_info[0].dataset[0].size()):0; }
//save default void BrushToolDlg::SaveDefault() { wxFileConfig fconfig("FluoRender default brush settings"); double val; wxString str; //brush properties fconfig.Write("brush_ini_thresh", m_dft_ini_thresh); fconfig.Write("brush_gm_falloff", m_dft_gm_falloff); fconfig.Write("brush_scl_falloff", m_dft_scl_falloff); fconfig.Write("brush_scl_translate", m_dft_scl_translate); //auto thresh fconfig.Write("auto_thresh", m_estimate_thresh_chk->GetValue()); //edge detect fconfig.Write("edge_detect", m_edge_detect_chk->GetValue()); //hidden removal fconfig.Write("hidden_removal", m_hidden_removal_chk->GetValue()); //select group fconfig.Write("select_group", m_select_group_chk->GetValue()); //2d influence str = m_brush_2dinfl_text->GetValue(); str.ToDouble(&val); fconfig.Write("brush_2dinfl", val); //size 1 str = m_brush_size1_text->GetValue(); str.ToDouble(&val); fconfig.Write("brush_size1", val); //size2 link fconfig.Write("use_brush_size2", m_brush_size2_chk->GetValue()); //size 2 str = m_brush_size2_text->GetValue(); str.ToDouble(&val); fconfig.Write("brush_size2", val); //iterations int ival = m_brush_iterw_rb->GetValue()?1: m_brush_iters_rb->GetValue()?2: m_brush_iterss_rb->GetValue()?3:0; fconfig.Write("brush_iters", ival); //component analyzer //selected only fconfig.Write("ca_select_only", m_ca_select_only_chk->GetValue()); //min voxel str = m_ca_min_text->GetValue(); str.ToDouble(&val); fconfig.Write("ca_min", val); //max voxel str = m_ca_max_text->GetValue(); str.ToDouble(&val); fconfig.Write("ca_max", val); //ignore max fconfig.Write("ca_ignore_max", m_ca_ignore_max_chk->GetValue()); //thresh fconfig.Write("ca_thresh", m_dft_ca_thresh); //falloff fconfig.Write("ca_falloff", m_dft_ca_falloff); //size map fconfig.Write("ca_size_map", m_ca_size_map_chk->GetValue()); //noise removal //nr thresh fconfig.Write("nr_thresh", m_dft_nr_thresh); //nr_size wxString expath = wxStandardPaths::Get().GetExecutablePath(); expath = expath.BeforeLast(GETSLASH(),NULL); #ifdef _WIN32 wxString dft = expath + "\\default_brush_settings.dft"; #else wxString dft = expath + "/../Resources/default_brush_settings.dft"; #endif wxFileOutputStream os(dft); fconfig.Save(os); }