void
GLFitDirector::Fit()
{
	JXGetApplication()->DisplayBusyCursor();
	RemoveFit();
	JIndex index;
	JBoolean ok	= itsCurveList->GetCurrentCurveIndex(&index);
	JPlotDataBase* data	= &(itsPlot->GetCurve(index));
	ok	= itsFitList->GetCurrentFitIndex(&index);
	assert(ok);
	const GLFitDescription& fd	= GetFitManager()->GetFitDescription(index);
	if (fd.GetType() == GLFitDescription::kPolynomial)
		{
		JArray<JIndex> powers;
		const GLPolyFitDescription& pd	= dynamic_cast<const GLPolyFitDescription&>(fd);
		pd.GetPowers(&powers);
		assert(ok);

		JFloat xmax, xmin, ymax, ymin;
		JPlotFitLinearEq* fit;
		if (itsFitPlot->IsUsingRange())
			{
			itsFitPlot->GetRange(&xmin, &xmax, &ymin, &ymax);
			fit = new JPlotFitLinearEq(itsFitPlot, data, xmin, xmax, ymin, ymax);
			assert(fit != NULL);
			}
		else
			{
			data->GetXRange(&xmin, &xmax);
			fit = new JPlotFitLinearEq(itsFitPlot, data, xmin, xmax);
			assert(fit != NULL);
			}
		fit->InitializePolynomial(powers);
		if (itsParameterTable->IsShowingStartCol())
			{
			JVector p(const_cast<GLFitDescription&>(fd).GetVarList()->GetVariableCount() - 1);
			const JArray<JFloat>& parms	= itsParameterTable->GetStartValues();
			const JSize count	= p.GetDimensionCount();
			for (JIndex i = 1; i <= count; i++)
				{
				p.SetElement(i, parms.GetElement(i));
				}
			fit->JPlotFitBase::GenerateFit(p, 0);
			}
		else
			{
			fit->GenerateFit();
			}
		itsCurrentFit = fit;
		}
	else if (fd.GetType() == GLFitDescription::kNonLinear)
		{
		GLNonLinearFitDescription& nd	= 
			dynamic_cast<GLNonLinearFitDescription&>(const_cast<GLFitDescription&>(fd));

		JFloat xmax, xmin, ymax, ymin;
		JPlotFitNonLinear* fit;
		if (itsFitPlot->IsUsingRange())
			{
			itsFitPlot->GetRange(&xmin, &xmax, &ymin, &ymax);
			fit = new JPlotFitNonLinear(itsFitPlot, data, xmin, xmax, ymin, ymax);
			assert(fit != NULL);
			}
		else
			{
			data->GetXRange(&xmin, &xmax);
			fit = new JPlotFitNonLinear(itsFitPlot, data, xmin, xmax);
			assert(fit != NULL);
			}
		fit->SetVarList(nd.GetVarList());
		fit->SetFunction(nd.GetFunctionString());
		JString fp	= nd.GetFunctionPrimedString();
		if (!fp.IsEmpty())
			{
			fit->SetFPrimed(fp);
			}		
		JVector p(nd.GetVarList()->GetVariableCount() - 1);
		const JArray<JFloat>& parms	= itsParameterTable->GetStartValues();
		const JSize count	= p.GetDimensionCount();
		for (JIndex i = 1; i <= count; i++)
			{
			p.SetElement(i, parms.GetElement(i));
			}
		fit->SetInitialParameters(p);
		itsCurrentFit = fit;
		}
	else if (fd.GetType() == GLFitDescription::kBLinear)
		{
		JFloat xmax, xmin, ymax, ymin;
		JPlotFitLinear* fit;
		if (itsFitPlot->IsUsingRange())
			{
			itsFitPlot->GetRange(&xmin, &xmax, &ymin, &ymax);
			fit = new JPlotFitLinear(itsFitPlot, data, xmin, xmax, ymin, ymax);
			assert(fit != NULL);
			}
		else
			{
			data->GetXRange(&xmin, &xmax);
			fit = new JPlotFitLinear(itsFitPlot, data, xmin, xmax);
			assert(fit != NULL);
			}
		if (itsParameterTable->IsShowingStartCol())
			{
			JVector p(const_cast<GLFitDescription&>(fd).GetVarList()->GetVariableCount() - 1);
			const JArray<JFloat>& parms	= itsParameterTable->GetStartValues();
			const JSize count	= p.GetDimensionCount();
			for (JIndex i = 1; i <= count; i++)
				{
				p.SetElement(i, parms.GetElement(i));
				}
			fit->JPlotFitBase::GenerateFit(p, 0);
			}
		else
			{
			fit->GenerateFit();
			}
		itsCurrentFit = fit;
		}
	else if (fd.GetType() == GLFitDescription::kBExp)
		{
		JFloat xmax, xmin, ymax, ymin;
		JPlotFitExp* fit;
		if (itsFitPlot->IsUsingRange())
			{
			itsFitPlot->GetRange(&xmin, &xmax, &ymin, &ymax);
			fit = new JPlotFitExp(itsFitPlot, data, xmin, xmax, ymin, ymax);
			assert(fit != NULL);
			}
		else
			{
			data->GetXRange(&xmin, &xmax);
			fit = new JPlotFitExp(itsFitPlot, data, xmin, xmax);
			assert(fit != NULL);
			}
		if (itsParameterTable->IsShowingStartCol())
			{
			JVector p(const_cast<GLFitDescription&>(fd).GetVarList()->GetVariableCount() - 1);
			const JArray<JFloat>& parms	= itsParameterTable->GetStartValues();
			const JSize count	= p.GetDimensionCount();
			for (JIndex i = 1; i <= count; i++)
				{
				p.SetElement(i, parms.GetElement(i));
				}
			fit->JPlotFitBase::GenerateFit(p, 0);
			}
		else
			{
			fit->GenerateFit();
			}
		itsCurrentFit = fit;
		}
	else if (fd.GetType() == GLFitDescription::kBPower)
		{
		JFloat xmax, xmin, ymax, ymin;
		JPlotFitPowerLaw* fit;
		if (itsFitPlot->IsUsingRange())
			{
			itsFitPlot->GetRange(&xmin, &xmax, &ymin, &ymax);
			fit = new JPlotFitPowerLaw(itsFitPlot, data, xmin, xmax, ymin, ymax);
			assert(fit != NULL);
			}
		else
			{
			data->GetXRange(&xmin, &xmax);
			fit = new JPlotFitPowerLaw(itsFitPlot, data, xmin, xmax);
			assert(fit != NULL);
			}
		if (itsParameterTable->IsShowingStartCol())
			{
			JVector p(const_cast<GLFitDescription&>(fd).GetVarList()->GetVariableCount() - 1);
			const JArray<JFloat>& parms	= itsParameterTable->GetStartValues();
			const JSize count	= p.GetDimensionCount();
			for (JIndex i = 1; i <= count; i++)
				{
				p.SetElement(i, parms.GetElement(i));
				}
			fit->JPlotFitBase::GenerateFit(p, 0);
			}
		else
			{
			fit->GenerateFit();
			}
		itsCurrentFit = fit;
		}
	else if (fd.GetType() == GLFitDescription::kModule)
		{
		GLModuleFitDescription& md	= 
			dynamic_cast<GLModuleFitDescription&>(const_cast<GLFitDescription&>(fd));
		JFloat xmax, xmin, ymax, ymin;
		JPlotFitModule* fit;
		if (itsFitPlot->IsUsingRange())
			{
			itsFitPlot->GetRange(&xmin, &xmax, &ymin, &ymax);
			fit = new JPlotFitModule(itsFitPlot, data, xmin, xmax, ymin, ymax);
			assert(fit != NULL);
			}
		else
			{
			data->GetXRange(&xmin, &xmax);
			fit = new JPlotFitModule(itsFitPlot, data, xmin, xmax);
			assert(fit != NULL);
			}
		fit->SetFitModule(md.GetFitModule());
		JVector p(md.GetParameterCount());
		const JArray<JFloat>& parms	= itsParameterTable->GetStartValues();
		const JSize count	= p.GetDimensionCount();
		for (JIndex i = 1; i <= count; i++)
			{
			p.SetElement(i, parms.GetElement(i));
			}
		fit->SetInitialParameters(p);
		itsCurrentFit = fit;
		}
	itsFitPlot->AddCurve(itsCurrentFit, kJFalse, fd.GetFnName());
	itsDiffPlot->AddCurve(itsCurrentFit->GetDiffData(), kJFalse, fd.GetFnName());
	const JSize count	= itsCurrentFit->GetParameterCount();
	for (JIndex i = 1; i <= count; i++)
		{
		JFloat value;
		JBoolean ok	= itsCurrentFit->GetParameter(i, &value);
		assert(ok);
		JFloat error = 0;
		itsCurrentFit->GetParameterError(i, &error);
		itsParameterTable->SetValue(i, value, error);			
		if (itsCurrentFit->GetGoodnessOfFit(&value))
			{
			itsChiSq->SetText(JString(value, JString::kPrecisionAsNeeded, JString::kStandardExponent, 0, 5));
			}
		else
			{
			itsChiSq->SetText("");
			}
		
		}
}
Exemplo n.º 2
0
JBoolean
JXDockWidget::Dock
	(
	JXWindow*		w,
	const JBoolean	reportError
	)
{
	if (itsChildPartition != NULL)
		{
		return kJFalse;
		}

	const JRect geom = GetApertureGlobal();
	JPoint minSize;
	if (w->Dock(this, (GetWindow())->GetXWindow(), geom, &minSize))
		{
		if (itsWindowList == NULL)
			{
			itsWindowList = new JPtrArray<JXWindow>(JPtrArrayT::kForgetAll);
			assert( itsWindowList != NULL );
			}

		const JSize count = itsWindowList->GetElementCount();
		assert( count == itsTabGroup->GetTabCount() );

		const JCharacter* title =
			JXFileDocument::SkipNeedsSavePrefix(w->GetTitle());

		JIndex index = count+1;
		for (JIndex i=1; i<=count; i++)
			{
			const JCharacter* t =
				JXFileDocument::SkipNeedsSavePrefix((itsWindowList->NthElement(i))->GetTitle());
			if (JStringCompare(title, t, kJFalse) < 0)
				{
				index = i;
				break;
				}
			}

		itsWindowList->InsertAtIndex(index, w);
		ListenTo(w);
		UpdateMinSize();

		itsTabGroup->InsertTab(index, w->GetTitle());

		// Can't call ShowTab() because window might be partially constructed,
		// so Activate() could blow up.

		JXSelectTabTask* task = new JXSelectTabTask(itsTabGroup, index);
		assert( task != NULL );
		(JXGetApplication())->InstallUrgentTask(task);

		return kJTrue;
		}
	else
		{
		if (reportError)
			{
			(JGetUserNotification())->ReportError(JGetString(kWindowWillNotFitID));
			}
		return kJFalse;
		}
}
void
JXFSBindingManager::ProcessFiles()
{
    if (!HasFiles() || itsRunFileDialog != NULL)
    {
        return;
    }

    // check for file with no command

    JSize count = itsFileList->GetElementCount();
    for (JIndex i=1; i<=count; i++)
    {
        JFSBinding* f           = itsFileList->NthElement(i);
        const JString& fileName = f->GetPattern();

        JFSBinding::CommandType type;
        JBoolean singleFile;
        const JString& cmd = f->GetCommand(&type, &singleFile);

        const JFSBinding* b;
        if (!itsIgnoreBindingsFlag &&
                cmd.IsEmpty() && itsBindingList->GetBinding(fileName, &b))
        {
            const JString& cmd = b->GetCommand(&type, &singleFile);
            f->SetCommand(cmd, type, singleFile);
        }
        else if (cmd.IsEmpty())
        {
            assert( itsRunFileDialog == NULL );
            itsRunFileDialog =
                new JXFSRunFileDialog(fileName, JNegate(count > 1 && itsIgnoreBindingsFlag));
            assert( itsRunFileDialog != NULL );
            ListenTo(itsRunFileDialog);
            itsRunFileDialog->BeginDialog();
            itsRunFileIndex = i;
            return;
        }
    }

    // exec one-at-a-time cmds

    (JXGetApplication())->DisplayBusyCursor();

    for (JIndex i=1; i<=count; i++)
    {
        JFSBinding::CommandType t;
        JBoolean singleFile;
        (itsFileList->NthElement(i))->GetCommand(&t, &singleFile);

        if (singleFile)
        {
            Exec(i, i);
            itsFileList->DeleteElement(i);
            count--;
            i--;	// compensate for shift
        }
    }

    // group remaining files and exec

    if (count > 0)
    {
        itsFileList->SetCompareFunction(CompareCommands);
        itsFileList->Sort();

        JIndex startIndex = 1;
        JString cmd;
        JFSBinding::CommandType type = JFSBinding::kRunPlain;

        for (JIndex i=1; i<=count; i++)
        {
            JFSBinding* f           = itsFileList->NthElement(i);
            const JString& fileName = f->GetPattern();

            JFSBinding::CommandType t;
            JBoolean singleFile;
            const JString& c = f->GetCommand(&t, &singleFile);
            assert( !singleFile );

            if (i == startIndex)
            {
                cmd  = c;
                type = t;
            }
            else if (c != cmd || type != t)
            {
                Exec(startIndex, i-1);

                startIndex = i;
                cmd        = c;
                type       = t;
            }
        }

        Exec(startIndex, count);
    }

    delete itsFileList;
    itsFileList = NULL;
}
void
CBSymbolTable::RebuildTable()
{
	(JXGetApplication())->DisplayBusyCursor();

	const JPoint scrollPt = (GetAperture()).topLeft();

	ClearSelection();
	itsKeyBuffer.Clear();
	itsMaxStringWidth = 0;

	if (itsVisibleListLockedFlag)
		{
		const JSize count = itsVisibleList->GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			const JIndex j = itsVisibleList->GetElement(i);

			const JString* signature;
			itsSymbolList->GetSignature(j, &signature);

			CBLanguage lang;
			CBSymbolList::Type type;
			CalcColWidths(itsSymbolList->GetSymbol(j, &lang, &type), signature);
			}
		}
	else if (itsNameFilter != NULL || itsNameLiteral != NULL)
		{
		itsVisibleList->RemoveAll();

		const JSize symbolCount = itsSymbolList->GetElementCount();
		for (JIndex i=1; i<=symbolCount; i++)
			{
			CBLanguage lang;
			CBSymbolList::Type type;
			const JString& symbolName = itsSymbolList->GetSymbol(i, &lang, &type);

			const JString* signature;
			itsSymbolList->GetSignature(i, &signature);

			if (/* (CBGetSymbolTypeList())->IsVisible(type) && */

				((itsNameFilter  != NULL && itsNameFilter->Match(symbolName)) ||
				 (itsNameLiteral != NULL && symbolName.Contains(*itsNameLiteral)))
				)
				{
				itsVisibleList->AppendElement(i);
				CalcColWidths(symbolName, signature);
				}
			}
		}
	else	// optimize because scanning 1e5 symbols takes a while!
		{
		const JSize symbolCount = itsSymbolList->GetElementCount();
		if (itsVisibleList->GetElementCount() > symbolCount)
			{
			itsVisibleList->RemoveNextElements(
				symbolCount+1, itsVisibleList->GetElementCount() - symbolCount);
			}
		while (itsVisibleList->GetElementCount() < symbolCount)
			{
			itsVisibleList->AppendElement(itsVisibleList->GetElementCount()+1);
			}
		}

	const JSize rowCount = itsVisibleList->GetElementCount();
	if (GetRowCount() < rowCount)
		{
		AppendRows(rowCount - GetRowCount());
		}
	else if (GetRowCount() > rowCount)
		{
		RemoveNextRows(rowCount+1, GetRowCount() - rowCount);
		}

	AdjustColWidths();
	ScrollTo(scrollPt);
	Refresh();
}
JXPTPrintSetupDialog::JXPTPrintSetupDialog()
	:
	JXDialogDirector(JXGetApplication(), kJTrue)
{
}
void
JXProgressDisplay::DisplayBusyCursor()
{
	(JXGetApplication())->DisplayBusyCursor();
}
Exemplo n.º 7
0
JBoolean
GMApp::OpenSession()
{
	JBoolean success = kJFalse;

	JString homeDir;
	if (JGetHomeDirectory(&homeDir))
		{
		JAppendDirSeparator(&homeDir);
		JString session = homeDir + kStateFileName;
		if (JFileExists(session) && JFileReadable(session))
			{
			JFileArray* fileArray;
			JError err = JFileArray::Create(session, kStateFileSignature, &fileArray);
			if (err.OK())
				{
				JFileVersion version = fileArray->GetVersion();
				if (0 < version && version <= kCurrentSessionVersion)
					{
					JFAID id = 1;
					JSize count;
					{
					std::string data;
					fileArray->GetElement(id, &data);
					std::istringstream is(data);
					is >> count;
					id.SetID(id.GetID() + 1);
					}

					if (count == 0)
						{
						delete fileArray;
						JRemoveFile(session);
						return kJFalse;
						}

					for (JSize i = 1; i <= count; i++)
						{
						JFileArray* embed;
						err = JFileArray::Create(fileArray, id, &embed);
						GMessageTableDir* dir;
						if (GMessageTableDir::Create(this, *embed, &dir, version))
							{
							itsTableDirs->Append(dir);
							}
						id.SetID(id.GetID() + 1);
						delete embed;
						}

					{
					std::string data;
					fileArray->GetElement(id, &data);
					std::istringstream is(data);
					is >> count;
					id.SetID(id.GetID() + 1);
					}

					for (JSize i = 1; i <= count; i++)
						{
						std::string data;
						fileArray->GetElement(id, &data);
						std::istringstream is(data);
						GMessageEditDir* dir = new GMessageEditDir(JXGetApplication());
						assert(dir != NULL);
						dir->ReadState(is, version);
						dir->Activate();
						id.SetID(id.GetID() + 1);
						}

					{
					std::string data;
					fileArray->GetElement(id, &data);
					std::istringstream is(data);
					GGetInboxMgr()->ReadState(is);
					}

					success = kJTrue;
					}
JXPSPageSetupDialog::JXPSPageSetupDialog()
	:
	JXDialogDirector(JXGetApplication(), kJTrue)
{
}
Exemplo n.º 9
0
JBoolean
CBCommand::StartProcess()
{
	// check if we are finished

	while (!itsCmdList->IsEmpty() && (itsCmdList->GetElement(1)).IsEndOfSequence())
		{
		CmdInfo info = itsCmdList->GetElement(1);
		info.Free(kJTrue);
		itsCmdList->RemoveElement(1);
		}
	if (itsCmdList->IsEmpty())
		{
		if (itsBeepFlag && itsParent == NULL)
			{
			((JXGetApplication())->GetCurrentDisplay())->Beep();
			}
		DeleteThis();
		return kJFalse;
		}

	// check if we can use the window

	itsInQueueFlag = kJFalse;
	if (itsOutputDoc != NULL && itsOutputDoc->ProcessRunning())
		{
		itsInQueueFlag = kJTrue;
		ListenTo(itsOutputDoc);
		return kJTrue;	// wait for message from itsOutputDoc
		}

	// check if need to run a subroutine

	CmdInfo info = itsCmdList->GetElement(1);
	if (info.cmdObj != NULL)
		{
		StopListening(itsOutputDoc);	// wait for CBCommand to notify us
		const JBoolean result = (info.cmdObj)->Start(*(info.cmdInfo));
		info.Free(kJFalse);
		itsCmdList->RemoveElement(1);
		return result;
		}

	// start process

	assert( info.cmd != NULL );

	JShouldIncludeCWDOnPath(kJTrue);

	JProcess* p;
	int toFD, fromFD;
	JError execErr = JNoError();
	if (itsOutputDoc != NULL)
		{
		execErr = JProcess::Create(&p, itsCmdPath, *(info.cmd),
								   kJCreatePipe, &toFD,
								   kJCreatePipe, &fromFD,
								   kJAttachToFromFD, NULL);
		}
	else
		{
		JSimpleProcess* p1;
		execErr = JSimpleProcess::Create(&p1, itsCmdPath, *(info.cmd), kJTrue);
		p       = p1;
		}

	JShouldIncludeCWDOnPath(kJFalse);

	if (!execErr.OK())
		{
		execErr.ReportIfError();
		DeleteThis();
		return kJFalse;
		}

	if (itsOutputDoc != NULL)
		{
		const JSize count = info.cmd->GetElementCount();
		JString cmd;
		for (JIndex i=1; i<=count; i++)
			{
			cmd += JPrepArgForExec(*info.cmd->NthElement(i));
			cmd += " ";
			}

		itsOutputDoc->SetConnection(p, fromFD, toFD, itsWindowTitle, itsDontCloseMsg,
									itsCmdPath, cmd, kJTrue);

		// We can't do this in Start() because we might be waiting for
		// itsMakeDependCmd.  We must not listen to both at the same time.

		ListenTo(itsOutputDoc);
		}
	else
		{
		ListenTo(p);
		JThisProcess::Ignore(p);
		}

	info.Free(kJTrue);
	itsCmdList->RemoveElement(1);
	return kJTrue;
}
JXUrgentTask::~JXUrgentTask()
{
	(JXGetApplication())->RemoveUrgentTask(this);
}
void
JXUrgentTask::Go()
{
	(JXGetApplication())->InstallUrgentTask(this);
}
void
TestDirector::BuildWindow
	(
	const JBoolean isMaster,
	const JBoolean bufferTestWidget,
	const JBoolean testWidgetIsImage
	)
{
	JXDisplay* display   = (JXGetApplication())->GetCurrentDisplay();
	JXColormap* colormap = display->GetColormap();

// begin JXLayout

    JXWindow* window = new JXWindow(this, 400,330, "");
    assert( window != NULL );

    JXMenuBar* menuBar =
        new JXMenuBar(window,
                    JXWidget::kHElastic, JXWidget::kFixedTop, 0,0, 400,30);
    assert( menuBar != NULL );

    JXScrollbarSet* scrollbarSet =
        new JXScrollbarSet(window,
                    JXWidget::kHElastic, JXWidget::kVElastic, 0,30, 400,300);
    assert( scrollbarSet != NULL );

// end JXLayout

	window->SetTitle("Test Director");
	window->SetWMClass("testjx", "TestDirector");

	window->SetMinSize(150,150);
	if (isMaster)
		{
		window->SetCloseAction(JXWindow::kQuitApp);
		}
	else
		{
		window->SetCloseAction(JXWindow::kCloseDisplay);
		}

	itsAnimIconTask = new AnimateWindowIconTask(GetWindow());
	assert( itsAnimIconTask != NULL );
	ListenTo(window);		// for icon animation

	// menus

	JXImage* aboutTitleImage =
		new JXImage(display, kSmileyBitmap[ kHappySmileyIndex ], colormap->GetRedColor());
	assert( aboutTitleImage != NULL );
	itsAboutMenu = menuBar->AppendTextMenu(aboutTitleImage, kJTrue);
	itsAboutMenu->SetShortcuts(kAboutMenuShortcuts);
	itsAboutMenu->SetMenuItems(kAboutMenuStr, "TestDirector");
	itsAboutMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsAboutMenu);

	itsAnimHelpTask = new AnimateHelpMenuTask(itsAboutMenu, kHelpCmd);
	assert( itsAnimHelpTask != NULL );

	itsPrintPSMenu = new JXTextMenu(itsAboutMenu, kPrintPSMenuCmd, menuBar);
	assert( itsPrintPSMenu != NULL );
	itsPrintPSMenu->SetMenuItems(kPrintPSMenuStr);
	itsPrintPSMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsPrintPSMenu);

	itsTestMenu = menuBar->AppendTextMenu(kTestMenuTitleStr);
	itsTestMenu->SetMenuItems(kTestMenuStr);
	itsTestMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsTestMenu);

	itsUNMenu = new JXTextMenu(itsTestMenu, kTestUserNotifyMenuCmd, menuBar);
	assert( itsUNMenu != NULL );
	itsUNMenu->SetMenuItems(kUserNotificationMenuStr);
	itsUNMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsUNMenu);

	itsCSFMenu = new JXTextMenu(itsTestMenu, kTestChooseSaveFileMenuCmd, menuBar);
	assert( itsCSFMenu != NULL );
	itsCSFMenu->SetMenuItems(kChooseSaveFileMenuStr);
	itsCSFMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsCSFMenu);

	itsPGMenu = new JXTextMenu(itsTestMenu, kTestPGMenuCmd, menuBar);
	assert( itsPGMenu != NULL );
	itsPGMenu->SetMenuItems(kProgressDisplayMenuStr);
	itsPGMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsPGMenu);

	if (isMaster)
		{
		itsDisplayMenu =
			new JXDisplayMenu(kDisplayMenuName, menuBar,
							  JXWidget::kFixedLeft, JXWidget::kFixedTop,
							  0,0, 10,10);
		assert( itsDisplayMenu != NULL );
		menuBar->AppendMenu(itsDisplayMenu);
		}
	else
		{
		itsDisplayMenu = NULL;
		}

	itsWidget =
		new TestWidget(isMaster, testWidgetIsImage,
					   menuBar, scrollbarSet,
					   scrollbarSet->GetScrollEnclosure(),
					   JXWidget::kHElastic, JXWidget::kVElastic,
					   0,0, 10,10);
	assert( itsWidget != NULL );
	itsWidget->FitToEnclosure(kJTrue, kJTrue);
	itsWidget->SetSingleFocusWidget();

	BuildIconMenus(window, menuBar);

	// do this -after- constructing JXScrollableWidget

	(GetWindow())->BufferDrawing(bufferTestWidget);
}
Exemplo n.º 13
0
PlotDir::PlotDir
	(
	JXDirector*       supervisor,
	JXFileDocument*   notifySupervisor,
	const JCharacter* filename,
	const JBoolean    hideOnClose
	)
	:
	JXDocument(supervisor),
	itsFileName(filename)
{
	itsSupervisor       = notifySupervisor;
	itsHideOnClose      = hideOnClose;
	itsPlotIsClosing	= kJFalse;

	itsPrinter          = NULL;

	JCoordinate w 		= 500;
	JCoordinate h       = 400;
	JCoordinate minW	= 400;
	JCoordinate minH    = 300;

	JXWindow* window = jnew JXWindow(this, w,h, filename);
	assert( window != NULL );

	window->SetMinSize(minW,minH);
	if (hideOnClose)
		{
		window->SetCloseAction(JXWindow::kDeactivateDirector);
		}

	JXMenuBar* menuBar =
		jnew JXMenuBar(window,
			JXWidget::kHElastic, JXWidget::kFixedTop, 0,0, w, kJXDefaultMenuBarHeight);
	assert( menuBar != NULL );

	itsPlotMenu = menuBar->AppendTextMenu(kPlotMenuTitleStr);
	itsPlotMenu->SetMenuItems(kPlotMenuStr);
	itsPlotMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsPlotMenu);

	itsAnalysisMenu = menuBar->AppendTextMenu(kAnalysisMenuTitleStr);
	itsAnalysisMenu->SetMenuItems(kAnalysisMenuStr);
	itsAnalysisMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsAnalysisMenu);

	itsFitParmsMenu = jnew JXTextMenu(itsAnalysisMenu, kFitParmsCmd, menuBar);
	assert( itsFitParmsMenu != NULL );
	itsFitParmsMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsFitParmsMenu);
	itsAnalysisMenu->DisableItem(kFitParmsCmd);

	itsDiffMenu = jnew JXTextMenu(itsAnalysisMenu, kDiffPlotCmd, menuBar);
	assert( itsDiffMenu != NULL );
	itsDiffMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsDiffMenu);
	itsAnalysisMenu->DisableItem(kDiffPlotCmd);

	itsSessionDir =
		jnew GloveHistoryDir(JXGetApplication());
	assert(itsSessionDir != NULL);
	JXGetDocumentManager()->DocumentMustStayOpen(itsSessionDir, kJTrue);
	ListenTo(itsSessionDir);

	itsPlot =
		jnew GlovePlotter(itsSessionDir, menuBar, window,
			JXWidget::kHElastic, JXWidget::kVElastic,
			0, 30, w, h - kJXDefaultMenuBarHeight);
	assert( itsPlot != NULL );

	ListenTo(itsPlot);

	JXDocumentMenu* windowListMenu =
		jnew JXDocumentMenu(kWindowListMenuTitleStr, menuBar,
			JXWidget::kFixedLeft, JXWidget::kVElastic, 0,0, 10,10);
	assert( windowListMenu != NULL );
	menuBar->AppendMenu(windowListMenu);

	itsHelpMenu = menuBar->AppendTextMenu(kHelpMenuTitleStr);
	itsHelpMenu->SetMenuItems(kHelpMenuStr);
	itsHelpMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsHelpMenu);

	itsVarList	 = jnew GVarList();
	itsVarList->AddVariable("x",0);
	itsXVarIndex = 1;
	itsFunctionDialog = NULL;
	itsFitModuleDialog = NULL;

	itsFits = jnew JPtrArray<JFitBase>(JPtrArrayT::kForgetAll);
	assert( itsFits != NULL );
	ListenTo(itsFits);
	itsFitParmsDir = jnew FitParmsDir(this, itsFits);
	assert( itsFitParmsDir != NULL );
	itsCurveStats = jnew JArray<CurveStats>;
	assert( itsCurveStats != NULL );
	itsCurrentCurveType = kGDataCurve;

	itsDiffDirs = jnew JPtrArray<PlotDir>(JPtrArrayT::kForgetAll);
	assert( itsDiffDirs != NULL );
	ListenTo(itsDiffDirs);

	itsPrinter = jnew JXPSPrinter(GetDisplay());
	assert( itsPrinter != NULL );
	itsPrinter->SetOrientation(JPSPrinter::kLandscape);

	itsEPSPrinter	= jnew JX2DPlotEPSPrinter(GetDisplay());
	assert(itsEPSPrinter != NULL);
	itsPlot->SetEPSPrinter(itsEPSPrinter);

	ListenTo(itsPrinter);
}
Exemplo n.º 14
0
JXDisplay*
JXDisplayMenu::GetSelectedDisplay()
	const
{
	return (JXGetApplication())->GetDisplay(itsDisplayIndex);
}
Exemplo n.º 15
0
void
JXDisplayMenu::SelectCurrentDisplay()
	const
{
	(JXGetApplication())->SetCurrentDisplay(itsDisplayIndex);
}
JError
CBSearchDocument::Create
	(
	const JPtrArray<JString>&	fileList,
	const JPtrArray<JString>&	nameList,
	const JCharacter*			searchStr,
	const JCharacter*			replaceStr
	)
{
	assert( !fileList.IsEmpty() );
	assert( fileList.GetElementCount() == nameList.GetElementCount() );

	int fd[2];
	JError err = JCreatePipe(fd);
	if (!err.OK())
		{
		return err;
		}

	pid_t pid;
	err = JThisProcess::Fork(&pid);
	if (!err.OK())
		{
		return err;
		}

	// child

	else if (pid == 0)
		{
		close(fd[0]);

		// get rid of JXCreatePG, since we must not use X connection
		// (binary files may trigger it)
		JInitCore();

		CBSearchTE te;
		JOutPipeStream output(fd[1], kJTrue);
		te.SearchFiles(fileList, nameList, kJTrue, kJFalse, output);
		output.close();
		exit(0);
		}

	// parent

	else
		{
		close(fd[1]);

		JProcess* process = jnew JProcess(pid);
		assert( process != NULL );

		const JCharacter* map[] =
			{
			"s", searchStr,
			"r", replaceStr
			};
		const JString windowTitle = JGetString("ReplaceTitle::CBSearchDocument", map, sizeof(map));

		CBSearchDocument* doc =
			jnew CBSearchDocument(kJTrue, kJTrue, fileList.GetElementCount(),
								 process, fd[0], windowTitle);
		assert( doc != NULL );

		(JXGetApplication())->Suspend();	// do this first so result window is active
		doc->Activate();

		RecordLink* link;
		const JBoolean ok = doc->GetRecordLink(&link);
		assert( ok );
		CBSearchTE::SetProtocol(link);
		}

	return JNoError();
}