Skip to content

Commit 9669177

Browse files
committed
Merge branch 'doc-preparations-3.6.0' of https://github.com/mccode-dev/McCode into doc-preparations-3.6.0
2 parents a25b32e + 9b55b00 commit 9669177

File tree

9 files changed

+40
-25
lines changed

9 files changed

+40
-25
lines changed

cmake/Modules/InstallMCCODE.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ macro(installMCCODE)
397397
endif()
398398

399399
if(WINDOWS)
400+
cmake_path( CONVERT "${MCCODE_RELPATH_BINDIR2TOOLDIR}" TO_NATIVE_PATH_LIST MCCODE_RELPATH_BINDIR2TOOLDIR)
401+
400402
# Generate and install Windows setup scripts
401403
foreach (name env.bat env.m go.bat test.bat)
402404
configure_file(
@@ -413,7 +415,7 @@ macro(installMCCODE)
413415
install(PROGRAMS ${WORK}/support/${FLAVOR}-labenv.bat DESTINATION "${DEST_BINDIR}")
414416

415417
# Python/Perl related batches special handling
416-
foreach (name run.bat doc.bat test.bat viewtest.bat resplot.bat plot.bat display.bat gui.bat guistart.bat plot-pyqtgraph.bat plot-matplotlib.bat plot-matlab.bat display-webgl.bat display-webgl-classic.bat display-pyqtgraph.bat display-cad.bat display-matplotlib.bat display-mantid.bat)
418+
foreach (name run.bat doc.bat test.bat viewtest.bat resplot.bat plot.bat display.bat gui.bat guistart.bat plot-pyqtgraph.bat plot-matplotlib.bat plot-matlab.bat display-webgl.bat display-webgl-classic.bat display-pyqtgraph.bat display-cad.bat display-matplotlib.bat display-mantid.bat display-matlab.bat)
417419
configure_file(
418420
cmake/support/run-scripts/${name}.in
419421
work/support/${MCCODE_PREFIX}${name}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@REM Isn't windows a lovely place???
2+
@set BINDIR=%~dp0
3+
@matlab -nosplash -r "addpath('%BINDIR%@MCCODE_RELPATH_BINDIR2TOOLDIR@\matlab\@MCCODE_PREFIX@display');mcdisplay @MCCODE_PREFIX@run %*"
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
@CALL @CPACK_NSIS_INSTALL_ROOT@\bin\mccodeenv.bat
2-
@set BINDIR=%~dp0
3-
@SET PATH=%BINDIR%\@MCCODE_RELPATH_BINDIR2TOOLDIR@\matlab\@MCCODE_PREFIX@plot;%PATH%
4-
@REM Isn't windows a lovely place???
5-
@mcplot.m %*
6-
1+
@CALL @CPACK_NSIS_INSTALL_ROOT@\bin\mccodeenv.bat
2+
@set BINDIR=%~dp0
3+
@REM Isn't windows a lovely place???
4+
@matlab -nosplash -r "addpath('%BINDIR%@MCCODE_RELPATH_BINDIR2TOOLDIR@\matlab\@MCCODE_PREFIX@plot');mcplot %*"

mcstas-comps/examples/Tests_union/Geometry_test/Geometry_test.instr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
* Use of all basic geometries, mesh(as a torus), sphere, cylinder, cone and box
2020
*
2121
* %Example: meshfile="torus.off" Detector: detector_scat_I=40.2053
22+
* %Example: meshfile="torus.STL" Detector: detector_scat_I=40.2053
2223
*
2324
* %Parameters
2425
*
2526
* %End
2627
*******************************************************************************/
2728

28-
DEFINE INSTRUMENT Geometry_test(string meshfile="torus.off")
29+
DEFINE INSTRUMENT Geometry_test(string meshfile="torus.STL")
2930

3031
DECLARE
3132
%{

mcstas-comps/union/Union_mesh.comp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ void read_stl(char* filename,
222222
fclose(file);
223223

224224
} else {
225-
#ifndef _MSC_EXTENSIONS
226-
FILE *file = Open_File(filename, "r", NULL);
225+
FILE *file = Open_File(filename, "rb", NULL);
227226
// Read header
228227
char header[80];
229228
fread(header, sizeof(char), 80, file);
@@ -247,9 +246,6 @@ void read_stl(char* filename,
247246
}
248247

249248
fclose(file);
250-
#else
251-
fprintf(stderr,"Union_mesh ERROR:\n Binary STL is not yet supported when compiling with MSVC.\n Please convert file to e.g. ascii OFF via meshlab.\n.");
252-
#endif
253249
}
254250

255251
*n_verts = 3* *n_faces;

tools/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 3.17.0)
22
cmake_policy(VERSION 3.17.0)
33

44
#add_subdirectory(Legacy-Perl-cmdline)
5-
add_subdirectory(Python)
5+
add_subdirectory(Python)
6+
add_subdirectory(matlab)

tools/Python/mcdisplay/cad/mcdisplay.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111
import sys
1212
from pathlib import Path
13+
import subprocess
1314

1415
sys.path.append(str(Path(__file__).resolve().parent.parent.parent))
1516
from mccodelib.instrgeom import Vector3d, DrawLine, DrawMultiline, DrawCircle
17+
from mccodelib import mccode_config
1618

1719

1820
def vector_to_tuple(v: Vector3d):
@@ -140,8 +142,19 @@ def instrument_to_assembly(inst):
140142

141143
def main(instr=None, dirname=None, **kwds):
142144
from logging import basicConfig, INFO
145+
import time
143146
basicConfig(level=INFO)
144147

148+
try:
149+
# Try initial import or inform to install cadquery
150+
from cadquery.occ_impl.geom import Matrix
151+
except:
152+
message="To use this display tool, please install the 'cadquery' Python package"
153+
subprocess.Popen('%s %s' % (mccode_config.configuration['MCCODE']+"_errmsg", message), shell=True)
154+
print(mccode_config.configuration['MCCODE']+": "+ message)
155+
time.sleep(3)
156+
quit()
157+
145158
# output directory
146159
if dirname is None:
147160
from datetime import datetime as dt
@@ -158,7 +171,12 @@ def main(instr=None, dirname=None, **kwds):
158171

159172
# Do the conversion to a CadQuery assembly, then save it to the desired location
160173
assembly = instrument_to_assembly(instrument)
161-
assembly.save(str(root.joinpath(f"{Path(instr).stem}.{kwds.get('format','step')}")))
174+
output = str(root.joinpath(f"{Path(instr).stem}.{kwds.get('format','step')}"))
175+
assembly.save(output)
176+
177+
# Use mccode_config / the OS to open the resulting file...
178+
if Path(output).is_file():
179+
subprocess.Popen('%s %s' % (mccode_config.configuration['BROWSER'], output), shell=True)
162180

163181
def output_format(astring):
164182
f = astring.lower()

tools/matlab/mcdisplay/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ set(WORK "${PROJECT_BINARY_DIR}/work")
6969

7070

7171
# Configure fallback script
72-
configure_file("${CMAKE_SOURCE_DIR}/mcdisplay.in" "${WORK}/${P}display" @ONLY)
72+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcdisplay.in" "${WORK}/${P}display" @ONLY)
7373

7474
# Configure doc
7575
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcdisplay-matlab.md.in" "${WORK}/${P}display-matlab.md" @ONLY)
7676

7777
if(WINDOWS)
78-
set(BINS "${PROJECT_SOURCE_DIR}/mcdisplay.m")
78+
set(BINS "${CMAKE_CURRENT_SOURCE_DIR}/mcdisplay.m")
7979
else()
8080
set(BINS "${WORK}/${P}display")
81-
set(BINS "${PROJECT_SOURCE_DIR}/mcdisplay.m")
81+
set(BINS "${CMAKE_CURRENT_SOURCE_DIR}/mcdisplay.m")
8282
endif()
8383

8484

@@ -112,10 +112,6 @@ if(NOT WINDOWS)
112112
"${TOOLS_LIB}/mcdisplay" "${WORK}/${P}display"
113113
)
114114

115-
add_custom_target(
116-
"CREATE_SYMLINK" ALL DEPENDS "${WORK}/${P}display"
117-
)
118-
119115
install(
120116
PROGRAMS "${WORK}/${P}display"
121117
DESTINATION ${DEST_BINDIR}

tools/matlab/mcdisplay/mcdisplay.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@
334334
this_line = output{index};
335335
this_line = strrep(this_line, 'MCDISPLAY: ','[x,y,z]=');
336336
eval([ this_line ';' ]); % executes multiline(..), return a set of points (local coords)
337-
X = [ X x ];
338-
Y = [ Y y ];
339-
Z = [ Z z ];
337+
X = [ X NaN x ];
338+
Y = [ Y NaN y ];
339+
Z = [ Z NaN z ];
340340
end
341341
end
342342

0 commit comments

Comments
 (0)