⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cellmenu.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if (wnd == null) return;		Cell cell = WindowFrame.needCurCell();		if (cell == null) return;		if (!cell.isMultiPage())		{			System.out.println("This is not a multi-page schematic.  To delete this cell, use 'Cell / Delete Cell'");			return;		}		int curPage = wnd.getMultiPageNumber();		new DeleteMultiPageJob(cell, curPage);		int numPages = cell.getNumMultiPages();		if (curPage >= numPages) wnd.setMultiPageNumber(numPages-1);	}	/**	 * This method implements the command to edit the next page in a multi-page schematic.	 */	private static void editNextMultiPage()	{		EditWindow wnd = EditWindow.needCurrent();		if (wnd == null) return;		Cell cell = WindowFrame.needCurCell();		if (cell == null) return;		if (!cell.isMultiPage())		{			System.out.println("First turn this cell into a multi-page schematic");			return;		}		int curPage = wnd.getMultiPageNumber();		int numPages = cell.getNumMultiPages();		wnd.setMultiPageNumber((curPage+1) % numPages);	}	/**	 * This method implements the command to do cross-library copies.	 */	private static void crossLibraryCopyCommand()	{		CrossLibCopy dialog = new CrossLibCopy(TopLevel.getCurrentJFrame());		dialog.setVisible(true);	}	/**	 * This command pushes down the hierarchy	 * @param keepFocus true to keep the zoom and scale in the new window.	 * @param newWindow true to create a new window for the cell.	 */	private static void downHierCommand(boolean keepFocus, boolean newWindow)	{		EditWindow curEdit = EditWindow.needCurrent();		if (curEdit == null) return;		curEdit.downHierarchy(keepFocus, newWindow, false);	}	/**	 * This command pushes down the hierarchy "in place".	 */	private static void downHierInPlaceCommand()	{		EditWindow curEdit = EditWindow.needCurrent();		if (curEdit == null) return;		curEdit.downHierarchy(false, false, true);	}	private static class DownHierToObjectActionListener implements ActionListener	{		GeometrySearch.GeometrySearchResult result;		DownHierToObjectActionListener(GeometrySearch.GeometrySearchResult r) { result = r; }		public void actionPerformed(ActionEvent e)		{			descendToObject(result);		}	}	private static void downHierInPlaceToObject()	{		EditWindow curEdit = EditWindow.needCurrent();		if (curEdit == null) return;		Cell cell = curEdit.getCell();		if (cell == null) return;		if (cell.getView() != View.LAYOUT)		{			System.out.println("Current cell should be a layout cell for 'Down Hierarchy In Place To Object'");			return;		}		// find all objects under the mouse		Point2D mouse = ClickZoomWireListener.theOne.getLastMouse();		Point2D mouseDB = curEdit.screenToDatabase((int)mouse.getX(), (int)mouse.getY());		EPoint point = new EPoint(mouseDB.getX(), mouseDB.getY());		GeometrySearch.GeometrySearchResult foundAtTopLevel = null;		GeometrySearch search = new GeometrySearch();		List<GeometrySearch.GeometrySearchResult> possibleTargets = search.searchGeometries(cell, point, true);		// eliminate results at the top level and duplicate results at any lower level		for(int i=0; i<possibleTargets.size(); i++)		{			GeometrySearch.GeometrySearchResult res = possibleTargets.get(i);			if (res.getContext() == VarContext.globalContext)			{				possibleTargets.remove(i);				i--;				foundAtTopLevel = res;				continue;			}			// also remove duplicate contexts at lower levels			for(int j=0; j<i; j++)			{				GeometrySearch.GeometrySearchResult oRes = possibleTargets.get(j);				if (sameContext(oRes.getContext(), res.getContext()))				{					possibleTargets.remove(i);					i--;				}			}		}		// give error if nothing was found		if (possibleTargets.size() == 0)		{			// nothing found, if top-level stuff found, say so			if (foundAtTopLevel != null)				System.out.println(foundAtTopLevel.describe() + " is at the top level, not down the hierarchy"); else					System.out.println("No primitive node or arc found under the mouse at lower levels of hierarchy");			return;		}		// get the selected object to edit		if (possibleTargets.size() == 1)		{			descendToObject(possibleTargets.get(0));		} else		{			// let the user choose            JPopupMenu menu = new JPopupMenu();        	JMenuItem menuItem = new JMenuItem("Multiple objects under the cursor...choose one");            menu.add(menuItem);            menu.addSeparator();            for(GeometrySearch.GeometrySearchResult res : possibleTargets)            {            	menuItem = new JMenuItem(res.describe());            	menuItem.addActionListener(new DownHierToObjectActionListener(res));                menu.add(menuItem);            }            menu.show(curEdit, 100, 100);		}	}	private static boolean sameContext(VarContext vc1, VarContext vc2)	{		if (vc1.getNumLevels() != vc2.getNumLevels()) return false;		while (vc1.getNodable() != null && vc2.getNodable() != null)		{			if (vc1.getNodable() != vc2.getNodable()) return false;			vc1 = vc1.pop();			vc2 = vc2.pop();		}		return true;	}	private static void descendToObject(GeometrySearch.GeometrySearchResult res)	{		// descend to that object		EditWindow curEdit = EditWindow.needCurrent();		System.out.println("Descending to cell " + res.getGeometric().getParent().getName());		for (Iterator<Nodable> it = res.getContext().getPathIterator(); it.hasNext(); )		{			Nodable no = it.next();			Cell curCell = no.getParent();			curEdit.getHighlighter().clear();			curEdit.getHighlighter().addElectricObject(no.getNodeInst(), curCell);			curEdit.getHighlighter().finished();			System.out.println("  Descended into "+no.getName()+"["+no.getProto().getName()+"] in cell "+curCell.getName());			curEdit.downHierarchy(false, false, true);		}		curEdit.getHighlighter().clear();		curEdit.getHighlighter().addElectricObject(res.getGeometric(), res.getGeometric().getParent());		curEdit.getHighlighter().finished();	}	/**	 * This command goes up the hierarchy	 */	private static void upHierCommand(boolean keepFocus)	{		EditWindow curEdit = EditWindow.needCurrent();		if (curEdit == null) return;		curEdit.upHierarchy(keepFocus);	}	private static void changeCellHistory(boolean back)	{		WindowFrame wf = WindowFrame.getCurrentWindowFrame();		if (wf == null) return;		if (back) wf.cellHistoryGoBack(); else			wf.cellHistoryGoForward();	}	/**	 * This method implements the command to make a new version of the current Cell.	 */	private static void newCellVersionCommand()	{		Cell curCell = WindowFrame.needCurCell();		if (curCell == null) return;		CircuitChanges.newVersionOfCell(curCell);	}	/**	 * This method implements the command to make a copy of the current Cell.	 */	private static void duplicateCellCommand()	{		Cell curCell = WindowFrame.needCurCell();		if (curCell == null) return;		new CellMenu.NewCellName(false, curCell);	}	public static class NewCellName extends EDialog	{		private JTextField cellName;		private Cell cell;		private boolean allInGroup;		/** Creates new form New Cell Name */		public NewCellName(boolean allInGroup, Cell cell)		{			super(TopLevel.getCurrentJFrame(), true);			this.allInGroup = allInGroup;			this.cell = cell;	        setTitle(allInGroup ? "New Group Name" : "New Cell Name");	        setName("");	        addWindowListener(new WindowAdapter() {	            public void windowClosing(WindowEvent evt) { closeDialog(); }	        });	        getContentPane().setLayout(new GridBagLayout());			String prompt = "Name of duplicated cell";			if (allInGroup) prompt += " group";	        JLabel lab = new JLabel(prompt + ":");	        lab.setHorizontalAlignment(SwingConstants.LEFT);	        GridBagConstraints gbc = new GridBagConstraints();	        gbc.gridx = 0;   gbc.gridy = 0;	        gbc.gridwidth = 2;	        gbc.anchor = GridBagConstraints.WEST;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(lab, gbc);	        String oldCellName = cell.getName();	        String newName = oldCellName + "NEW";	        cellName = new JTextField(newName);	        cellName.setSelectionStart(oldCellName.length());	        cellName.setSelectionEnd(newName.length());	        cellName.setColumns(Math.max(20, newName.length()));	        cellName.addActionListener(new ActionListener() {	            public void actionPerformed(ActionEvent evt) { ok(); }	        });	        gbc = new GridBagConstraints();	        gbc.gridx = 0;   gbc.gridy = 1;	        gbc.gridwidth = 2;	        gbc.fill = GridBagConstraints.HORIZONTAL;	        gbc.anchor = GridBagConstraints.WEST;	        gbc.weightx = 1.0;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(cellName, gbc);	        JButton cancel = new JButton("Cancel");	        cancel.addActionListener(new ActionListener() {	            public void actionPerformed(ActionEvent evt) { closeDialog(); }	        });	        gbc = new GridBagConstraints();	        gbc.gridx = 0;   gbc.gridy = 2;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(cancel, gbc);	        JButton ok = new JButton("OK");	        ok.addActionListener(new ActionListener() {	            public void actionPerformed(ActionEvent evt) { ok(); }	        });	        gbc = new GridBagConstraints();	        gbc.gridx = 1;   gbc.gridy = 2;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(ok, gbc);			getRootPane().setDefaultButton(ok);	        pack();			finishInitialization();			setVisible(true);	    }		protected void escapePressed() { closeDialog(); }		private void ok()		{	    	String newName = cellName.getText();			closeDialog();			Cell already = cell.getLibrary().findNodeProto(newName);			if (already != null && already.getView() == cell.getView())			{				int response = JOptionPane.showOptionDialog(TopLevel.getCurrentJFrame(),					"Cell " + newName + " already exists.  Make this a new version?", "Confirm duplication",					JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] {"Yes", "Cancel"}, "Yes");				if (response != 0) return;			}			new CellChangeJobs.DuplicateCell(cell, newName, allInGroup);		}	}	/**	 * Method to delete old, unused versions of cells.	 */	private static void deleteOldCellVersionsCommand()	{		// count the number of old unused cells to delete in the current and in other libraries		int oldUnusedCurrent = 0, oldUnusedElsewhere = 0;		for(Library lib : Library.getVisibleLibraries())		{			for(Iterator<Cell> it = lib.getCells(); it.hasNext(); )			{				Cell cell = it.next();				if (cell.getNewestVersion() == cell) continue;				if (cell.getInstancesOf().hasNext()) continue;				if (lib == Library.getCurrent()) oldUnusedCurrent++; else					oldUnusedElsewhere++;			}		}		// if complex, prompt for what to do		if (oldUnusedCurrent+oldUnusedElsewhere != 0 && oldUnusedElsewhere != 0)		{			// old unused cells are not just in the current library: ask what to do			String [] options = {"Current library", "Other libraries", "All libraries", "Cancel"};			int ret = Job.getUserInterface().askForChoice("There are " + oldUnusedCurrent +				" old unused cells in the current library and " + oldUnusedElsewhere +				" in other libraries.  Which libraries should have their old unused cells deleted?",				"Which Old Unused Cells to Delete", options, "No");			if (ret == 0) oldUnusedElsewhere = 0;			if (ret == 1) oldUnusedCurrent = 0;			if (ret == 3) return;		}		// stop now if nothing to delete		if (oldUnusedCurrent == 0 && oldUnusedElsewhere == 0)		{			System.out.println("There are no old unused cells to delete");			return;		}		// pre-clean the cell references		List<Cell> cellsToDelete = new ArrayList<Cell>();		for(Library lib : Library.getVisibleLibraries())		{			if (lib == Library.getCurrent())			{				if (oldUnusedCurrent == 0) continue;			} else			{				if (oldUnusedElsewhere == 0) continue;			}			for(Iterator<Cell> it = lib.getCells(); it.hasNext(); )			{				Cell cell = it.next();				if (cell.getNewestVersion() == cell) continue;				if (cell.getInstancesOf().hasNext()) continue;				CircuitChanges.cleanCellRef(cell);				cellsToDelete.add(cell);			}		}		// do the deletion		new CellChangeJobs.DeleteManyCells(cellsToDelete);	}	/**	 * Method to temporarily expand the current selected area to the bottom.	 */	private static void peekCommand()	{		EditWindow wnd = EditWindow.needCurrent();		if (wnd == null) return;		Highlighter highlighter = wnd.getHighlighter();		if (highlighter == null) return;		Rectangle2D bounds = highlighter.getHighlightedArea(wnd);		if (bounds == null)		{			System.out.println("Must define an area in which to display");			return;		}		wnd.repaintContents(bounds, true);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -