diff --git a/mcstas-comps/samples/Single_crystal.comp b/mcstas-comps/samples/Single_crystal.comp index ba7755261..36476b76b 100644 --- a/mcstas-comps/samples/Single_crystal.comp +++ b/mcstas-comps/samples/Single_crystal.comp @@ -379,12 +379,97 @@ struct hkl_data { struct hkl_data const *pa = a; struct hkl_data const *pb = b; - double s = pa->tau - pb->tau; - if (!s) return 0; - else return (s < 0 ? -1 : 1); - } /* PN_list_compare */ - + /* Sort by tau */ + if (pa->tau < pb->tau) return -1; + if (pa->tau > pb->tau) return 1; + + /* Sort by tau_x */ + if (pa->tau_x < pb->tau_x) return -1; + if (pa->tau_x > pb->tau_x) return 1; + + /* Sort by tau_y */ + if (pa->tau_y < pb->tau_y) return -1; + if (pa->tau_y > pb->tau_y) return 1; + + /* Sort by tau_z */ + if (pa->tau_z < pb->tau_z) return -1; + if (pa->tau_z > pb->tau_z) return 1; + + /* In case of tie, sort by h also */ + if (pa->h < pb->h) return -1; + if (pa->h > pb->h) return 1; + + /* In case of tie, sort by k also */ + if (pa->k < pb->k) return -1; + if (pa->k > pb->k) return 1; + + /* In case of tie, sort by l also */ + if (pa->l < pb->l) return -1; + if (pa->l > pb->l) return 1; + + /* In case of tie, sort by F2 also */ + if (pa->F2 < pb->F2) return -1; + if (pa->F2 > pb->F2) return 1; + + /* In case of tie, sort by cutoff also */ + if (pa->cutoff < pb->cutoff) return -1; + if (pa->cutoff > pb->cutoff) return 1; + + /* In case of tie, sort by sig123 also */ + if (pa->sig123 < pb->sig123) return -1; + if (pa->sig123 > pb->sig123) return 1; + + /* In case of tie, sort by m1 also */ + if (pa->m1 < pb->m1) return -1; + if (pa->m1 > pb->m1) return 1; + + /* In case of tie, sort by sig123 also */ + if (pa->m2 < pb->m2) return -1; + if (pa->m2 > pb->m2) return 1; + + /* In case of tie, sort by m3 also */ + if (pa->m3 < pb->m3) return -1; + if (pa->m3 > pb->m3) return 1; + + /* In case of tie, sort by u1x also */ + if (pa->u1x < pb->u1x) return -1; + if (pa->u1x > pb->u1x) return 1; + + /* In case of tie, sort by u1y also */ + if (pa->u1y < pb->u1y) return -1; + if (pa->u1y > pb->u1y) return 1; + + /* In case of tie, sort by u1z also */ + if (pa->u1z < pb->u1z) return -1; + if (pa->u1z > pb->u1z) return 1; + + /* In case of tie, sort by u2x also */ + if (pa->u2x < pb->u2x) return -1; + if (pa->u2x > pb->u2x) return 1; + + /* In case of tie, sort by u2y also */ + if (pa->u2y < pb->u2y) return -1; + if (pa->u2y > pb->u2y) return 1; + + /* In case of tie, sort by u2z also */ + if (pa->u2z < pb->u2z) return -1; + if (pa->u2z > pb->u2z) return 1; + + /* In case of tie, sort by u3x also */ + if (pa->u3x < pb->u3x) return -1; + if (pa->u3x > pb->u3x) return 1; + + /* In case of tie, sort by u3y also */ + if (pa->u3y < pb->u3y) return -1; + if (pa->u3y > pb->u3y) return 1; + + /* In case of tie, sort by u3z also */ + if (pa->u3z < pb->u3z) return -1; + if (pa->u3z > pb->u3z) return 1; + + return 0; + } /* SX_list_compare */ #ifndef CIF2HKL #define CIF2HKL diff --git a/mcstas-comps/union/Single_crystal_process.comp b/mcstas-comps/union/Single_crystal_process.comp index 3df79c171..28b6bb102 100755 --- a/mcstas-comps/union/Single_crystal_process.comp +++ b/mcstas-comps/union/Single_crystal_process.comp @@ -167,11 +167,97 @@ SHARE { struct hkl_data_union const *pa = a; struct hkl_data_union const *pb = b; - double s = pa->tau - pb->tau; - - if (!s) return 0; - else return (s < 0 ? -1 : 1); - } /* PN_list_compare */ + + /* Sort by tau */ + if (pa->tau < pb->tau) return -1; + if (pa->tau > pb->tau) return 1; + + /* Sort by tau_x */ + if (pa->tau_x < pb->tau_x) return -1; + if (pa->tau_x > pb->tau_x) return 1; + + /* Sort by tau_y */ + if (pa->tau_y < pb->tau_y) return -1; + if (pa->tau_y > pb->tau_y) return 1; + + /* Sort by tau_z */ + if (pa->tau_z < pb->tau_z) return -1; + if (pa->tau_z > pb->tau_z) return 1; + + /* In case of tie, sort by h also */ + if (pa->h < pb->h) return -1; + if (pa->h > pb->h) return 1; + + /* In case of tie, sort by k also */ + if (pa->k < pb->k) return -1; + if (pa->k > pb->k) return 1; + + /* In case of tie, sort by l also */ + if (pa->l < pb->l) return -1; + if (pa->l > pb->l) return 1; + + /* In case of tie, sort by F2 also */ + if (pa->F2 < pb->F2) return -1; + if (pa->F2 > pb->F2) return 1; + + /* In case of tie, sort by cutoff also */ + if (pa->cutoff < pb->cutoff) return -1; + if (pa->cutoff > pb->cutoff) return 1; + + /* In case of tie, sort by sig123 also */ + if (pa->sig123 < pb->sig123) return -1; + if (pa->sig123 > pb->sig123) return 1; + + /* In case of tie, sort by m1 also */ + if (pa->m1 < pb->m1) return -1; + if (pa->m1 > pb->m1) return 1; + + /* In case of tie, sort by sig123 also */ + if (pa->m2 < pb->m2) return -1; + if (pa->m2 > pb->m2) return 1; + + /* In case of tie, sort by m3 also */ + if (pa->m3 < pb->m3) return -1; + if (pa->m3 > pb->m3) return 1; + + /* In case of tie, sort by u1x also */ + if (pa->u1x < pb->u1x) return -1; + if (pa->u1x > pb->u1x) return 1; + + /* In case of tie, sort by u1y also */ + if (pa->u1y < pb->u1y) return -1; + if (pa->u1y > pb->u1y) return 1; + + /* In case of tie, sort by u1z also */ + if (pa->u1z < pb->u1z) return -1; + if (pa->u1z > pb->u1z) return 1; + + /* In case of tie, sort by u2x also */ + if (pa->u2x < pb->u2x) return -1; + if (pa->u2x > pb->u2x) return 1; + + /* In case of tie, sort by u2y also */ + if (pa->u2y < pb->u2y) return -1; + if (pa->u2y > pb->u2y) return 1; + + /* In case of tie, sort by u2z also */ + if (pa->u2z < pb->u2z) return -1; + if (pa->u2z > pb->u2z) return 1; + + /* In case of tie, sort by u3x also */ + if (pa->u3x < pb->u3x) return -1; + if (pa->u3x > pb->u3x) return 1; + + /* In case of tie, sort by u3y also */ + if (pa->u3y < pb->u3y) return -1; + if (pa->u3y > pb->u3y) return 1; + + /* In case of tie, sort by u3z also */ + if (pa->u3z < pb->u3z) return -1; + if (pa->u3z > pb->u3z) return 1; + + return 0; + } /* SX_list_compare */ /* ------------------------------------------------------------------------ */ int diff --git a/mcxtrace-comps/samples/Single_crystal.comp b/mcxtrace-comps/samples/Single_crystal.comp index 02d35b25b..41d020ecd 100644 --- a/mcxtrace-comps/samples/Single_crystal.comp +++ b/mcxtrace-comps/samples/Single_crystal.comp @@ -396,10 +396,96 @@ SHARE { struct hkl_data const *pa = a; struct hkl_data const *pb = b; - double s = pa->tau - pb->tau; - if (!s) return 0; - else return (s < 0 ? -1 : 1); + /* Sort by tau */ + if (pa->tau < pb->tau) return -1; + if (pa->tau > pb->tau) return 1; + + /* Sort by tau_x */ + if (pa->tau_x < pb->tau_x) return -1; + if (pa->tau_x > pb->tau_x) return 1; + + /* Sort by tau_y */ + if (pa->tau_y < pb->tau_y) return -1; + if (pa->tau_y > pb->tau_y) return 1; + + /* Sort by tau_z */ + if (pa->tau_z < pb->tau_z) return -1; + if (pa->tau_z > pb->tau_z) return 1; + + /* In case of tie, sort by h also */ + if (pa->h < pb->h) return -1; + if (pa->h > pb->h) return 1; + + /* In case of tie, sort by k also */ + if (pa->k < pb->k) return -1; + if (pa->k > pb->k) return 1; + + /* In case of tie, sort by l also */ + if (pa->l < pb->l) return -1; + if (pa->l > pb->l) return 1; + + /* In case of tie, sort by F2 also */ + if (pa->F2 < pb->F2) return -1; + if (pa->F2 > pb->F2) return 1; + + /* In case of tie, sort by cutoff also */ + if (pa->cutoff < pb->cutoff) return -1; + if (pa->cutoff > pb->cutoff) return 1; + + /* In case of tie, sort by sig123 also */ + if (pa->sig123 < pb->sig123) return -1; + if (pa->sig123 > pb->sig123) return 1; + + /* In case of tie, sort by m1 also */ + if (pa->m1 < pb->m1) return -1; + if (pa->m1 > pb->m1) return 1; + + /* In case of tie, sort by sig123 also */ + if (pa->m2 < pb->m2) return -1; + if (pa->m2 > pb->m2) return 1; + + /* In case of tie, sort by m3 also */ + if (pa->m3 < pb->m3) return -1; + if (pa->m3 > pb->m3) return 1; + + /* In case of tie, sort by u1x also */ + if (pa->u1x < pb->u1x) return -1; + if (pa->u1x > pb->u1x) return 1; + + /* In case of tie, sort by u1y also */ + if (pa->u1y < pb->u1y) return -1; + if (pa->u1y > pb->u1y) return 1; + + /* In case of tie, sort by u1z also */ + if (pa->u1z < pb->u1z) return -1; + if (pa->u1z > pb->u1z) return 1; + + /* In case of tie, sort by u2x also */ + if (pa->u2x < pb->u2x) return -1; + if (pa->u2x > pb->u2x) return 1; + + /* In case of tie, sort by u2y also */ + if (pa->u2y < pb->u2y) return -1; + if (pa->u2y > pb->u2y) return 1; + + /* In case of tie, sort by u2z also */ + if (pa->u2z < pb->u2z) return -1; + if (pa->u2z > pb->u2z) return 1; + + /* In case of tie, sort by u3x also */ + if (pa->u3x < pb->u3x) return -1; + if (pa->u3x > pb->u3x) return 1; + + /* In case of tie, sort by u3y also */ + if (pa->u3y < pb->u3y) return -1; + if (pa->u3y > pb->u3y) return 1; + + /* In case of tie, sort by u3z also */ + if (pa->u3z < pb->u3z) return -1; + if (pa->u3z > pb->u3z) return 1; + + return 0; } /* SX_list_compare */ #ifndef CIF2HKL diff --git a/tools/Python/mccodelib/mccode_config.json.in b/tools/Python/mccodelib/mccode_config.json.in index 810a4d86d..38db0e6d3 100644 --- a/tools/Python/mccodelib/mccode_config.json.in +++ b/tools/Python/mccodelib/mccode_config.json.in @@ -15,6 +15,9 @@ "BROWSER": "@BROWSER@", "GUICOLS": "3", "GUIFONTSIZE": "12", + "GUILOGCOLOR": "blue", + "GUIINFOCOLOR": "green", + "GUIERRCOLOR": "red", "NDBUFFERSIZE": "10000000", "EDITOR": "@EDITOR@", "FORMAT": "McCode", diff --git a/tools/Python/mcgui/viewclasses.py b/tools/Python/mcgui/viewclasses.py index 07499c007..845d1178b 100644 --- a/tools/Python/mcgui/viewclasses.py +++ b/tools/Python/mcgui/viewclasses.py @@ -71,7 +71,14 @@ def closeCodeEditorWindow(self): ''' def updateInstrument(self, labels, instr): ''' labels: , ''' - self.mw.ui.lblInstrument.setText(labels[0]) + if len(labels[0])>70: + label=str(pathlib.Path("(..long dirname..)",pathlib.Path(labels[0]).name)) + tooltip="Located in: "+str(pathlib.Path(labels[0]).parent) + else: + label=labels[0] + tooltip=labels[0] + self.mw.ui.lblInstrument.setText(label) + self.mw.ui.lblInstrument.setToolTip(tooltip) if str(labels[0]) == '': self.__ssd = None if Qsci: @@ -85,11 +92,11 @@ def updateLog(self, text='', error=False, gui=False, clear=False): if clear: self.mw.ui.txtbrwMcgui.setText('Cleared messages.') if error: - self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor('red')) + self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor(mccode_config.configuration["GUIERRCOLOR"])) elif gui: - self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor('blue')) + self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor(mccode_config.configuration["GUILOGCOLOR"])) else: - self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor('green')) + self.mw.ui.txtbrwMcgui.setTextColor(QtGui.QColor(mccode_config.configuration["GUIINFOCOLOR"])) self.mw.ui.txtbrwMcgui.append(text) def disableRunBtn(self): @@ -116,9 +123,9 @@ def updateSimState(self, state=[]): ui.btnEdit.setEnabled(enableRun) ui.btnPlot.setEnabled(enablePlot) if enableRun: - ui.lblInstrument.setStyleSheet('color: green') + ui.lblInstrument.setStyleSheet('color: ' + mccode_config.configuration["GUILOGCOLOR"]) else: - ui.lblInstrument.setStyleSheet('color: red') + ui.lblInstrument.setStyleSheet('color: ' + mccode_config.configuration["GUIERRCOLOR"]) ui.actionClose_Instrument.setEnabled(enableRun) ui.actionPlot.setEnabled(enablePlot) ui.actionDisplay.setEnabled(enableRun)