Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
add --desc command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
takashi310 committed Apr 23, 2021
1 parent fa04eed commit 0bce861
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 53 deletions.
13 changes: 8 additions & 5 deletions fluorender/FluoRender/DataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6864,7 +6864,7 @@ bool DataManager::DownloadToCurrentDir(wxString &filename)
return true;
}

int DataManager::LoadVolumeData(wxString &filename, int type, int ch_num, int t_num, size_t datasize)
int DataManager::LoadVolumeData(wxString &filename, int type, int ch_num, int t_num, size_t datasize, wxString prefix)
{
wxString pathname = filename;
bool isURL = false;
Expand Down Expand Up @@ -7086,11 +7086,14 @@ int DataManager::LoadVolumeData(wxString &filename, int type, int ch_num, int t_
BRKXMLReader* breader = (BRKXMLReader*)reader;
name = reader->GetDataName();
name = name.Mid(0, name.find_last_of(wxT('.')));
if(ch_num > 1) name = wxT("_Ch") + wxString::Format("%i", i);
if(ch_num > 1) name += wxT("_Ch") + wxString::Format("%i", i);
pathname = filename;
breader->SetCurChan(i);
breader->SetCurTime(0);
}

if (!prefix.IsEmpty())
name = prefix + wxT("_") + name;

bool valid_spc = reader->IsSpcInfoValid();
if (vd && vd->Load(data, name, pathname, (type == LOAD_TYPE_BRKXML) ? (BRKXMLReader*)reader : NULL))
Expand Down Expand Up @@ -7199,7 +7202,7 @@ int DataManager::LoadVolumeData(wxString &filename, int type, int ch_num, int t_
return result;
}

int DataManager::LoadMeshData(wxString &filename)
int DataManager::LoadMeshData(wxString &filename, wxString prefix)
{
wxString pathname = filename;
if (!wxFileExists(pathname))
Expand All @@ -7213,11 +7216,11 @@ int DataManager::LoadMeshData(wxString &filename)
md->Load(pathname);

wxString name = md->GetName();
wxString new_name = name;
wxString new_name = prefix + wxT("_") + name;
int i;
for (i=1; CheckNames(new_name, DATA_MESH); i++)
new_name = name+wxString::Format("_%d", i);
if (i>1)
if (i>1 || !prefix.IsEmpty())
md->SetName(new_name);
m_md_list.push_back(md);

Expand Down
4 changes: 2 additions & 2 deletions fluorender/FluoRender/DataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ class EXPORT_API DataManager

bool DownloadToCurrentDir(wxString &filename);
//load volume
int LoadVolumeData(wxString &filename, int type, int ch_num=-1, int t_num=-1, size_t datasize = 0);
int LoadVolumeData(wxString &filename, int type, int ch_num=-1, int t_num=-1, size_t datasize = 0, wxString prefix = wxT(""));
//set default
void SetVolumeDefault(VolumeData* vd);
//load volume options
Expand Down Expand Up @@ -1628,7 +1628,7 @@ class EXPORT_API DataManager
}

//load mesh
int LoadMeshData(wxString &filename);
int LoadMeshData(wxString &filename, wxString prefix = wxT(""));
int LoadMeshData(GLMmodel* mesh);
int GetMeshNum();
MeshData* GetMeshData(int index);
Expand Down
87 changes: 80 additions & 7 deletions fluorender/FluoRender/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ IMPLEMENT_APP(VRenderApp)

static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{
{ wxCMD_LINE_OPTION, "p", NULL, NULL,
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_PARAM, NULL, NULL, "input file",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_PARAM_MULTIPLE },
{ wxCMD_LINE_OPTION, "p", "plugin", NULL, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, "d", "desc", NULL, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_PARAM, NULL, NULL, "input file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL|wxCMD_LINE_PARAM_MULTIPLE },
{ wxCMD_LINE_NONE }
};

Expand Down Expand Up @@ -144,7 +143,7 @@ bool VRenderApp::OnInit()
((VRenderFrame *)m_frame)->SetRealtimeCompression(setting_dlg->GetRealtimeCompress());

if (m_files.Count()>0)
((VRenderFrame*)m_frame)->StartupLoad(m_files);
((VRenderFrame*)m_frame)->StartupLoad(m_files, 0LL, m_descs);

if (!m_plugin_name.IsEmpty())
((VRenderFrame*)m_frame)->RunPlugin(m_plugin_name, m_plugin_params, true);
Expand Down Expand Up @@ -172,10 +171,83 @@ void VRenderApp::OnInitCmdLine(wxCmdLineParser& parser)

bool VRenderApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
int i=0;
wxString params;
int i=0;
wxString params;


for (wxCmdLineArgs::const_iterator itarg=parser.GetArguments().begin();
itarg!=parser.GetArguments().end();
++itarg)
{
wxString optionName;
switch (itarg->GetKind())
{
case wxCMD_LINE_SWITCH:
if (itarg->IsNegated()) {
}
else {
}
break;
case wxCMD_LINE_OPTION:
// assuming that all the options have a short name
optionName = itarg->GetShortName();
if (optionName == wxT("p")) {
wxString val = itarg->GetStrVal();
m_plugin_name = val.BeforeFirst(' ');
m_plugin_params = val.AfterFirst(' ');
}
else if (optionName == wxT("d")) {
wxString val = itarg->GetStrVal();
m_descs.Add(val);
}
break;
case wxCMD_LINE_PARAM:
{
wxString file = itarg->GetStrVal();
if (file.StartsWith(wxT("vvd:")))
{
m_open_by_web_browser = true;
if (file.Length() >= 5)
{
params = file.SubString(4, file.Length() - 1);
wxStringTokenizer tkz(params, wxT(","));
while (tkz.HasMoreTokens())
{
wxString path = tkz.GetNextToken();
m_files.Add(path);
}
}
}
else
{
m_files.Add(file);
}
}
break;
case wxCMD_LINE_NONE:
switch (itarg->GetType()) {
case wxCMD_LINE_VAL_NUMBER:
// do something with itarg->GetLongVal();
break;
case wxCMD_LINE_VAL_DOUBLE:
// do something with itarg->GetDoubleVal();
break;
case wxCMD_LINE_VAL_DATE:
// do something with itarg->GetDateVal();
break;
case wxCMD_LINE_VAL_STRING:
// do something with itarg->GetStrVal();
break;
default:
break;
}
break;
default:
break;
}
}

/*
wxString list;
for (i = 0; i < (int)parser.GetParamCount(); i++)
{
Expand Down Expand Up @@ -222,6 +294,7 @@ bool VRenderApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_files.Add(file);
}
}
*/

#ifdef _WIN32
/* {
Expand Down
3 changes: 2 additions & 1 deletion fluorender/FluoRender/Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class VRenderApp : public wxApp

private:
wxArrayString m_files;
wxArrayString m_descs;
wxString m_plugin_params;
wxString m_plugin_name;
wxFrame *m_frame;
Expand All @@ -63,4 +64,4 @@ class VRenderApp : public wxApp

DECLARE_APP(VRenderApp)

#endif//_MAIN_H_
#endif//_MAIN_H_
88 changes: 53 additions & 35 deletions fluorender/FluoRender/VRenderFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void VRenderFrame::OnDownloadVolume(wxCommandEvent& WXUNUSED(event))
m_aui_mgr.Update();
}

void VRenderFrame::LoadVolumes(wxArrayString files, VRenderView* view, vector<vector<AnnotationDB>> annotations, size_t datasize)
void VRenderFrame::LoadVolumes(wxArrayString files, VRenderView* view, vector<vector<AnnotationDB>> annotations, size_t datasize, wxArrayString descs)
{
int j;

Expand Down Expand Up @@ -1118,28 +1118,29 @@ void VRenderFrame::LoadVolumes(wxArrayString files, VRenderView* view, vector<ve

int ch_num = 0;
wxString filename = files[j];
wxString prefix = j < descs.Count() ? descs[j] : wxT("");
wxString suffix = filename.Mid(filename.Find('.', true)).MakeLower();

if (suffix == ".nrrd")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_NRRD, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_NRRD, -1, -1, datasize, prefix);
else if (suffix==".tif" || suffix==".tiff" || suffix==".zip")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_TIFF, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_TIFF, -1, -1, datasize, prefix);
else if (suffix == ".oib")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_OIB, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_OIB, -1, -1, datasize, prefix);
else if (suffix == ".oif")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_OIF, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_OIF, -1, -1, datasize, prefix);
else if (suffix==".lsm")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_LSM, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_LSM, -1, -1, datasize, prefix);
else if (suffix==".xml")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_PVXML, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_PVXML, -1, -1, datasize, prefix);
else if (suffix==".vvd" || suffix==".n5" || suffix==".json" || suffix==".n5fs_ch")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_BRKXML, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_BRKXML, -1, -1, datasize, prefix);
else if (suffix == ".h5j")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_H5J, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_H5J, -1, -1, datasize, prefix);
else if (suffix == ".v3dpbd")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_V3DPBD, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_V3DPBD, -1, -1, datasize, prefix);
else if (suffix == ".idi")
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_IDI, -1, -1, datasize);
ch_num = m_data_mgr.LoadVolumeData(filename, LOAD_TYPE_IDI, -1, -1, datasize, prefix);

if (ch_num > 1)
{
Expand Down Expand Up @@ -1329,7 +1330,7 @@ void VRenderFrame::AddVolume(VolumeData *vd, VRenderView* view)
vrv->RefreshGL();
}

void VRenderFrame::StartupLoad(wxArrayString files, size_t datasize)
void VRenderFrame::StartupLoad(wxArrayString files, size_t datasize, wxArrayString descs)
{
if (m_vrv_list[0])
m_vrv_list[0]->m_glview->Init();
Expand All @@ -1343,31 +1344,48 @@ void VRenderFrame::StartupLoad(wxArrayString files, size_t datasize)
{
OpenProject(files[0]);
}
else if (suffix == ".nrrd" ||
suffix == ".tif" ||
suffix == ".tiff" ||
suffix == ".oib" ||
suffix == ".oif" ||
suffix == ".lsm" ||
suffix == ".xml" ||
suffix == ".vvd" ||
suffix == ".n5" ||
suffix == ".json" ||
suffix == ".h5j" ||
suffix == ".v3dpbd" ||
suffix == ".zip" ||
suffix == ".idi")
{
LoadVolumes(files, NULL, vector<vector<AnnotationDB>>(), datasize);
}
else if (suffix == ".obj" || suffix == ".swc" || suffix == ".ply")
{
LoadMeshes(files);
}
else
{
wxArrayString vol_files, msh_files;
wxArrayString vol_descs, msh_descs;
for (int i = 0; i < files.Count(); i++)
{
suffix = files[i].Mid(files[i].Find('.', true)).MakeLower();
if (suffix == ".nrrd" ||
suffix == ".tif" ||
suffix == ".tiff" ||
suffix == ".oib" ||
suffix == ".oif" ||
suffix == ".lsm" ||
suffix == ".xml" ||
suffix == ".vvd" ||
suffix == ".n5" ||
suffix == ".json" ||
suffix == ".h5j" ||
suffix == ".v3dpbd" ||
suffix == ".zip" ||
suffix == ".idi")
{
vol_files.Add(files[i]);
if (i < descs.Count())
vol_descs.Add(descs[i]);
}
else if (suffix == ".obj" || suffix == ".swc" || suffix == ".ply")
{
msh_files.Add(files[i]);
if (i < descs.Count())
msh_descs.Add(descs[i]);
}
}
if (vol_files.Count() > 0)
LoadVolumes(vol_files, NULL, vector<vector<AnnotationDB>>(), datasize, vol_descs);
if (msh_files.Count() > 0)
LoadMeshes(msh_files, NULL, msh_descs);
}
}
}

void VRenderFrame::LoadMeshes(wxArrayString files, VRenderView* vrv)
void VRenderFrame::LoadMeshes(wxArrayString files, VRenderView* vrv, wxArrayString descs)
{
if (!vrv)
vrv = GetView(0);
Expand All @@ -1391,7 +1409,7 @@ void VRenderFrame::LoadMeshes(wxArrayString files, VRenderView* vrv)
prg_diag->Update(90*(i+1)/(int)files.Count());

wxString filename = files[i];
m_data_mgr.LoadMeshData(filename);
m_data_mgr.LoadMeshData(filename, i < descs.Count() ? descs[i] : wxT(""));

MeshData* md = m_data_mgr.GetLastMeshData();
if (vrv && md)
Expand Down
6 changes: 3 additions & 3 deletions fluorender/FluoRender/VRenderFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ class EXPORT_API VRenderFrame: public wxFrame
MeshData* GetCurSelMesh()
{ return m_data_mgr.GetMeshData(m_cur_sel_mesh); }

void StartupLoad(wxArrayString files, size_t datasize = 0LL);
void StartupLoad(wxArrayString files, size_t datasize = 0LL, wxArrayString descs = wxArrayString());
VolumeData* OpenVolumeFromProject(wxString name, wxFileConfig &fconfig);
void OpenVolumesFromProjectMT(wxFileConfig &fconfig, bool join);
void SetVolumePropertiesFromProject(wxFileConfig &fconfig);
MeshData* OpenMeshFromProject(wxString name, wxFileConfig &fconfig);
void OpenProject(wxString& filename);
void SaveProject(wxString& filename);
void LoadVolumes(wxArrayString files, VRenderView* view = 0, vector<vector<AnnotationDB>> annotations = vector<vector<AnnotationDB>>(), size_t datasize = 0LL);
void LoadMeshes(wxArrayString files, VRenderView* view = 0);
void LoadVolumes(wxArrayString files, VRenderView* view = 0, vector<vector<AnnotationDB>> annotations = vector<vector<AnnotationDB>>(), size_t datasize = 0LL, wxArrayString descs = wxArrayString());
void LoadMeshes(wxArrayString files, VRenderView* view = 0, wxArrayString descs = wxArrayString());

void AddVolume(VolumeData *vd, VRenderView* view);

Expand Down

0 comments on commit 0bce861

Please sign in to comment.